Page 1 of 2

Coinslots and Coins

Posted: Sat Mar 02, 2013 2:51 am
by hades200082
Hi

I'm trying out the coinslots and coins from http://grimrock.nexusmods.com/mods/128

The coins stack in your inventory but if you drop a stack of coins on a coinslot it takes the whole stack. Is there a way to know how many coins were entered and/or a way to prevent more than a set number from entering or require only a certain amount?

Re: Coinslots and Coins

Posted: Sat Mar 02, 2013 4:58 am
by Komag
It could be done I think, you could get the stack count of the mouse item and only do it for one or if there is more than one then only take one or something, might get a bit complicated but should be possible

Re: Coinslots and Coins

Posted: Sat Mar 02, 2013 5:21 am
by germanny
AFAIK if you use shift+click at the coin stack u get one coin at mouse.
The simple way^^

Re: Coinslots and Coins

Posted: Sat Mar 02, 2013 3:09 pm
by hades200082
germanny wrote:AFAIK if you use shift+click at the coin stack u get one coin at mouse.
The simple way^^
I know that... but my players may not ;)

Komag wrote:It could be done I think, you could get the stack count of the mouse item and only do it for one or if there is more than one then only take one or something, might get a bit complicated but should be possible
I want to be able to allow my players to find coins but the when they put them in a slot, if they pick up the whole stack, for the slot to only take one at a time.

Then, if I want to have it "cost" a certain number of coins I can just attach it to a counter.

A better alternative would be to set the number of coins required on a coinslot and then whether they are entered one by one or in bunches shouldn't matter... it will only take that many coins.

Any examples of how I could achieve any of this? I'm pretty new to lua.

Re: Coinslots and Coins

Posted: Sat Mar 02, 2013 3:25 pm
by Neikun
Best way to do this is to have a little readme tutorial about it. Where you tell them coins must be inserted one by one. Shift click to separate from stack.

Re: Coinslots and Coins

Posted: Sat Mar 02, 2013 3:36 pm
by Komag
Yeah but he wants the machine not to steal too many coins at once! Relying on the player to do it right is not user friendly enough.

You would need to use hooks and scripts to check the stack amount on the mouse, then you might have to do destroying and spawning tricks to make things work right. I don't have time to work on it, but I think it should be doable with some effort.

Re: Coinslots and Coins

Posted: Sat Mar 02, 2013 4:04 pm
by hades200082
Komag wrote:Yeah but he wants the machine not to steal too many coins at once! Relying on the player to do it right is not user friendly enough.

You would need to use hooks and scripts to check the stack amount on the mouse, then you might have to do destroying and spawning tricks to make things work right. I don't have time to work on it, but I think it should be doable with some effort.
Exactly... Relying on players to do it right could potentially lead to players not being able to progress because they "wasted" all their coins.

Would a simply solution be this?

When a player inserts coin(s) the hook that catches this counts how many were inserted and calls activate that many times? Then if you wanted to refund the player the excess you could.

I may be totally off base as I'm not totally familiar with the hooks yet... Would that work?

Re: Coinslots and Coins

Posted: Sat Mar 02, 2013 7:35 pm
by Komag
I think so, sounds like a good approach

Re: Coinslots and Coins

Posted: Sat Mar 02, 2013 8:03 pm
by hades200082
Ok ... I'm going box-eyed with this.

I can clone the object and set a function for when it's activated... but I can't figure out how to get a count of the items in the stack that activated it. Am I missing something really obvious?

Re: Coinslots and Coins

Posted: Sat Mar 02, 2013 8:30 pm
by Komag
Well, it will depend on how you are setting up the slot. If it is an alcove, you can use the onInsertItem hook to run a script that will getMouseItem and getStackCount, then go from there