Documentation

cmd

cmd

Syntax: zs.cmd.cmdname(arguments)

'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:

zs.cmd.message("Hello World")

Normally you would not need the 'cmd' table reference since Lua will automatically look for commands first. So you could just use:

zs.message("Hello World")

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")

This creates an alias called "test" and then executes it. Then, using the 'myalias' variable that points to the alias, we can change it's value and execute it again.

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:

Alias object
#ALIAS
Var object
#VAR, #ADDITEM, #DELITEM, #ADDKEY, #DELKEY, #MATH, #ADD, #VARFUNC, #PROMPT
Trigger object
#TRIGGER, #ALARM, #ONINPUT, #MXPTRIG, #REGEX, #CONDITION, #TEMP
Event object
#EVENT
Menu object
#MENU
Path object
#PATH
Macro object
#KEY
Button object
#BUTTON, #GAUGE
Direction object
#DIR
Class object
#CLASS
Status object
#STATUS, #STWIN

Add comment

Login or register to post comments