approach
does something
returns bool
approach(target: object) -> boolapproach(target: wall) -> boolapproach(target: npc) -> boolapproach(target: drop) -> bool
Walks toward this, choosing a tile beside it rather than its own tile - you cannot stand on a rock, and routing to one answers unreachable. Walks only when distance is what is wrong: something already drawn, or hidden behind a wall, or behind the camera is not made nearer by walking, and the trace says which. One click per call, so a destination further than about sixteen tiles is walked in legs and a script loops. False only when no frame has been drawn yet, or when nothing beside the target can be reached at all.
| Parameter | Type | What it does |
| targetrequired |
object |
the object to walk toward |
Example
let rock = nearestObject(name: "Iron rock", within: 20)
if rock != none { approach(rock) }
let door = nearestWall(name: "Door", within: 20)
if door != none { approach(door) }
let banker = nearestNpc(id: 95, within: 30)
if banker != none { approach(banker) }
let loot = nearestDrop(name: "Coins", within: 20)
if loot != none { approach(loot) }
interact
does something
returns bool
interact(target: object, command: string) -> boolinteract(target: wall, command: string) -> boolinteract(target: npc, command: string) -> boolinteract(target: item, command: string) -> boolinteract(target: drop, command: string) -> bool
Right-clicks an object and picks an option, checking at every step that the pointer is really on it. False when it could not be done, with the reason in the trace.
Right-clicks a wall or a door and picks an option. False when it could not be done, with the reason in the trace.
Right-clicks an npc and picks an option. The npc must have been found in this pass: this is the one target the API aims at without re-resolving first, so a handle older than one server tick is refused rather than clicked at where it used to be.
Right-clicks an inventory slot and picks an option, opening the tab first. The cell is re-measured and re-read before the click, so an inventory that shifted under the pointer refuses rather than acting on whatever moved into the slot.
Right-clicks something lying on the floor and picks an option. Only the menu row naming this item is clicked, because everything on a tile is drawn in the same box and taking the bones instead of the rune is not a near miss.
| Parameter | Type | What it does |
| targetrequired |
object |
the object to click |
| commandrequired |
string |
the menu option, as the game spells it |
Example
let rock = nearestObject(name: "Iron rock", within: 12)
if rock != none { interact(rock, "Mine") }
let door = nearestWall(name: "Door", within: 6)
if door != none { interact(door, "Open") }
let goblin = nearestNpc(name: "Goblin", within: 10, notInCombat: true)
if goblin != none { interact(goblin, "Attack") }
let ore = invItem(151)
if ore != none { interact(ore, "Drop") }
let loot = nearestDrop(name: "Coins", within: 8)
if loot != none { interact(loot, "Take") }
reach
does something
returns string
reach(target: object) -> stringreach(target: wall) -> stringreach(target: npc) -> stringreach(target: drop) -> string
Walks toward this and turns the view until the client is drawing it, and returns which of DRAWN, RANGE, BEARING, HIDDEN or UNKNOWN it ended on. DRAWN is the one worth interacting after. At most one walk and one turn per call - never a walk-turn-walk cycle - so a script that is still out of range calls again. A failed reach can cost seven seconds, so do not put it in a tight loop over a dozen targets.
| Parameter | Type | What it does |
| targetrequired |
object |
the object to get to |
Example
let rock = nearestObject(name: "Iron rock", within: 20)
if rock != none and reach(rock) == "DRAWN" { interact(rock, "Mine") }
let door = nearestWall(name: "Door", within: 20)
if door != none and reach(door) == "DRAWN" { interact(door, "Open") }
let banker = nearestNpc(id: 95, within: 30)
if banker != none and reach(banker) == "DRAWN" { interact(banker, "Bank") }
let loot = nearestDrop(name: "Coins", within: 20)
if loot != none and reach(loot) == "DRAWN" { interact(loot, "Take") }