Document how to include a Lua script.

This commit is contained in:
Condorra 2024-10-13 00:05:00 +11:00
parent c4db69a1fe
commit 58a9aa088f

View File

@ -275,3 +275,21 @@ Tip: When setting aliases or triggers to call into Lua code, the most robust way
If you want to write a comment in your Lua code, use `-- ` to make the rest of the line a comment, or
`--[[` to open a comment block that runs until you close it with `--]]`.
## Running scripts from the terminal
Type `#include scriptname` to run a script. Only `init.lua` automatically runs at startup.
You could create a script, for example, that automatically connects you to a particular MUD, and logs you in, and
sets up some aliases and triggers. Then just `#include yournewscript.lua` when needed.
Hint: When sending the username and password, try using something like:
```
commands.connect_mud("mymud", "wss://mymud.example.org/ws");
commands.delay(0.1, "yourusername;yourpassword");
```
The delay will allow for the connection to be made before you actually attempt the password.
Be aware that if you use this pattern, your MUD password will be stored in your browser and will
be viewable by anyone with local access to your browser.