Examples
Working plugin examples to learn from.
Simple Echo Plugin
The simplest possible plugin (no canvas):
print("Echo Plugin loading...")
print("Hello from Echo Plugin!")
utilprint("$GPlugin: $wReady!") -- Green "Plugin:" with white text
addAlias("^/greet (.+)$", function(match, name)
send("say Hello, " .. name .. "!")
end, true)
print("Echo Plugin loaded!")Canvas Widget
Drawing shapes on a canvas:
print("Canvas Demo loading...")
local widget = createWidget({
type = "canvas",
title = "Shapes",
width = 300,
height = 200
})
local function draw()
clear("#1a1a2e")
drawRect(20, 20, 80, 60, "#e94560")
drawCircle(180, 50, 40, "#0f3460")
drawLine(20, 150, 280, 150, "#16c79a", 3)
drawText("Hello World!", 100, 180, "#ffffff")
end
registerWidgetEvent(widget, "resize", function() draw() end)
function init()
draw()
end
print("Canvas Demo loaded!")Trigger with Capture Groups
Capturing data from MUD output:
print("Combat Logger loading...")
local kills = 0
addTrigger("You have slain (.+)!", function(match, target)
kills = kills + 1
print("[Combat] Killed: " .. target .. " (Total: " .. kills .. ")")
utilprint("$R[Kill] $w" .. target) -- Red "[Kill]" with white target name
end, true)
addAlias("^/kills$", function()
print("Total kills this session: " .. kills)
utilprint("$YKills: $w" .. kills) -- Yellow "Kills:" with white count
end, true)
print("Combat Logger loaded!")Timer Example
Periodic actions:
print("Auto-Heal loading...")
local isHurt = false
addTimer(5000, function()
if isHurt then
send("cast heal self")
end
end, true)
addTrigger("You are wounded!", function()
isHurt = true
print("[Auto-Heal] Activating...")
utilprint("$Y[Heal] $wActivating...") -- Yellow "[Heal]"
end, false)
addTrigger("You are fully healed.", function()
isHurt = false
print("[Auto-Heal] Complete.")
utilprint("$G[Heal] $wComplete!") -- Green "[Heal]"
end, false)
print("Auto-Heal loaded!")Using GMCP Data
Accessing protocol data:
print("Room Tracker loading...")
local room = getCurrentRoom()
if room then
print("Current room: " .. (room.name or "Unknown"))
end
onGMCPUpdate("Room.Info", function(data)
print("Moved to: " .. (data.name or "Unknown room"))
utilprint("$C[Room] $w" .. (data.name or "Unknown")) -- Cyan "[Room]"
end)
print("Room Tracker loaded!")Multi-Session Communication
Sending commands between sessions:
print("Session Coordinator loading...")
addAlias("^/all (.+)$", function(match, cmd)
sendToAll(cmd)
print("Sent to all: " .. cmd)
utilprint("$M[All] $w" .. cmd) -- Magenta "[All]"
end, true)
addAlias("^/to (%w+) (.+)$", function(match, session, cmd)
sendToSession(session, cmd)
print("Sent to " .. session .. ": " .. cmd)
utilprint("$C[" .. session .. "] $w" .. cmd) -- Cyan session name
end, true)
print("Session Coordinator loaded!")Last updated on