Palace Lua API

Room, hotspot, and cyborg scripts may use Lua 5.4 running in the browser via WebAssembly (Wasmoon). Scripts never receive window, the DOM, or PSNet — only the sandboxed global palace, which mirrors classic and extended IPTSCRAE host effects.

Events

Register handlers with palace.on:

palace.on("ENTER", function(ctx)
  palace.chat.say("hello from lua")
end)

palace.on("OUTCHAT", function(ctx)
  -- mutate ctx.chatstr to rewrite outgoing chat (best-effort)
  if ctx.chatstr == "ping" then
    ctx.chatstr = "pong"
  end
end)

Supported event names match IPTSCRAE: SIGNON, ROOMLOAD, ENTER, LEAVE, SIGNOFF, SELECT, OUTCHAT, INCHAT, ALARM, PROPCHANGE, LOCK, UNLOCK, MACRO0MACRO12.

When a target has both IPTSCRAE and Lua sources, they run in authored scripts[] order. Cyborg scripts still run before room-level scripts, which run before hotspot scripts.

palace surface

APITierNotes
palace.chat.say(text)classicSend as local user
palace.chat.local(text)classicLocal balloon
palace.chat.room(text)classicRoom message
palace.chat.global(text)classicServer-wide (wizard)
palace.chat.log(text)classicChat log line
palace.room.goto(id)classicNavigate
palace.room.id() / name() / serverName()classicRead-only
palace.user.name() / id() / rank()classicLocal user
palace.spot.state(id[, n])classicGet/set pict state
palace.spot.lock(id) / unlock(id)classicDoor lock sim
palace.sound.play(name)classicRoom sound
palace.globals.get/set/delete/keysclassicShared with IPTSCRAE GLOBAL
palace.net.goto(url)extendedGated by extended iptscrae pref
palace.spot.setScript(id, src)extendedGated by extended iptscrae pref

Persistence

Sandbox limits

Mixed example

; IPTSCRAE (scripts[0])
ON SELECT {
  "ipt clicked" SAY
}

-- Lua (scripts[1])
palace.on("SELECT", function(ctx)
  palace.chat.say("lua clicked")
  local n = palace.globals.get("CLICKS") or 0
  palace.globals.set("CLICKS", n + 1)
end)

Iptscrae command reference