Skip to content

Commit

Permalink
[Docs] Added missing method descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-kish committed Jan 27, 2024
1 parent 250766c commit 23c95b5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/item_ref_slot.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Holds a reference to an inventory item.

* `equip(item: InventoryItem) -> bool` - Equips the given inventory item in the slot. If the slot already holds an item, `clear()` will be called first. Returns `false` if the `clear` call fails, the slot can't hold the given item, or already holds the given item. Returns `true` otherwise.
* `clear() -> bool` - Clears the item slot.
* `get_item() -> InventoryItem` - Returns the equipped item.
* `can_hold_item(new_item: InventoryItem) -> bool` - Checks if the slot can hold the given item, i.e. `inventory` contains the given item and the item is not `null`. This method can be overridden to implement item slots that can only hold specific items.
* `reset()` - Clears the item slot.
* `serialize() -> Dictionary` - Serializes the item slot into a dictionary.
Expand Down
1 change: 1 addition & 0 deletions docs/item_slot.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Holds an inventory item.

* `equip(item: InventoryItem) -> bool` - Equips the given inventory item in the slot. If the slot already contains an item, `clear()` will be called first. Returns `false` if the `clear` call fails, the slot can't hold the given item, or already holds the given item. Returns `true` otherwise.
* `clear() -> bool` - Clears the item slot. If `remember_source_inventory` is `true`, the method will try to return the item to its original inventory. Returns `false` if the item can't be returned, or if the slot is already empty.
* `get_item() -> InventoryItem` - Returns the equipped item.
> Note: this method will not free the item if `remember_source_inventory` is `false`.
* `can_hold_item(new_item: InventoryItem) -> bool` - Checks if the slot can hold the given item, i.e. the item has the same protoset as the slot and is not `null`. This method can be overridden to implement item slots that can only hold specific items.
* `reset()` - Clears the item slot and queues the contained item (if any) for deletion.
Expand Down
1 change: 1 addition & 0 deletions docs/item_slot_base.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Base class for [`ItemSlot`](./item_slot.md) and [`ItemRefSlot`](./item_ref_slot.

* `equip(item: InventoryItem) -> bool` - Equips the given inventory item in the slot. See the documentation for [`ItemSlot`](./item_slot.md) and [`ItemRefSlot`](./item_ref_slot.md) for more details.
* `clear() -> bool` - Clears the item slot. See the documentation for [`ItemSlot`](./item_slot.md) and [`ItemRefSlot`](./item_ref_slot.md) for more details.
* `get_item() -> InventoryItem` - Returns the equipped item. See the documentation for [`ItemSlot`](./item_slot.md) and [`ItemRefSlot`](./item_ref_slot.md) for more details.
* `can_hold_item(new_item: InventoryItem) -> bool` - Checks if the slot can hold the given item. See the documentation for [`ItemSlot`](./item_slot.md) and [`ItemRefSlot`](./item_ref_slot.md) for more details.
* `reset()` - Clears the item slot. See the documentation for [`ItemSlot`](./item_slot.md) and [`ItemRefSlot`](./item_ref_slot.md) for more details.
* `serialize() -> Dictionary` - Serializes the item slot into a dictionary. See the documentation for [`ItemSlot`](./item_slot.md) and [`ItemRefSlot`](./item_ref_slot.md) for more details.
Expand Down

2 comments on commit 23c95b5

@GreatRedBird
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good afternoon, thank you for your great work! I have one question.
Previously there was only an ItemSlot, and it stored a link to the item. The item itself remained in the inventory.
Do I understand correctly that now ItemRefSlot does this, and the new ItemSlot will pick up the item from the inventory?

@peter-kish
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's the idea.

Please sign in to comment.