Grid Item_Dropped signal only giving weakref for item? #124
-
Hi, I'm trying to use the item_dropped signal on the Grid inventory, however, the "item" field of the signal only gives a weak reference to the connect script, which doesn't allow me to get any information from the item itself. Am I doing something wrong? For instance, using print(item) on the inventory_item_activated(item:var) signal gives something like "@node@43:<Node#94774496325>" |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You should still be able to access the var item_node: InventoryItem = item.get_ref()
if item_node == null:
return
# do something with item_node I used weak references here, since in cases where the item is dropped into another inventory, there's the possibility of it being "consumed" if it gets merged with another item. In that case the weak reference will contain |
Beta Was this translation helpful? Give feedback.
You should still be able to access the
InventoryItem
viaWeakRef.get_ref
(bare in mind that it can returnnull
- see the docs for WeakRef) . Something like:I used weak references here, since in cases where the item is dropped into another inventory, there's the possibility of it being "consumed" if it gets merged with another item. In that case the weak reference will contain
null
.