Lua Scripting
Lua is the power layer beneath simple UI tools.
You can use PlayMUD.online without writing code. Lua is there when a trigger or alias needs decisions, saved values, timers, colored feedback, or reusable helper functions.
Two Layers
Saved profile settings include automation folders, triggers, aliases, scripts, saved variables, hotkeys, and UI preferences.
Runtime state is temporary data shared by Lua while connected: counters, combat notes, prompt values, and other session-only details. Use state when you do not need the value saved forever.
Current API
send(command)
echo(text)
gag()
sub(text)
vars.name = value
state.name = value
highlight(fg, bg)
gauge.create(id, options)
status.create(id, options)
Helper Example
function captureTarget(text)
local target = string.match(text, "^You are now fighting (.+)%.$")
if target then
vars.target = target
echo("Target set to " .. vars.target)
end
end
This function looks at one line of text. If the line says you are now fighting something, it saves that name as vars.target and echoes a confirmation.
Put reusable helpers in Scripts, then call them from Lua triggers or Lua aliases.
Echo Color Tags
Lua echo() supports readable inline tags such as <green>, <bg:#202000>, and <#12FA00>.
See Echo Colors for the tag syntax and named color list.
Safety Decisions
- Lua runs in isolated browser workers with CPU and action limits.
- Scripts cannot access the DOM, network, browser storage, or unrestricted operating-system APIs.
- Persistent variables autosave; temporary
statedoes not. - A runtime error disables only its responsible trigger, alias, or script validation and appears in Activity.