Author Topic: Remove keys after using  (Read 88 times)

Hawkinzon

  • Newbie
  • *
  • Posts: 14
    • View Profile
Remove keys after using
« 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

Diarandor

  • Hero Member
  • *****
  • Posts: 805
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Remove keys after using
« Reply #1 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".

Hawkinzon

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Remove keys after using
« Reply #2 on: December 05, 2017, 09:43:29 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

Diarandor

  • Hero Member
  • *****
  • Posts: 805
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Remove keys after using
« Reply #3 on: December 06, 2017, 07:52:10 am »
Which errors do you get?