Differences

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

Link to this comparison view

Next revision
Previous revision
ardieffects:binding_expressions [2018/04/16 06:43]
optrix created
ardieffects:binding_expressions [2018/07/03 01:53] (current)
optrix
Line 1: Line 1:
 ====Binding Expressions==== ====Binding Expressions====
  
-You can use //​expressions//​ to change how values from an ARDI asset are translated into effects.+You can use //​expressions//​ to change how values from an ARDI asset are translated into effects. ​
  
 +These are most often used when you need to convert a measurement from raw units (ie. meters) to a value more suitable for an effect.
 +
 +The basic format is...
 +
 +<​code>​
 +[ <​property name/​number>​ ]
 +</​code>​
 +
 +However, there are three expression types that can help change the value.
 +
 +===Converting to Boolean===
 +<​code>​
 +[ <​property name/​number>​|value1|value2|value3 ]
 +</​code>​
 +
 +This expression results in a boolean (yes/no) value. When the property (for example, '​Mode'​) matches any one of the given values, the boolean is '​true'​. Otherwise, it's '​false'​. ​
 +
 +===Using Measurement Scales===
 +<​code>​
 +[ <​property name/​number>:​%:<​minimum>:<​maximum>​]
 +</​code>​
 +
 +This uses the minimum and maximum scale of the measurement to rescale the value. It's most often used to convert properties from a raw value (for instance, tank level measured in meters) to a height (tank level measured in %).
 +
 +Let's take a look at the following example...
 +
 +**Tank Level** - Analogue value, 0.5 - 2.5m
 +
 +If you used this expression... <​code>​[ Tank Level:​%:​0:​100 ]</​code>​
 +
 +Then you would get the following values....
 +
 +^Input^Output^
 +|0.5|0 (0%)|
 +|1|25 (25%)|
 +|1.5|50 (50%)|
 +|2|75 (75%)|
 +|2.5|100 (100%)|
 +
 +===Mathematical Transform===
 +<​code>​
 +[ <​property name/​number>:​*:<​offset>:<​multiplier>​]
 +</​code>​
 +
 +This option allows you to add an offset and multiplier to your values.
 +
 +Lets take a look at the last example, where we again want to convert a tank level in meters to a percentage.
 +
 +**Tank Level** - Analogue value, 0.5 - 2.5m
 +
 +To convert a 0.5-2.5 value to a 0-1 value, we need to first subtract 0.5, then multiply by 0.5. This gives us the following expression <​code>​[ Tank Level:​*:​-0.5:​0.5 ]</​code>​
 +
 +//NOTE - Where possible, please use the measurement-scale version of this function. This allows users to adjust your visual scales globally from the web interface, without needing to edit individual effect files.//
 +
 +===Examples===
 ^Example^Description^ ^Example^Description^
 |<​code>​[ Level ]</​code>​|A simple copy of the property into the effect.| |<​code>​[ Level ]</​code>​|A simple copy of the property into the effect.|
 |<​code>​[ Level|1 ]</​code>​|Is '​1'​ when the property equals one, otherwise it's 0.| |<​code>​[ Level|1 ]</​code>​|Is '​1'​ when the property equals one, otherwise it's 0.|
-|<​code>​[ Level|3|5|12 ]</​code>​|Is '​1'​ when the property equals three, five or twelve, otherwise it's 0.|+|<​code>​[ Level|3|5|12 ]</​code>​|Is '​1'​ when the property equals three, five or twelve, otherwise it's 0|
 |<​code>​[ Level:​%:​0:​100]</​code>​|Use the percentage of the property range. If the property has a range between 0 and 500, 500 results in an effect value of 100, 250 results in an effect of 50, 0 results in an effect of 0.| |<​code>​[ Level:​%:​0:​100]</​code>​|Use the percentage of the property range. If the property has a range between 0 and 500, 500 results in an effect value of 100, 250 results in an effect of 50, 0 results in an effect of 0.|
 |<​code>​[ Level:​*:​20:​2 ]</​code>​|The first option is an //offset// (an amount added to the base) and the second option is a multiplier. In this example, 20 is added to the amount before it is multiplied by 2, so that 0=40, 50 = 140 etc.| |<​code>​[ Level:​*:​20:​2 ]</​code>​|The first option is an //offset// (an amount added to the base) and the second option is a multiplier. In this example, 20 is added to the amount before it is multiplied by 2, so that 0=40, 50 = 140 etc.|