Open don-tnowe opened 10 months ago
⚡ Custom actions with items are now doable
There are now signals that GrabbedItemStackView
has that allow handling input onto inventories and items. Allows interception of the input, like when a ctrl-left-click would normally use the left-click action, but you want to do something else instead.
Although a system that lets the user give a script to each item would still be more discoverable.
Submitted by Discord user.
There's no custom actions on items! And there should be. Because so many games have logic tied to items. Some can even be possible to be activated from the inventory!
For that,
ItemType
should store a script that can override methods:input_inside_inventory(item : ItemStack, event : InputEvent, inventory_view : InventoryView, item_stack_view : ItemStackView) -> bool
, which is called when an input occurs on anItemStackView
holding an item of the type;input_into_world(item : ItemStack, event : InputEvent, drop_at_node : Node) -> bool
, which is called before an input that would drop the item into the world.drop_at_node
is the node set in the Grabbed Stack node, normally the player character;input_onto_inventory(item : ItemStack, event : InputEvent, inventory_view : InventoryView?, inventory_cell_under : Vector2) -> bool
, which is called when an input occurs while an item of the type is grabbed.InventoryView
can benull
.All must return
true
if the input has been handled - which can, for example, prevent item grabbing and dropping.