class Rosegold::Inventory
- Rosegold::Inventory
- Reference
- Object
Overview
Utility methods for interacting with the open window.
Defined in:
rosegold/control/inventory.crConstructors
Instance Method Summary
-
#count(spec, slots = slots)
Returns the number of matching items in the entire window, or in the given slots range.
- #count(&spec : WindowSlot -> _)
-
#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 : WindowSlot -> _)
-
#pick(spec)
Picks a matching slot, if it exists in the inventory.
- #pick!(spec)
- #throw_all_of(item_id)
-
#withdraw_at_least(count, spec, source : Array(WindowSlot) = content, target : Array(WindowSlot) = inventory + hotbar)
Tries to transfer at least
#count
matching items from the player inventory to the container, using shift-clicking. - #withdraw_at_least(count, &spec : WindowSlot -> _)
Macro Summary
Constructor Detail
Instance Method Detail
Returns the number of matching items in the entire window, or in the given slots range.
Example: inventory.count "diamond_pickaxe" # => 2 inventory.count &.empty? # => 2 inventory.count { |slot| slot.item_id == "diamond_pickaxe" && slot.efficiency >= 4 } # => 1 inventory.count &.empty?, hotbar # => 1
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.item_id == "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.item_id == "diamond_pickaxe" && slot.efficiency >= 4 } # => false
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.item_id == "diamond_pickaxe" && slot.efficiency >= 4 } # => 2