'cmd' is a virtual Lua table that points to all of the zScript commands. It will execute a specific zScript command with the given arguments. Even if you do not want to send any arguments to the command, you must still always use the parenthesis, just like with any other Lua function. zScript commands are just functions that do not return a value (with a few exceptions).
For example, to display a message using the zScript #MESSAGE command, you could do this:
Normally you would not need the 'cmd' table reference since Lua will automatically look for commands first. So you could just use:
and it will also work and is a bit shorter.
A few zScript commands will actually return a value when executed via Lua. These are the commands that create a new setting, or change an existing setting. For example, the zScript #ALIAS command creates or changes an Alias. When called from Lua, the actual Alias object is returned. So you can create an alias like this:
myalias = zs.alias("test","#show hello")
zs.execalias("test")
myalias.value = "#show new script"
zs.execalias("test")
The difference between this and the makealias method is that 'makealias' uses Lua class syntax and allows you to set various options directly.
The other commands that return objects like this are:
Add comment