class Rosegold::Inventory

Overview

Utility methods for interacting with the open window.

Defined in:

rosegold/control/inventory.cr

Constructors

Macro Summary

Instance Method Summary

Constructor Detail

def self.new(client : Rosegold::Client) #

[View source]

Macro Detail

macro method_missing(call) #

[View source]

Instance Method Detail

def boots(*args, **options) #

Equipment slot accessors


[View source]
def boots(*args, **options, &) #

Equipment slot accessors


[View source]
def chestplate(*args, **options) #

Equipment slot accessors


[View source]
def chestplate(*args, **options, &) #

Equipment slot accessors


[View source]
def count(spec, slots = player_inventory_slots) #

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)


[View source]
def count(&spec : Slot -> _) #

[View source]
def deposit_at_least(count, spec) #

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.deposit_at_least 5, "diamond_pickaxe" # => 3 inventory.deposit_at_least 5, &.empty? # => 1 inventory.deposit_at_least 5, { |slot| slot.name == "diamond_pickaxe" && slot.efficiency >= 4 } # => 2


[View source]
def deposit_at_least(count, &spec : Slot -> _) #

[View source]
def helmet(*args, **options) #

Equipment slot accessors


[View source]
def helmet(*args, **options, &) #

Equipment slot accessors


[View source]
def leggings(*args, **options) #

Equipment slot accessors


[View source]
def leggings(*args, **options, &) #

Equipment slot accessors


[View source]
def off_hand(*args, **options) #

Equipment slot accessors


[View source]
def off_hand(*args, **options, &) #

Equipment slot accessors


[View source]
def pick(spec) #

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


[View source]
def pick!(spec) #

[View source]
def refill_hand #

Refills the main hand to its maximum stack size by manually combining stacks. Only works when no container is open (player inventory only). Returns the final quantity in the main hand after refilling.

Example: inventory.refill_hand # => 64 (if main hand was stone and got filled to max stack) inventory.refill_hand # => 32 (if only 32 items were available) inventory.refill_hand # => 0 (if main hand is empty)


[View source]
def replenish(count, item_id) #

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)


[View source]
def throw_all_of(name) #

[View source]
def withdraw_at_least(count, spec) #

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.withdraw_at_least 5, "diamond_pickaxe" # => 3 inventory.withdraw_at_least 5, &.empty? # => 1 inventory.withdraw_at_least 5, { |slot| slot.name == "diamond_pickaxe" && slot.efficiency >= 4 } # => 2


[View source]
def withdraw_at_least(count, &spec : Slot -> _) #

[View source]