#Problem: Items disapearing from the inventory after dragging it a second time
1 messages · Page 1 of 1 (latest)
Hello. In the first image, in the _get_drag_data function, you should be returning the data that will be dropped on another slot. You are returning slot_id here.
Then in the _drop_data function the paseed argument data will be the slot_id that you returned ealier from the _get_drag_data() function. So when you are emiting the singal item_dropped(), it is essentially becoming item_dropped.emit(slot_id, slot_id) because of the data being slot_id here. That is why the data is being lost I think.
Oh. I just realized. You are probably using both slot_ids to directly swap/transfer their data. My bad. Then that might not be the problem.
Can you show which function is listening to the item_dropped() signal?
Ah.. it's the last image.
I think the issue might be, in the swap_slots() function, the item_in_slot: ItemData variable is not being stored anywhere and getting lost. Only the textures of the slots is being set. So when you swap the second time, in the function item_dropped_on_slot()
the variable from_slot_item is becoming null. That's why it is disappearing.
i changed the code to this (this is in the swap_slots), but now, after a few drag and drops (about 8), the item dupes itself, so when i drag it, instead of making the "from_slot" null it generates up to 3 copies