So, one of the 'features' for my game I am working on is that the player 'holds' items (they equip one item at a time from their inventory and a variable tells other objects what that item is). This works fine, but my issue comes in one of the ways to navigate the player's inventory. I am pretty new to RPGmaker as a whole, so I'm sure it's possible the answer is obvious and I've just missed it, but I need help with the following:
If the player presses Q or E (I have Yanfly's button common events plugin, along with the rest of Yanfly's set if that is relevant), they will go back and forward an item in their inventory, respectively. This is based on the ID of the items. So, if the player has items 1, 2, 4, 10, and 20, and they are holding item 4, then hitting Q will make them hold item 2, and hitting E will make them hold item 10. This system would also include a failsafe for if they already have the lowest or highest ID- if they hold item 20, E would send them to 1, and holding 1 and hitting Q would send them to 20. Coding-wise, once the nearest numbers are identified, they go to a previous item and next item variable respectively, and changing items will lead to another check to see which numbers are now closest, changing the variables accordingly. The part I am struggling with is finding a way to cross-compare the IDs and identify the two directly higher and lower than the current ID. If it is relavant, there would not need to be checks for weapons or items, only armors.
Any help would be appreciated!
If the player presses Q or E (I have Yanfly's button common events plugin, along with the rest of Yanfly's set if that is relevant), they will go back and forward an item in their inventory, respectively. This is based on the ID of the items. So, if the player has items 1, 2, 4, 10, and 20, and they are holding item 4, then hitting Q will make them hold item 2, and hitting E will make them hold item 10. This system would also include a failsafe for if they already have the lowest or highest ID- if they hold item 20, E would send them to 1, and holding 1 and hitting Q would send them to 20. Coding-wise, once the nearest numbers are identified, they go to a previous item and next item variable respectively, and changing items will lead to another check to see which numbers are now closest, changing the variables accordingly. The part I am struggling with is finding a way to cross-compare the IDs and identify the two directly higher and lower than the current ID. If it is relavant, there would not need to be checks for weapons or items, only armors.
Any help would be appreciated!