diff options
| author | t <t@tjp.lol> | 2026-06-02 19:41:56 -0600 |
|---|---|---|
| committer | t <t@tjp.lol> | 2026-06-02 22:09:31 -0600 |
| commit | 442888c6c306cfff0708c3d4bbbeda685cec2e75 (patch) | |
| tree | 858ad09d4da908cc7e61ca5e570e2f46e74bdb68 /examples/extensions/greet.lua | |
| parent | 8b88b886346460b1ab29edb03ad85bc3bb565a45 (diff) | |
lua /commands
Diffstat (limited to 'examples/extensions/greet.lua')
| -rw-r--r-- | examples/extensions/greet.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/extensions/greet.lua b/examples/extensions/greet.lua new file mode 100644 index 0000000..5ec406f --- /dev/null +++ b/examples/extensions/greet.lua @@ -0,0 +1,16 @@ +-- A trivial Lua slash command that greets the user. +-- Drop this under .panto/extensions/ (project) or your user config's +-- extensions/ dir, then type `/greet` or `/greet <name>` in the REPL. +-- +-- Slash-command handlers run synchronously and act by side effect (here, +-- writing to stdout). `args` is the trimmed text after the command name; +-- it is an empty string when none was given. The return value is ignored. + +panto.register_command { + name = "greet", + description = "Print a greeting. Optional args name who to greet.", + handler = function(args) + local who = args ~= "" and args or "world" + io.write("\n[greet] hello, " .. who .. "!\n") + end, +} |
