Game Object Type

GameObject

Represents an interactive game object in Old School RuneScape, such as doors, trees, rocks, banks, altars, etc.

Object Types

Game objects can be one of several types:

  • interactive - Standard interactive objects (trees, rocks, doors, etc.)
  • boundary - Boundary objects (doors, gates)
  • floor - Floor decorations
  • wall - Wall decorations
  • unknown - Unknown type

Methods

is_valid()

Check if underlying pointer is non-null.

Returns: boolean - true if valid, false otherwise


kind()

Get object kind.

Returns: string - One of: "interactive", "boundary", "floor", "wall", or "unknown"

Example:

local tree = game_objects:find_first({name = "Tree"})
if tree then
    print("Object type:", tree:kind()) -- "interactive"
end

id()

Get object ID.

Returns: number - The unique object ID


name()

Get object name.

Returns: string - The object's display name

Example:

local altar = game_objects:find_first({name = "Altar"})
if altar then
    print("Found:", altar:name())
end

x()

Get world X coordinate.

Returns: number - The X coordinate in the game world


y()

Get world Y coordinate.

Returns: number - The Y coordinate in the game world


floor()

Get floor/plane level.

Returns: number - The floor level (0-3)


tile()

Get position as a Tile object with x, y, and floor.

Returns: Tile or nil - The tile object representing the object's position

Example:

local bank = game_objects:find_first({name = "Bank booth"})
if bank then
    local tile = bank:tile()
    print(string.format("Bank at (%d, %d, %d)", tile.x, tile.y, tile.floor))
end

distance()

Get distance to local player in tiles. This is the preferred method over distance_to_player().

Returns: number - The distance in tiles

Example:

local tree = game_objects:find_first({name = "Tree"})
if tree then
    local dist = tree:distance()
    if dist < 2 then
        tree:interact({action = "Chop down"})
    else
        print("Tree too far away:", dist, "tiles")
    end
end

distance_to_player() (deprecated)

Deprecated: Use distance() instead.

Get distance to local player in tiles.

Returns: number - The distance in tiles


local_x()

Get local X coordinate (relative to the region).

Returns: number - The local X coordinate


local_y()

Get local Y coordinate (relative to the region).

Returns: number - The local Y coordinate


click()

Human-like left click the object.

Returns: boolean - true if clicked successfully, false otherwise


shift_click()

Shift+click the object (holds shift, clicks, releases shift). Useful for shift-click drop or other shift-modified actions.

Returns: boolean - true if clicked successfully, false otherwise

Example:

local obj = game_objects:find_first({name = "Rock"})
if obj then
    obj:shift_click()
end

interact(filter_input)

Right-click and select menu option by filters.

Parameters:

NameTypeDescription
filter_inputtable or nilOptional menu item filters

Returns: boolean - true if interaction succeeded, false otherwise

Example:

-- Chop a tree
local tree = game_objects:find_first({name = "Tree"})
if tree then
    tree:interact({action = "Chop down"})
end

-- Open a door
local door = game_objects:find_first({name = "Door"})
if door then
    door:interact({action = "Open"})
end

-- Mine a rock
local rock = game_objects:find_first({name = "Rocks"})
if rock then
    rock:interact({action = "Mine"})
end

-- Use bank booth
local booth = game_objects:find_first({name = "Bank booth"})
if booth then
    booth:interact({action = "Bank"})
end

is_visible()

Check if object is visible in the viewport.

Returns: boolean - true if visible on screen, false otherwise

Example:

local objects = game_objects:find({name = "Tree", within_distance_of_local = 15})
for _, obj in ipairs(objects) do
    if obj:is_visible() then
        print("Can see tree at", obj:tile().x, obj:tile().y)
    end
end

reachable()

Check if game object is reachable from the local player's position using pathfinding.

Returns: boolean - true if the object can be reached from the player's current position, false otherwise

Example:

local altar = game_objects:find_first({name = "Altar"})
if altar and altar:reachable() then
    altar:interact({action = "Pray-at"})
else
    print("Altar is blocked or unreachable")
end

move_mouse_to()

Move the mouse to this game object with human-like movement. Uses the object's clickable point.

Returns: boolean - true on success, false if the position is invalid or the move fails

Example:

local tree = game_objects:find_first({name = "Tree"})
if tree and tree:move_mouse_to() then
    mouse:click()
end

track()

Start tracking this game object: the mouse follows the object until the entity is invalid, another mouse action is performed, or you call mouse:stop_track().

Returns: void

Example:

local tree = game_objects:find_first({name = "Tree"})
if tree then
    tree:track()
    sleep(1500)
    mouse:stop_track()
end

set_bounding_model(x1, x2, y1, y2, z1, z2)

Set custom bounding model dimensions for this game object. Falls back to the default captured model if not set.

Parameters:

NameTypeDescription
x1numberMinimum X coordinate
x2numberMaximum X coordinate
y1numberMinimum Y coordinate
y2numberMaximum Y coordinate
z1numberMinimum Z coordinate
z2numberMaximum Z coordinate

Returns: void

Example:

local bank = game_objects:find_first({name = "Bank booth"})
if bank then
    -- Set custom bounding model dimensions
    bank:set_bounding_model(-50, 50, -100, 0, -50, 50)
end

remove_bounding_model()

Remove the custom bounding model, falling back to the default captured model.

Returns: void

Example:

local bank = game_objects:find_first({name = "Bank booth"})
if bank then
    -- Remove custom bounding model to use default
    bank:remove_bounding_model()
end

Common Examples

Woodcutting

local tree = game_objects:find_first({name = "Tree", within_distance_of_local = 10})
if tree and tree:is_visible() then
    tree:interact({action = "Chop down"})
    wait(1000)
end

Mining

local rock = game_objects:find_first({
    name = "Rocks",
    within_distance_of_local = 5
})
if rock then
    rock:interact({action = "Mine"})
end

Banking

local bank = game_objects:find_first({
    name_contains = "Bank",
    within_distance_of_local = 10
})
if bank then
    bank:interact({action = "Bank"})
end