Writing Joystick Code: Part 3: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Line 6: Line 6:


-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
  To toggle the Parking brake, use this. Entire code-block shown. Non-repeatable button. (You have to specifically set <repeatable> to true
  To toggle the Parking brake, use this. Entire code-block shown. Non-repeatable button.
if you want repeatable. It is assumed to be false.
(You have to specifically set <repeatable> to true if you want repeatable. It is assumed to be false.
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
   <button n="1">
   <button n="1">
Line 17: Line 17:
   </button>
   </button>
</syntaxhighlight>  
</syntaxhighlight>  
  This method can be used to toggle any property that is on/off. Use Debug - Browse Internal Properties to find suitable candidates.  
  This method can be used to toggle any property that is on/off.
Use Debug - Browse Internal Properties to find suitable candidates.  
  Also see getProp, setProp and setAll below.
  Also see getProp, setProp and setAll below.
   
   
Line 75: Line 76:
     <step type="double">-2.0</step>
     <step type="double">-2.0</step>
   </binding>
   </binding>
This will continously reduce /sim/current-view/goal-pitch-offset-deg in steps of 2 while the button is held in.
This will continuously reduce /sim/current-view/goal-pitch-offset-deg in steps of 2 while the button is held in.


== Advanced Programming ==
== Advanced Programming ==
Line 86: Line 87:


We write then as {, and endif as }.
We write then as {, and endif as }.
And each "action" is terminated by a semicolon:
And each "action" is terminated by a semicolon ;




Line 144: Line 145:


In English our code would be
In English our code would be
   If (x < 5) then (x = x + 2) else if (x < 10) then (x = x + 1). If none of these are true then (x = x + 7). End of if clause.
   If (x < 5) then (x = x + 2) else if (x < 10) then (x = x + 1).
  If none of these are true then (x = x + 7). End of if clause.


We test for x < 5 first. If it fails we test for x < 10. If x , 5 succeeds we do (x = x + 2) and then move on past the end of if clause.
We test for x < 5 first. If it fails we test for x < 10. If x , 5 succeeds we do (x = x + 2) and then move on past the end of if clause.
224

edits

Navigation menu