Documentation

maketrigger

maketrigger

Syntax: zs.maketrigger{prop-list}

Creates a new trigger or modifies an existing trigger and returns the Trigger record. This uses the Lua class syntax of {prop-list} where {prop-list} is a table of property values. Some properties can be set by the index (position in the table), while other properties can be set by name.

The indexed properties are: Pattern, Value/Script, Class, and Name/ID. So, for example:

a = zs.maketrigger{"pattern", "commands", "myclass", "mytrig"}

will create an trigger called "mytrigger" in the class folder "myclass" with the "commands" as the value/script of the trigger . This same trigger could have been created with the syntax:

a = zs.maketrigger{pattern="mytrigger", value="commands", class="myclass", name="mytrig"}

This key=value syntax allows you to set *any* of the properties of the Trigger object at creation time directly.

For example,

a = zs.maketrigger{"you get (\d+) coins", "split %1", isregex=true}

This sets the "IsRegEx" property of the trigger to True when it is created. Note that two \ were needed because Lua uses \ as an escape character within string values.

Add comment

Login or register to post comments