Solarus-Games English Forum

Solarus => Development => Topic started by: Hawkinzon on November 28, 2017, 06:41:51 PM

Title: Remove keys after using
Post by: Hawkinzon on November 28, 2017, 06:41:51 PM
Hi again!

I've been trying to add a key (the wooden key which already exists as an item) to my game which should be removed/decreased in amount after used.
I've been following this topic (http://forum.solarus-games.org/index.php/topic,245.0.html) about the same issue, and used the code that was set by Christopho on page 2, but I don't get the item to work properly.

I can add the key to the game and pick it, and use it to open chests. But when I have picked it up it doesn't want to decrease in amount when I open a chest even if i edit the chest to remove/decrement this item after using it. Also tried to use the counter as a required item to open the chest but it makes no different.

I also tried this directly directly in the wooden key lua and wooden key counter lua:
Function item:on_using()
             item:remove_amount(1)
end

but it doesn't work.
I have attached both my Wooden key lua and my Wooden key counter lua to be read here. Please help me!!  :'( :'(

Also, @Christopho, if you see this. You might have ALOT to do, but if you could do a tutorial about this in english as you have about the bow and arrow in french it would be AWESOME!

BR
Hawkinzon
Title: Re: Remove keys after using
Post by: Diarandor on November 28, 2017, 08:33:08 PM
If you are using a special and unique key (the wooden key), the normal keys counter will not be what you need. You need a (unique) variable associated to that key, that you could get/set with "game.get/set_value".
Title: Re: Remove keys after using
Post by: Hawkinzon on December 05, 2017, 09:43:29 PM
Quote from: Diarandor on November 28, 2017, 08:33:08 PM
If you are using a special and unique key (the wooden key), the normal keys counter will not be what you need. You need a (unique) variable associated to that key, that you could get/set with "game.get/set_value".

Hi Diarandor!

I have tried and tried but still not getting this to work properly. I have no clue were I am doing this wrong.
I even removed the wooden key and now I try to use the small key, but it still give me different errors, even when I have the exact code that Christopho wrote in the other topic (See link in description) it doesn't work. Can you please give me an example that I can test? I don't know if Christopho is talking about another "game" since he is refering to "ZSDX".

BR
Hawkinzon
Title: Re: Remove keys after using
Post by: Diarandor on December 06, 2017, 07:52:10 AM
Which errors do you get?