API Types Overview

Lua API Types Reference

This directory contains documentation for all Lua types available in the pow-desktop API.

Entity Types

  • Item - Represents items in inventory, bank, or equipment
  • Player - Represents player characters in the game world
  • NPC - Represents non-player characters
  • GameObject - Represents interactive game objects
  • GroundItem - Represents items on the ground

UI Types

  • Component - Represents UI components/widgets
  • MenuItem - Represents a right-click menu option

Geometry Types

  • Point - Represents a 2D point with x, y coordinates
  • Tile - Represents a 3D game tile with x, y, floor
  • LocalTile - Represents a scene-local tile using raw local center coordinates
  • Area - Represents a rectangular area in the game world
  • Rectangle - Represents a screen rectangle

Game Data Types

Common Patterns

Checking Validity

Most entity types have an is_valid() method to check if the underlying data is still accessible:

local item = inventory:find_first({name = "Shark"})
if item and item:is_valid() then
    -- Safe to use item
end

Interaction

Entity types support two main interaction methods:

  • click() - Performs a left-click on the entity
  • interact(filters) - Right-clicks and selects a menu option
-- Left click
npc:click()

-- Right click with menu selection
npc:interact({action = "Talk-to"})

Position Data

Entities with positions typically provide:

  • x(), y(), floor() - World coordinates
  • tile() - Returns a Tile object
  • local_x(), local_y() - Local/region coordinates
local player = players:local_player()
local tile = player:tile()
print(string.format("Position: (%d, %d, %d)", tile.x, tile.y, tile.floor))

Animation State

Actors (Players, NPCs) provide animation state:

  • is_animating() - Currently performing an animation
  • is_moving() - Currently moving
  • is_busy() - Either animating or moving
  • is_idle() - Neither animating nor moving
local player = players:local_player()
while player:is_busy() do
    wait()
end
-- Player is now idle

Custom Bounding Models

Players, NPCs, and GameObjects support custom bounding model dimensions:

  • set_bounding_model(x1, x2, y1, y2, z1, z2) - Set custom bounding model dimensions
  • remove_bounding_model() - Remove custom bounding model, fall back to default
local npc = npcs:find_first({name = "Banker"})
if npc then
    -- Set custom bounding model dimensions
    npc:set_bounding_model(-50, 50, -100, 0, -50, 50)
    
    -- Later, remove it to use the default
    npc:remove_bounding_model()
end