Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
blocks:tasks [2019-05-12 19:17]
mattias [JavaScript Expressions]
blocks:tasks [2025-02-24 19:48] (current)
admin [Tasks and Expressions]
Line 33: Line 33:
 While the //Trigger// is the mere occurrence of the specified event (such as the time being 8:00 in the morning), the //Trigger Condition// can apply arbitrarily complex conditions on top of this event in order to decide whether to actually start the task. For instance, in the case of a time-of-day trigger, you can specify that it should only start the task if it's Saturday and a certain Block is playing on a particular Spot. While the //Trigger// is the mere occurrence of the specified event (such as the time being 8:00 in the morning), the //Trigger Condition// can apply arbitrarily complex conditions on top of this event in order to decide whether to actually start the task. For instance, in the case of a time-of-day trigger, you can specify that it should only start the task if it's Saturday and a certain Block is playing on a particular Spot.
  
-A //Trigger Condition// often uses the predefined variable named //trigger//, as in the example shown above. This variable is further described below under "Predefined Variables". You can, however, use any variable or system property in the condition.+A //Trigger Condition// often uses the predefined variable named //trigger//, as in the example shown above. This variable is further described below under "Predefined Variables". You can, however, use any system property in the condition.
  
 ===== JavaScript Expressions ===== ===== JavaScript Expressions =====
Line 118: Line 118:
 === Relational Operators === === Relational Operators ===
  
-Another type of operators allow you to compare things, such as numbers. As hey evaluate the //relation// of two values to each other, they are often called //relational operators//. They all result in a boolean value. Examples of relational operators include:+Another type of operators allow you to compare things, such as numbers. As they evaluate the //relation// of two values to each other, they are often called //relational operators//. They all result in a boolean value. Examples of relational operators include:
  
   * < for "left is less than right".   * < for "left is less than right".
Line 224: Line 224:
 ==== Predefined Variables ==== ==== Predefined Variables ====
  
-In addition to all system properties of you Blocks system, you also have access to the following predefined variables in tasks and their trigger condition field:+In addition to all system properties of your Blocks system, you also have access to the following predefined variables in tasks and their trigger condition field:
  
   * **trigger** contains the value of whatever triggered the task.   * **trigger** contains the value of whatever triggered the task.
Line 232: Line 232:
  
   * If the triggering mode is “Time of Day”; it's a JavaScript Date object.   * If the triggering mode is “Time of Day”; it's a JavaScript Date object.
-  * If the triggering mode is “Property Change” it's a number, boolean or string containing the property’s new value.+  * For “Property Change” it's a number, booleanstring or other object indicating the property’s new state. 
 +  * For "Server Startup", the value of //trigger// is undefined.
  
 If no trigger is assigned to the task, the value of //trigger// is undefined, and should not be used. Note that //trigger// will contain the current value of the tasks trigger even if the task was started by other means, such as manually clicking the //play// arrow next to the task's name, or by setting the task's //running// property to true. If no trigger is assigned to the task, the value of //trigger// is undefined, and should not be used. Note that //trigger// will contain the current value of the tasks trigger even if the task was started by other means, such as manually clicking the //play// arrow next to the task's name, or by setting the task's //running// property to true.
Line 238: Line 239:
 ==== Realm Variables ==== ==== Realm Variables ====
  
-You can add externally visible variables to a Realm. When doing o, you specify the data type used by that variable (number, boolean or string). Such a variable can be set frmo the outside, for example using a button on a panel, or by another task (using a //set realm variable// statement).+You can add externally visible variables to a Realm. When doing so, you specify the data type used by that variable (number, boolean or string). Such a variable can be set frmo the outside, for example using a button on a panel, or by another task (using a //set realm variable// statement).
  
 The value of such a realm variable can be used as a trigger, just like any other system property. You can also directly reference the value of a realm variable in any task within the same realm using the name of the variable followed by a period and the work //value//. Assuming you have a realm variable named //Brightness//, you can use its value in an expression like this: The value of such a realm variable can be used as a trigger, just like any other system property. You can also directly reference the value of a realm variable in any task within the same realm using the name of the variable followed by a period and the work //value//. Assuming you have a realm variable named //Brightness//, you can use its value in an expression like this:
Line 259: Line 260:
 ==== Property References ==== ==== Property References ====
  
-As seen in some of the example above, you can set the value of any property in your Blocks system using a //do// statement. You can pick the target of the //do// statement using the dropdown menus to the right. Alternatively, if you know the full path to the desired property, you can type this into the //do// statement's target field.+As seen in some of the examples above, you can set the value of any property in your Blocks system using a //do// statement. You can pick the target of the //do// statement using the dropdown menus to the right. Alternatively, if you know the full path to the desired property, you can type this into the //do// statement's target field.
  
 Some properties are //read only//. An example of such a read only property is the //connected// state of a Display Spot. There's nothing you can do from within Blocks to force a Spot to connect. Thus, this property can only be read, not set. Read only properties are shown in //italics// on dropdown menus. They can not be used as the target property of a //do// statement. They can, however, be used in expressions and task triggers. Some properties are //read only//. An example of such a read only property is the //connected// state of a Display Spot. There's nothing you can do from within Blocks to force a Spot to connect. Thus, this property can only be read, not set. Read only properties are shown in //italics// on dropdown menus. They can not be used as the target property of a //do// statement. They can, however, be used in expressions and task triggers.