class
Rosegold::Inventory
- Rosegold::Inventory
- Reference
- Object
Overview
Utility methods for interacting with the open window.
Defined in:
rosegold/control/inventory.crConstructors
Macro Summary
Instance Method Summary
-
#boots(*args, **options)
Equipment slot accessors
-
#boots(*args, **options, &)
Equipment slot accessors
-
#chestplate(*args, **options)
Equipment slot accessors
-
#chestplate(*args, **options, &)
Equipment slot accessors
-
#count(spec, slots = player_inventory_slots)
Returns the number of matching items in the player inventory (inventory + hotbar), or in the given slots range.
- #count(&spec : Slot -> _)
-
#deposit_at_least(count, spec, source : Array(WindowSlot) = inventory + hotbar, target : Array(WindowSlot) = content)
Tries to transfer at least
#count
matching items from the container to the player inventory, using shift-clicking. - #deposit_at_least(count, &spec : Slot -> _)
-
#helmet(*args, **options)
Equipment slot accessors
-
#helmet(*args, **options, &)
Equipment slot accessors
-
#leggings(*args, **options)
Equipment slot accessors
-
#leggings(*args, **options, &)
Equipment slot accessors
-
#off_hand(*args, **options)
Equipment slot accessors
-
#off_hand(*args, **options, &)
Equipment slot accessors
-
#pick(spec)
Picks a matching slot, if it exists in the inventory.
- #pick!(spec)
-
#replenish(count, item_id)
Ensures the player has at least
#count
items of the specified type in their inventory. - #throw_all_of(name)
-
#withdraw_at_least(count, spec, source : Array(WindowSlot) = content, target : Array(WindowSlot) | Nil = nil)
Tries to transfer at least
#count
matching items from the player inventory to the container, using shift-clicking. - #withdraw_at_least(count, &spec : Slot -> _)
Constructor Detail
Macro Detail
Instance Method Detail
Returns the number of matching items in the player inventory (inventory + hotbar), or in the given slots range.
Example: inventory.count "diamond_pickaxe" # => 2 inventory.count &.empty? # => 2 inventory.count { |slot| slot.name == "diamond_pickaxe" && slot.efficiency >= 4 } # => 1 inventory.count "stone", slots # => 5 (count in entire window including container)
Tries to transfer at least #count
matching items from the container to the player inventory, using shift-clicking.
Returns the number of actually transferred items.
Example: inventory.deposit_at_least 5, "diamond_pickaxe" # => 3 inventory.deposit_at_least 5, &.empty?, hotbar # => 1 inventory.deposit_at_least 5, { |slot| slot.name == "diamond_pickaxe" && slot.efficiency >= 4 } # => 2
Picks a matching slot, if it exists in the inventory. Returns true if the item was picked, false otherwise.
Example: inventory.pick "diamond_pickaxe" # => true inventory.pick &.empty? # => true inventory.pick { |slot| slot.name == "diamond_pickaxe" && slot.efficiency >= 4 } # => false
Ensures the player has at least #count
items of the specified type in their inventory.
If there are already enough items, returns the current count.
If not enough items are present, attempts to withdraw more from a container.
Returns the total count after replenishment attempt.
Example: inventory.replenish 10, "stone" # => 10 (if successful) inventory.replenish 5, "diamond" # => 3 (if only 3 available)
Tries to transfer at least #count
matching items from the player inventory to the container, using shift-clicking.
Returns the number of actually transferred items.
Example: inventory.withdraw_at_least 5, "diamond_pickaxe" # => 3 inventory.withdraw_at_least 5, &.empty?, hotbar # => 1 inventory.withdraw_at_least 5, { |slot| slot.name == "diamond_pickaxe" && slot.efficiency >= 4 } # => 2