In a RPG game, the player picks 12 items out of a 100 possible objects placed in a structured manner.
Those objects are moved into their inventory when the player clicks on any of these items.
When the player clicks on the items in their inventory, how do I make them go back to their original position?
In the code, “Item” is the item to be moved to and from inventory.
“slot” is the slot in inventory which would be filled or vacated.
Conditions:
When the mouse is released, the “In_slot” variable checks if the item is in the slot or not.
If it’s not in slot, it puts it in the slot (of inventory). This part is working well. only if I comment out the condition 3 below
I seek help in this part which isn’t working:
3. When the “In_slot” is “Yes” (Item is in the inventory slot), then it should read “Original_X” and “Original_Y” and move the item back to this position.
The issue is with setting In_slot to “Yes”. When In_slot = 'No", the variable is set to “Yes”. However, a few events further down, it’s checked whether it’s “Yes”, which it will be, and then set to “No”.
What you’re after is an if-then-else statement, which GDevelop doesn’t have. The best solution is to use a second variable (boolean) that keeps track of whether In_slot has changed value, and to ignore the item in the subsequent events.