-
-
Notifications
You must be signed in to change notification settings - Fork 19
PopochiuInventoryItem
Inherits TextureRect.
An object the player can grab and use in Props, Hotspots, characters and other inventory items. It is similar to PopochiuClickable but as a Control node.
-
description_toggled( String
description
). Emitted to show or hide the object´sdescription
when the cursor is over it or leaves it. The graphic interface connects to this signal in order to show or hide this text. -
selected( PopochiuInventoryItem
item
). Emitted when the object is clicked in the inventory. Inventory connects to this signal in order to change the pointer texture by the one of this object.
-
cursor. Cursor. Default
Cursor.NONE
. The cursor to show when the pointer is over this object. -
description String. Default
''
. The text shown to players when the cursor hovers the object. -
script_name String. Default
''
. The identifier of the object used in scripts. -
stack bool. Default
false
. Whether the object can be stacked.⚠️ Not used yet by any script⚠️ .
-
amount int. Default
1
. The number of this objects.⚠️ Not used yet by any script⚠️ . -
in_inventory bool. Default
false
. Whether the object is inside the inventory.
🍑 For a detailed and exemplified description of all the virtual methods of this class, go to the Your scripts > Inventory item page 🍑.
-
on_added_to_inventory() void
Use it to define custom behaviors once the item enters the inventory.
-
on_discard() void
Use it to define custom behaviors when the object is discarded from the inventory.
-
on_interact() void
Use it to define custom behaviors when players INTERACT (click) with the object.
⚠️ By default this function emits theselected
signal, so take this into account when adding your code. -
on_item_used( PopochiuInventoryItem
item
) voidUse it to define custom behaviors when another
item
is used on this one. By default this function shows a game message ( G.display() ) warning the player that there is nothing defined for that action. -
on_look() void
Use it to define custom behaviors when players LOOK AT/EXAMINE (right click) the object. By default this function shows a game message ( G.display() ) warning the player that there is nothing defined for that action.
-
add( bool
animate = true
) void🍑 Intended to be used inside an E.run() (a.k.a. queue of instructions) 🍑
Adds this item to the inventory. Pass
animate
asfalse
if you do not want the inventory to animate when the item is added.func on_interact() -> void: E.run([ C.walk_to_clicked(), "Player: I'm gonna take this with me", I.Key.add() ])
-
add_now( bool
animate = true
) voidAdds this item to the inventory immediately. Pass
animate
asfalse
if you do not want the inventory to animate when the item is added.func on_interact() -> void: I.ToyCay.add_now(false) E.run([ "Narrator: Goddiu slipped the toy car into his pocket without anyone noticing", ])
-
add_as_active( bool
animate = true
) void🍑 Intended to be used inside an E.run() (a.k.a. queue of instructions) 🍑
Adds this item to the inventory and makes it the current selected item (the cursor will look like the item's texture). Pass
animate
asfalse
if you do not want the inventory to animate when the item is added.func on_interact() -> void: E.run([ C.walk_to_clicked(), I.Knife.add_as_active(), "Player: Let's cut that cake" ])
-
add_as_active_now( bool
animate = true
) voidAdds this item to the inventory immediately and makes it the current selected item (the cursor will look like the item's texture). Pass
animate
asfalse
if you do not want the inventory to animate when the item is added.func grab_blue_vase() -> void: I.BlueVase.add_as_active_now(false) # Do not show the inventory
-
remove( bool
animate = true
) void🍑 Intended to be used inside an E.run() (a.k.a. queue of instructions) 🍑
Removes the item from the inventory (its instance will be kept in the
_item_instances
array). Passanimate
asfalse
if you do not want the inventory to animate when the item is removed.func on_interact() -> void: E.run([ C.walk_to_clicked(), "Player: A cut here, a cut there", "Player: And I don't need these scissors anymore", I.Scissors.remove(false), # Do not show the inventory ])
-
remove_now( bool
animate = true
) voidRemoves the item from the inventory immediately (its instance will be kept in the
_item_instances
array). Passanimate
asfalse
if you do not want the inventory to animate when the item is removed.func on_room_exited() -> void: I.ToiletPaper.remove(false)
-
set_active( bool
ignore_block = false
) voidMakes the cursor use the texture of this item. If
ignore_block
istrue
the cursor will change even if the cursor is blocked.C.Guard.say('Give me your ID card') I.IDCard.set_active()
-
set_in_inventory( bool
value
) voidCalls
on_added_to_inventory()
if the object is inside the inventory. -
get_description() String
Returns the
description
of the object passing it throughE.get_text()
, which can be used to show it in different languages when using localization.
-
_toggle_description( bool
display
) voidShows and hides (depending on the value of
display
) thedescription
when the cursor hovers or leaves the object. -
_on_action_pressed( InputEvent
event
) voidDetermines the action made by the player when interacting with the object. If it was a click, then
on_interact()
is called, but if there is an active inventory item, thenon_item_used()
is called. If it was a right click, thenon_look()
is called.