Server Static Object API

Methods available on the static object passed to server-side interactable and tree hooks.

Interactable hooks (server-on-interact, server-update, server-on-create, server-on-inventory-close) receive a static object — the placed interactable or tree the hook belongs to. This page lists its methods.

Static objects are simpler than entities: they don’t move, so there is no velocity, health, or pathfinding. For the interacting player argument that some hooks also pass, see lua-server-entity.md.


Persistent Script State: lua_data

Like entities, every static object carries a lua_data table that persists across hook calls for the lifetime of the object. Use it for per-object state (open/closed flags, timers, owner IDs):

return function(static_object, player_entity_id, player)
    local data = static_object.lua_data
    data.open = not data.open
    if data.open then
        static_object:animate("open", false)
        static_object:toggle_collidable()
    else
        static_object:animate("open", true)
        static_object:toggle_collidable()
    end
end

lua_data returns the live table — field changes stick immediately; assigning a new table replaces it entirely.


Methods

Positions are world coordinates in block units.

MethodReturnsDescription
get_x()numberThe object’s X position.
get_location()locationPosition snapshot with read-only .x, .y, .world fields (see lua-server-globals.md § Locations). There is no get_y(); use get_location().y.
is_collidable()booleanWhether the object currently blocks movement.
toggle_collidable()Flip the collidable flag (e.g. opening a door).
animate(name, reverse)Play the named animation on every client that can see the object. reverse (boolean) plays it backwards.
set_state(state)Set the object’s state string (drives state-dependent visuals).
set_display_name(name)Change the object’s displayed name.
set_inventory_size(rows, columns)Resize the object’s inventory grid. Interactables only — does nothing on trees. Each dimension is clamped to a maximum of 256.

See Also