Writing Joystick Code: Part 2: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 5: Line 5:
Make sure you have read [[Input device]] and [[Writing Joystick Code: Part 1]] first.
Make sure you have read [[Input device]] and [[Writing Joystick Code: Part 1]] first.


These are what you use instead of ''Your code goes here'' amd ''Ctrl-Alt button released''. You just need to put them in the right place - inbetween the <script> and </script> tags.
These are what you use instead of ''Your code goes here'' amd ''Ctrl-Alt button released''.
You just need to put them in the right place - inbetween the <script> and </script> tags.


Please note that some of them have concepts that will be explained in a later section.
Please note that some of them have concepts that will be explained in a later section.
Line 15: Line 16:
     Code for <mod-up>
     Code for <mod-up>


Where Action is what you want to do, R means use with a repeatable button, NR means use with a non-repeatable button, and U is the code for <mod-up>. If it is empty, a <mod-up> is not needed.
Where Action is what you want to do, R means use with a repeatable button, NR means use with a non-repeatable button,
and U is the code for <mod-up>. If it is empty, a <mod-up> is not needed.


Some Actions will have code for use with repeatable and non-repeatable buttons.
Some Actions will have code for use with repeatable and non-repeatable buttons.
Line 23: Line 25:
If the action is upside-down for you, swap the + and - signs.
If the action is upside-down for you, swap the + and - signs.


Also, sometimes the 1 is replaced by a number, which specifies by how much the action should be carried out. If the action is too viscious for you, make the number smaller.
Also, sometimes the 1 is replaced by a number, which specifies by how much the action should be carried out.
If the action is too vicious for you, make the number smaller.


=== The snippets ===
=== The snippets ===
Line 189: Line 192:
   setProp(("controls/lighting/xxx"), false)
   setProp(("controls/lighting/xxx"), false)
   
   
  Where xxx = beacon, landing-lights, landing-light, landing-light[1] logo-lights, nav-lights, strobe, taxi-light, taxi-lights, cabin-lights, map-lights.  
  Where xxx = beacon, landing-lights, landing-light, landing-light[1] logo-lights, nav-lights, strobe, taxi-light,
taxi-lights, cabin-lights, map-lights.  
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
  Instrument lights level up R
  Instrument lights level up R
Line 233: Line 237:


   
   
If you find a line is too long for your page width, then you can press Enter and go to a new line. FG will be happy - it needs a tag or a ; at the end of a line to tell it that the current line of code is finished.
If you find a line is too long for your page width, then you can press Enter and go to a new line.
FG will be happy - it needs a tag or a ; at the end of a line to tell it that the current line of code is finished.
   setprop("controls/engines/engine/mixture", getprop ("controls/engines/engine/mixture") + 0.05)
   setprop("controls/engines/engine/mixture", getprop ("controls/engines/engine/mixture") + 0.05)
becomes
becomes
   setprop("controls/engines/engine/mixture",
   setprop("controls/engines/engine/mixture",
     getprop ("controls/engines/engine/mixture") + 0.05)
     getprop ("controls/engines/engine/mixture") + 0.05)
Notice where I put the newline and how I indented the second line. Both are designed to make it easy for people to read, as part of being a programmer is making your code legible for others.
Notice where I put the newline and how I indented the second line. Both are designed to make it easy for people to read,
as part of being a programmer is making your code legible for others.




224

edits