Item only used with a certain key.

● ARCHIVED · READ-ONLY
Started by matthewk1462 5 posts View original ↗
  1. Hello, I need some help with Item using. When I equip an item it uses it. I want it so only one key can use an item. For example all seeds for my farm are planted as soon as a I equip can I make it so Certain items can only be used with a certain key like "S" key for example and cannot be used with enter? 
  2. I think you confused several different things with each other.


    "Items" are database objects that can only be used from the menu, they have nothing to do with map events or with equipable weapons or armors.


    Items are used by opening the menu, then selecting them on the item list and then pressing enter - why would you want to use a different key at that moment in the menu?
  3. Forgive me for butting in and bringing up a dead topic, but I THINK I get where OP is coming from... For example, there's X item that fires Y lasers or whatever when you press the S (or whatever custom) key.  I've seen it done before and some devs claim it can be done with eventing only...  (I'd sure like to see how myself!)
  4. It would be better to get further explanation from the OP on how this would work with is own example (seeds), than to throw other examples around that may need a different kind of implementation.


    I am guessing they want to "equip" a bag/packet of seeds, return to the map, then walk around pressing S, and every time S is pressed, a seed will be planted (and maybe the number of seeds left is reduced).


    You would need to have your item call a common event that would turn on a switch. Then you'd have a parallel process on the map (or a common event) conditioned by that switch, that would then monitor for that key being pressed. Every time it is, a seed would be planted. If you want the player to be able to plant an unlimited number of seeds, your common event attached to the item would actually toggle the switch (if it's on, turn it off, otherwise turn it on). If you want them to use seeds every time they press the button, and have it stop automatically once they run out, you'd have your event monitoring for the keypress reduce the number of seeds, then check if there are 0 in inventory. If there are 0, it would turn the switch back off again.


    In either case, you would needs events all over the map (or wherever they can be planted) that would also have to be activated to show the correct graphic, or a spawning script that would add the event when needed and make sure it stays there when you leave the map and return.
  5. Shaz said:
    It would be better to get further explanation from the OP on how this would work with is own example (seeds), than to throw other examples around that may need a different kind of implementation.

    I am guessing they want to "equip" a bag/packet of seeds, return to the map, then walk around pressing S, and every time S is pressed, a seed will be planted (and maybe the number of seeds left is reduced).

    You would need to have your item call a common event that would turn on a switch. Then you'd have a parallel process on the map (or a common event) conditioned by that switch, that would then monitor for that key being pressed. Every time it is, a seed would be planted. If you want the player to be able to plant an unlimited number of seeds, your common event attached to the item would actually toggle the switch (if it's on, turn it off, otherwise turn it on). If you want them to use seeds every time they press the button, and have it stop automatically once they run out, you'd have your event monitoring for the keypress reduce the number of seeds, then check if there are 0 in inventory. If there are 0, it would turn the switch back off again.

    In either case, you would needs events all over the map (or wherever they can be planted) that would also have to be activated to show the correct graphic, or a spawning script that would add the event when needed and make sure it stays there when you leave the map and return.
    Ah! I see.  I've been having a similar problem myself too recently. I'm glad I found this thread (rather than spam the forums and start my own), I think I'll follow this one.