Godot 4.2
I have a pretty basic inventory system with slots that get instanced on ready. The inventory gets populated with these slots.
I also have created a small context popup menu in a separate scene.
This menu has 3 items: Use, Help, and Drop.
What I want to do is whenever the player right clicks in the inventory, the menu opens for that slot and they can choose whether they want to use the item, read more help about it, or drop it. I’ve tried instantiating and adding the menu as a child of the slot but that wasn’t working. What should I do?
This is my inventory interaction function.
func on_inventory_interact(inventory_data: InventoryData, index: int, button: int):
match [grabbed_slot_data, button]:
[null, MOUSE_BUTTON_LEFT]:
grabbed_slot_data = inventory_data.grab_slot_data(index)
[_, MOUSE_BUTTON_LEFT]:
grabbed_slot_data = inventory_data.drop_slot_data(grabbed_slot_data, index)
[null, MOUSE_BUTTON_RIGHT]:
#OPEN CONTEXT MENU HERE
inventory_data.use_slot_data(index)
[_, MOUSE_BUTTON_RIGHT]:
grabbed_slot_data = inventory_data.drop_single_slot_data(grabbed_slot_data, index)
I followed this video for the entire system: https://www.youtube.com/watch?v=V79YabQZC1s
Any suggestions or advice greatly appreciated! Thanks