World
Handle world adalah snapshot bot terhadap peta sekarang: tile, player di world yang sama, drop yang tergeletak, mob AI, tanaman yang lagi tumbuh. Setiap accessor await snapshot fresh dari bot session, jadi panggilan beruntun langsung baca data live tanpa perlu refresh manual.
local world = getClient():world() -- atau getWorld()
Identitas
world.id
| Field | Type |
|---|---|
| Signature | World.id → string |
| Returns | string — sama persis kayak world.name (protokolnya gak punya world id terpisah) |
world.name
| Field | Type |
|---|---|
| Signature | World.name → string |
| Returns | string — nama world dalam huruf kapital (mis. "PIXELSTATION") |
world:size()
| Field | Type |
|---|---|
| Signature | (self: World) → Vec2i |
| Returns | Vec2i — dimensi world dalam satuan tile (x = WIDTH, y = HEIGHT) |
| Async | yes |
world:entrance()
| Field | Type |
|---|---|
| Signature | (self: World) → Vec2i |
| Returns | Vec2i — spawn point dalam koordinat tile (WorldStartPoint, kecuali TUTORIAL2 yang selalu return tile sleeping-pod) |
| Async | yes |
world.id
world.name
world:size()
world:entrance()
Tile
world:tile(point)
| Field | Type |
|---|---|
| Signature | (self: World, point: Vec2i) → Tile? |
| Returns | Tile? — nil kalau snapshot world belum siap (mis. lagi mid-warp). Koordinat OOB jatuh ke tile sentinel dengan semua layer nol |
| Async | yes |
world:tiles()
| Field | Type |
|---|---|
| Signature | (self: World) → {Tile}? |
| Returns | {Tile}? — array flat 1-indexed, row-major, panjangnya width * height entry. nil kalau snapshot belum siap |
| Async | yes |
local tile = world:tile(Vector2i.new(5, 5))
for tileIndex, tile in pairs(world:tiles()) do
tile.foreground
tile.background
tile.water
tile.wire
tile.point
local item = tile:item()
if item then
for k, v in pairs(item) do print("{}: {}", k, v) end
end
local tree = tile:tree()
if tree then
tree.point
tree.blockType
tree.mixed
tree:ready()
end
end
world:findTiles(blockType)
| Field | Type |
|---|---|
| Signature | (self: World, blockType: number) → {Vec2i} |
| Returns | {Vec2i} — list 1-indexed berisi semua tile foreground yang id-nya match blockType. Table kosong kalau gak ada hit |
| Async | yes |
Index scan cepat — berguna buat nyari gemstone, peti, portal, dll.
for i, point in ipairs(world:findTiles(9)) do -- 9 = Soil
print(point.x, point.y)
end
Player
world:player(uid)
| Field | Type |
|---|---|
| Signature | (self: World, uid: string) → Player? |
| Returns | Player? — nil kalau gak ada player dengan uid itu di world (atau yang match itu local player dan dia di-exclude) |
| Async | yes |
world:players()
| Field | Type |
|---|---|
| Signature | (self: World) → {[string]: Player} |
| Returns | {[string]: Player} — map setiap player lain, key-nya userid (BUKAN 1-indexed). Local player gak ikut |
| Async | yes |
local p = world:player("userId")
for userId, p in pairs(world:players()) do
p.id
p.name
p.position
p.level
end
Collectable
world:collectable(id)
| Field | Type |
|---|---|
| Signature | (self: World, id: number) → Collectable? |
| Returns | Collectable? — nil kalau gak ada collectable dengan CollectableID server-side itu di world |
| Async | yes |
world:collectables()
| Field | Type |
|---|---|
| Signature | (self: World) → {[number]: Collectable} |
| Returns | {[number]: Collectable} — map setiap collectable yang tergeletak, key-nya id |
| Async | yes |
local c = world:collectable(collectableId)
for id, c in pairs(world:collectables()) do
c.id
c.amount
c.position
c.blockType
c.inventoryType
c.isGem
c.gemType
end
Mob AI
world:enemy(id)
| Field | Type |
|---|---|
| Signature | (self: World, id: number) → Enemy? |
| Returns | Enemy? — nil kalau gak ada AI dengan id itu yang ke-track. Id ini sama yang lo lempar ke client:hitEnemy(x, y, aiId) |
| Async | yes |
world:enemies()
| Field | Type |
|---|---|
| Signature | (self: World) → {[number]: Enemy} |
| Returns | {[number]: Enemy} — map setiap enemy AI yang ke-track, key-nya aiId |
| Async | yes |
local e = world:enemy(enemyId)
for id, e in pairs(world:enemies()) do
e.id
e.type
e.direction
e.behavior
e.position
e.velocity
e.parent
end
Growscan
world:growscan()
| Field | Type |
|---|---|
| Signature | (self: World) → Growscan |
| Returns | Growscan — proyeksi panen agregat dari setiap tile yang lagi tumbuh + collectable yang udah jatuh. Pake :tiles() / :collectables() buat baca row-nya |
| Async | yes |
Aggregat pohon panen dan drop tanah berdasarkan (blockType, inventoryType):
local g = world:growscan()
for i, pair in pairs(g:tiles()) do
print("{} {} x{}", pair.blockType, pair.inventoryType, pair.amount)
end
for i, pair in pairs(g:collectables()) do
print("{} {} x{}", pair.blockType, pair.inventoryType, pair.amount)
end
Contoh harvest
Jalan ke setiap pohon yang siap dan tebang.
local client = getClient()
local world = client:world()
local function harvestable(tile)
local tree = tile:tree()
return tree ~= nil and tree:ready()
end
local function tryHarvest(tile)
while harvestable(tile) do
if not client:point():equals(tile.point) then
if not client:findPath(tile.point) then return end
while client:pathfinding() do sleep(100) end
else
client:hit(tile.point)
sleep(200)
end
end
end
for i, tile in pairs(world:tiles()) do
tryHarvest(tile)
end