v1.2.0.1-beta1
|
A collection of simple examples of using math, formatting, and other basic functions.
These examples use States coming from another plugin (for Microsoft Flight Simulator), but any State or Value could be substituted in their place.
The dynamic values (State names) are all in Touch Portal's usual ${value:value_name}
format as they appear when selected with the +
button.
Uses Number.toFixed() standard JavaScript function.
Simple math operation on any numeric value (there are 0.3048 meters to one foot).
This example results in "Ground Speed: 12 mph" based on current ground speed in knots (there are 1.150779448 knots to one mile). It uses the Format function.
A ternary operator means, in English, "if condition is true then do A, otherwise do B". The corresponding syntax is condition ? A : B
This example sets the 'MSFS_StallWarning' state to "STALL" when the warning is active and to an empty string when the warning is not.
Uses Net.request()
to get an image from a URL and send it to Touch Portal to be used as a button icon.
Download example button: DSE_RequestImageExample.tpb
This example reacts to either a button press or a change in a test Touch Portal Value (with name/id dse.Example.numeric_1
).
One could add this Value in the Touch Portal Values tab, and then for example set up a Slider to change the value (this varies the value between 0 and 100). Moving the slider will then run through the whole gamut of color hues.
The example uses the Color
class to perform color manipulation. This is used more extensively in the Color Mixer Example.
Download example button: DSE_Color_Example.tpb