Coinslots and Coins

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
hades200082
Posts: 14
Joined: Sun Feb 24, 2013 5:49 pm

Coinslots and Coins

Post 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?
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Coinslots and Coins

Post 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
Finished Dungeons - complete mods to play
User avatar
germanny
Posts: 530
Joined: Sat Apr 07, 2012 10:52 pm
Location: Kiel, Germany

Re: Coinslots and Coins

Post by germanny »

AFAIK if you use shift+click at the coin stack u get one coin at mouse.
The simple way^^
Dungeon Master Resource Pack worker and passionated Beer drinker
hades200082
Posts: 14
Joined: Sun Feb 24, 2013 5:49 pm

Re: Coinslots and Coins

Post 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.
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: Coinslots and Coins

Post 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.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Coinslots and Coins

Post 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.
Finished Dungeons - complete mods to play
hades200082
Posts: 14
Joined: Sun Feb 24, 2013 5:49 pm

Re: Coinslots and Coins

Post 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?
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Coinslots and Coins

Post by Komag »

I think so, sounds like a good approach
Finished Dungeons - complete mods to play
hades200082
Posts: 14
Joined: Sun Feb 24, 2013 5:49 pm

Re: Coinslots and Coins

Post 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?
User avatar
Komag
Posts: 3658
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Coinslots and Coins

Post 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
Finished Dungeons - complete mods to play
Post Reply