diff options
Diffstat (limited to 'examples')
| -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, +} |
