// world
NPC & tiles
High-level facades for NPCs and world tiles.
NPC
Lua
local NPC = require("CrawlzUtils").NPC
local B = require("CrawlzUtils").DialogBuilder
local npc = NPC.new(world, "Vendor", 10, 5, { meta = { role = "seller" } })
npc:spawn()
npc:onWrench(function(evWorld, pl, ctx)
npc:openDialog(pl, { page = "main" })
end)
npc:dialog("vendor_ui", function(w, pl, c)
return B.new("vendor_ui"):title("Shop", 242)
end)
| Area | Methods |
|---|---|
| Factory | new, create, wrap, find, fromObject, all, removeAll |
| Lifecycle | spawn, remove, respawn, refreshHandle, isSpawned |
| State | position, tile, move, netID, userID, getMeta, setMeta |
| UX | bubble, say, message, dialog, route, openDialog |
| World | visualPunch, visualBuild, effect, setClothing, updateClothing |
| Events | on, onWrench, onPunch, onSpawn, onRemove, emit |
| Sandbox | withAccess |
Tile
Lua
local Utils = require("CrawlzUtils")
local T = Utils.Tile.at(world, 12, 34)
if T:exists() then
Utils.wrapPlayer(pl):message("FG: " .. tostring(T:foreground()))
end
Factories: Tile.new, Tile.at, Tile.wrap.
| Area | Methods |
|---|---|
| Geometry | :exists, :refresh, :pos, :x, :y, :isAt |
| Read | :foreground, :background, :flags, :item, :itemName |
| Data | :data, :setData |
| Write | :setForeground, :setBackground, :setFlags, :paint, :clearPaint |
| Sync | :update, :punch |
| Drops | :spawnItem, :drops, :dropCount, :removeDrops |
| Graph | :neighbor, :neighbors, :around |
| Copy | :serialize, :copyFrom, :replace |