On this page

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)
AreaMethods
Factorynew, create, wrap, find, fromObject, all, removeAll
Lifecyclespawn, remove, respawn, refreshHandle, isSpawned
Stateposition, tile, move, netID, userID, getMeta, setMeta
UXbubble, say, message, dialog, route, openDialog
WorldvisualPunch, visualBuild, effect, setClothing, updateClothing
Eventson, onWrench, onPunch, onSpawn, onRemove, emit
SandboxwithAccess

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.

AreaMethods
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