-
-
Notifications
You must be signed in to change notification settings - Fork 20
InventoryItem
Each inventory item you create will have its own script file (based on InventoryItemTemplate.gd). This is created with the name you give the item in the Create inventory item popup prefixed by Inventory: E.g. InventoryMasterKey.gd, InventoryScythe.gd, InventoryCardDeck.gd.
- on_interact() void
Called when "popochiu-interact" (set to Left Mouse Button in the project's Input Map) is used on the item. E.g. You can use it to make the item as the active item.
By default this calls to
.on_interact()
in PopochiuInventoryItem, which makes this object the active one.
func on_interact() -> void:
.on_interact()
A.play_no_block('sfx_key')
- on_look() void
Called when "popochiu-look" (set to Right Mouse Button in the project's Input Map) is used on the item. E.g. You can use it to make the PC say something about the item.
By default this calls to
.on_look()
in PopochiuInventoryItem, which shows a game message.
func on_look() -> void:
E.run([
'Player: It is a master key.',
'Player: I can go anywhere with this!'
])
-
on_item_used( PopochiuInventoryItem
item
) void
Called when an inventory item is used on this item. Use the script_name
property of item
to see which one was used.
By default this calls to
.on_item_used(item)
in PopochiuInventoryItem, which shows a game message.
func on_item_used(item: PopochiuInventoryItem) -> void:
if item.script_name == 'Bullet':
yield(E.run([
'Player: Great.',
I.remove_item('Gun'),
I.remove_item('Bullet'),
I.add_item_as_active('LoadedGun'),
'Player: Say hello to my little friend!'
]), 'completed')
- on_added_to_inventory() void
Called once the item is added to the Inventory.
func on_added_to_inventory() -> void:
if Globals.game_state.get(GameState.BATTERY_FULL):
description = 'Battery charged'
else:
description = 'Battery empty'
- on_discard() void
Called when the item is discarded from the inventory.
func on_discard() -> void:
E.run([
"Player: I'll leave this key here",
A.play('sfx_key'),
'Player: Might be useful later'
])