Skip to content

ActionBarSlotData ​

Inherits: RefCounted

Data structure for storing action bar slot content Can reference either abilities or items REFACTORED: Now stores direct item instance references instead of inventory indices

Variables ​

ContentTypecontent_typeContentType.EMPTY
AbilityInstanceability_instancenull
ItemInstanceitem_instancenull
intquantity1

Methods ​

ActionBarSlotDatafor_ability( ability: AbilityInstance ) static
ActionBarSlotDatafor_item( item: ItemInstance, quantity: int = 1 ) static
Variantget_content( player: Player )
boolis_empty()
voidclear()
Dictionaryto_dict()
ActionBarSlotDatafrom_dict( data: Dictionary, player: Player = null ) static
boolrestore_ability_reference( player: Player, ability_definition_id: int )
boolrestore_item_reference( player: Player, item_instance_id: String )
boolis_valid_for_player( player: Player )
intget_current_stack_size()
boolhas_sufficient_quantity()

Enumerations ​

enum ContentType ​

The options of content type: empty, ability, item.

  • EMPTY = 0
  • ABILITY = 1
  • ITEM = 2

Variable descriptions ​

ContentType content_type = ContentType.EMPTY ​

What the slot holds: nothing, an ability or an item.

AbilityInstance ability_instance = null ​

For abilities: direct reference to the ability instance

ItemInstance item_instance = null ​

For items: direct reference to the item instance

int quantity = 1 ​

For items that consume multiple per use

Method descriptions ​

ActionBarSlotData for_ability( ability: AbilityInstance ) ​

Create slot data for an ability

ActionBarSlotData for_item( item: ItemInstance, quantity: int = 1 ) ​

Create slot data for an item - now takes direct item instance

Variant get_content( player: Player ) ​

Get the actual content (ability or item) from this slot data

bool is_empty() ​

Check if this slot is empty

void clear() ​

Clear this slot

Dictionary to_dict() ​

Convert to dictionary for save/load

ActionBarSlotData from_dict( data: Dictionary, player: Player = null ) ​

Create from dictionary for save/load NOTE: This will need to be paired with a restoration system that rebuilds ability and item instance references from IDs after player data is loaded

bool restore_ability_reference( player: Player, ability_definition_id: int ) ​

Restore ability instance reference from player (call after loading)

bool restore_item_reference( player: Player, item_instance_id: String ) ​

Restore item instance reference from inventory (call after loading)

bool is_valid_for_player( player: Player ) ​

Check if this slot data is valid for the given player

int get_current_stack_size() ​

Get the current stack size for item in this slot (for display)

bool has_sufficient_quantity() ​

Check if the referenced item has enough quantity/charges for usage