Ground Items API

Find and interact with items lying on the ground.

Functions

find_first

ground_items:find_first(filters: table?) -> GroundItem?

Find first ground item matching filters.

Parameters:

ParameterTypeRequiredDescription
filterstableNoFilter options

Returns:

  • GroundItem? - First matching item

Filters:

FilterTypeDescription
namestringExact name match
name_containsstringName contains text
name_matches_regexstringName matches regex
name_anytableMatch if name equals any in array of strings
name_contains_anytableMatch if name contains any substring in array
idnumberExact item ID
idstableArray of IDs
within_distance_of_localnumberDistance from player
within_distance_oftableDistance from coordinates
attableExact tile location {x, y, z} or [x, y, z]
at_anytableArray of tiles to check {{x, y, z}, ...}
actions_containsstringHas an action containing this text (case-insensitive)
actions_equalsstringHas an action exactly matching this text (case-insensitive)
min_store_pricenumberMinimum store price (vendor value)
max_store_pricenumberMaximum store price (vendor value)
min_store_price_totalnumberMinimum total store price (store_price × stack_size)
max_store_price_totalnumberMaximum total store price (store_price × stack_size)
min_high_pricenumberMinimum high price from Grand Exchange
max_high_pricenumberMaximum high price from Grand Exchange
has_high_pricebooleanFilter items that have high price data available
min_high_price_totalnumberMinimum total high price (high_price × stack_size)
max_high_price_totalnumberMaximum total high price (high_price × stack_size)
min_low_pricenumberMinimum low price from Grand Exchange
max_low_pricenumberMaximum low price from Grand Exchange
has_low_pricebooleanFilter items that have low price data available
min_low_price_totalnumberMinimum total low price (low_price × stack_size)
max_low_price_totalnumberMaximum total low price (low_price × stack_size)
min_average_pricenumberMinimum average price (average of high and low)
max_average_pricenumberMaximum average price (average of high and low)
has_average_pricebooleanFilter items that have average price data available
min_average_price_totalnumberMinimum total average price (average_price × stack_size)
max_average_price_totalnumberMaximum total average price (average_price × stack_size)

find_all

ground_items:find_all(filters: table?) -> table

Find all ground items matching filters.

Parameters:

ParameterTypeRequiredDescription
filterstableNoFilter options

Returns:

  • table - Array of GroundItem objects

Example:

local bones = ground_items:find_all({name = "Bones"})
local nearby = ground_items:find_all({within_distance_of_local = 10})

-- Find item at specific tile
local item = ground_items:find_first({
    name = "Coins",
    at = {3200, 3210, 0}  -- or at = {x = 3200, y = 3210, floor = 0}
})

-- Find items with any of multiple names
local valuable = ground_items:find_first({
    name_any = {"Coins", "Dragon bones", "Rune platebody"}
})

-- Find items containing any substring
local loot = ground_items:find_all({
    name_contains_any = {"rune", "dragon", "gold"}
})

-- Find valuable ground items by price
local valuable = ground_items:find_all({
    min_high_price_total = 10000,
    has_high_price = true,
    within_distance_of_local = 15.0
})

find_nearest

ground_items:find_nearest(filters: table?) -> GroundItem?

Find nearest ground item matching filters.

Parameters:

ParameterTypeRequiredDescription
filterstableNoFilter options

Returns:

  • GroundItem? - Nearest matching item

Common Patterns

Looting Items

local function loot_bones()
    local bones = ground_items:find_nearest({name = "Bones"})
    
    if bones then
        logger:info("Looting bones")
        bones:smart_interact({action = "Take"})
        return true
    end
    
    return false
end

Multi-Item Looting

local function loot_items(item_names, max_distance)
    local looted = 0
    
    for _, name in ipairs(item_names) do
        local items = ground_items:find_all({
            name = name,
            within_distance_of_local = max_distance
        })
        
        for _, item in ipairs(items) do
            if inventory:full() then
                logger:info("Inventory full")
                break
            end
            
            item:smart_interact({action = "Take"})
            looted = looted + 1
            sleep(600)
        end
    end
    
    return looted
end

local count = loot_items({"Bones", "Dragon bones"}, 10)
logger:info("Looted " .. count .. " items")

Related APIs

  • Inventory API - Inventory management