P

PlayMUD.online

Lua aliases

Lua Aliases

Run Lua when a typed command matches.

Lua aliases intercept manual input before simple aliases and variables. Scripts run in the same browser worker sandbox as advanced triggers.

Where To Find Them

Open Automation and click Add Lua Alias. Lua aliases can live in the same folders as triggers, simple aliases, and scripts.

A Lua alias must compile before it can be enabled. If a parent folder is disabled, the alias will not intercept commands until that folder is enabled again.

Match Modes

  • exact matches the full typed command.
  • starts with matches the beginning of the command and exposes the rest as matches[2].
  • contains matches text anywhere in the command.
  • regex enables JavaScript regular expressions and capture groups.

First Example

Pattern: kt
Match: starts with

vars.target = matches[2]
echo("<green>Target:<reset> " .. vars.target)
send("kill " .. vars.target)

Typing kt orc sets the PlayMUD.online variable target to orc, echoes colored feedback, and sends kill orc.

matches[2] is the text after kt. The .. joins pieces of text. echo() writes feedback only to your terminal, and send() sends a command to the MUD.

Send More Than One Command

A simple alias expands to one command. A Lua alias can decide to send several commands.

Pattern: prep
Match: exact

send("wield sword")
send("wear shield")
send("score")

Typing prep sends those three commands in order. Use this for short command bundles that you would otherwise type by hand.

Check For Missing Text

Scripts can make friendly mistakes safer. This alias asks for a target if you forget to type one.

Pattern: blast
Match: starts with

local target = matches[2]
if target == "" then
  echo("<yellow>Usage:<reset> blast target")
  return
end

send("cast blast at " .. target)

if target == "" then checks whether the target is empty. return stops the alias early, so no MUD command is sent when the input is incomplete.

Actions

send("look")
send("look", 1) -- silent local echo

echo("<green>Green<reset> normal")
echo("<#12FA00>TrueColor<reset>")

Use Echo Colors for named colors and TrueColor tags. Echo output does not run triggers.

Variables

Global assignments write PlayMUD.online variables. They autosave with the current profile and can be used later as {target} in normal commands, aliases, hotkeys, and triggers.

target = "orc"
send("consider " .. target)

Use state.name for private Lua state that belongs only to that one alias.

Shared Helpers

Reusable functions belong in enabled Scripts. Lua aliases load enabled Scripts before running, so an alias can call functions such as luashow() directly.

-- Shared Script
function luashow(text)
  echo("<cyan>" .. text .. "<reset>")
end

-- Lua Alias
luashow(matches[1])

Safety Limits

Lua aliases compile before they can be enabled. Built-in action and run-time limits are shared with Lua triggers so one script cannot overwhelm the client.