From Lavish Software Wiki
Jump to navigation Jump to search

LavishGUI 2 implements a Trigger system to react to LavishScript conditions.

Triggers can Update on a "manual" basis (in code), "pulse" (automatically each frame), or "event" (via a LavishScript Event).

A Trigger maps a LavishScript condition to LGUI2 Event Handlers. The condition is checked each Update; if it equals zero, the Trigger is un-matched; otherwise, it is matched. An Event Handler fires if the matched/unmatched state changed.

Defining a Trigger

LavishGUI 2 Triggers are defined by a JSON Object enclosed by {}

Triggers can be defined within any Element, in a "triggers" Object.

Trigger Properties

Trigger properties
matched (Required) An Event Handler definition specifying what to do when the Trigger becomes matched
unmatched An Event Handler definition specifying what to do when the Trigger becomes un-matched
name The name of the Trigger. This name should be mutually exclusive within the Element; Any new Trigger with the same name will remove the previously existing Trigger.
condition A LavishScript condition (see LavishScript:Mathematical Formulae) which may include LavishScript:Data Sequences. If not given, default is to always match.
mode A string specifying one of "manual", "pulse" (automatically checked each frame), or "event". If not given, the default is "pulse" (checked each frame).
ls1event A string specifying the name of a LavishScript Event to attach to. When the Event fires, the Trigger Updates. If given, the "event" mode is inferred.


A button with different background colors depending on the value of ${ISBoxer2.MasterHotkeyToggleState}
  "type": "button",
  "content": "H",
  "styles": {
    "on": {
      "backgroundBrush": {
        "color": [0.0,1.0,0.0]
    "off": {
      "backgroundBrush": {
        "color": [1.0,0.0,0.0]
  "triggers": {
      "condition": "${ISBoxer2.MasterHotkeyToggleState}",
      "matched": {
        "type": "style",
        "styleName": "on"
      "unmatched": {
        "type": "style",
        "styleName": "off"
    "onRelease": ["method","ISBoxer2","ToggleMasterHotkeyToggle"]

LavishGUI 2 Topics