| # | Name | Lv | XP |
|---|
Define loop() (required, runs every tick, 50 ms limit) and optionally
init() (runs once, 500 ms limit). Scripts get 32 MB of memory.
Properties: x, y, hp, maxHp,
xp, level, queued (actions waiting).
Actions return true if queued, false if the queue (max 10) is full:
player.move(dir)
player.attack(dir)
player.attackClosest()
player.wait()
world.tick // current tick
world.vision // entities in view (free)
world.nearestPlayerDistance
world.wall(dx, dy) // true if solid; beyond radius 20 counts as solid
world.tiles(radius) // 2 calls per tick
world.scan(radius) // entities within radius
world.players(radius?) // type "user"
world.bots(radius?) // type "bot"
world.entities(radius?) // everything
world.drops(radius?) // hearts etc. on the ground
Without a radius, players/bots/entities filter world.vision for free.
With a radius they run a scan: 2 scans per tick, max radius 20.
const off = ui.onKey((key) => { ... });
off(); // unsubscribe
Max 8 listeners. Key names are cut to 16 characters.
log(...) and console.log/warn/error. Lines are cut to 200 characters.
function loop() {
if (world.bots(5).length) player.attackClosest();
else player.wait();
}