class Rosegold::Inventory

Overview

Utility methods for interacting with the open window.

Defined in:

rosegold/control/inventory.cr

Constructors

Instance Method Summary

Macro Summary

Constructor Detail

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

[View source]

Instance Method Detail

def count(spec, slots = slots) #

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


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

[View source]
def 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. 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


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

[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.item_id == "diamond_pickaxe" && slot.efficiency >= 4 } # => false


[View source]
def pick!(spec) #

[View source]
def throw_all_of(item_id) #

[View source]
def 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. 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


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

[View source]

Macro Detail

macro method_missing(call) #

[View source]