Writing Joystick Code: Part 3: Difference between revisions

Jump to navigation Jump to search
no edit summary
(Created page with "{{WIP}} == Special snippets == Once again, the examples may use concepts that you need to explore in the Advanced Programming section. ------------------------------------...")
 
No edit summary
Line 1: Line 1:
{{WIP}}
{{WIP}}




Line 5: Line 6:


Once again, the examples may use concepts that you need to explore in the Advanced Programming section.
Once again, the examples may use concepts that you need to explore in the Advanced Programming section.


-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Line 15: Line 17:
     </binding>
     </binding>
   </button>
   </button>
 
  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.
  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.
 
  Remember, it ''toggles'' the property, you can't use it to set the property into a specific state.
  Remember, it ''toggles'' the property, you can't use it to set the property into a specific state.
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Line 28: Line 30:
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
  To make condition work with mixture on a non-repeatable button.
  To make condition work with mixture on a non-repeatable button.
 
  Make mixture richer NR
  Make mixture richer NR
   <![CDATA[  
   <![CDATA[  
Line 36: Line 38:
     }
     }
   ]]>
   ]]>
 
  Make mixture leaner NR
  Make mixture leaner NR
   <![CDATA[
   <![CDATA[
Line 53: Line 55:
     }
     }
   ]]>
   ]]>
 
  Make mixture leaner R
  Make mixture leaner R
   <![CDATA[
   <![CDATA[
Line 64: Line 66:




You can also use the following method to adjust a property
This is an alternative method to adjust a property
   <repeatable>true</repeatable>
   <repeatable>true</repeatable>
   <binding>
   <binding>
Line 98: Line 100:
     y + y + 1
     y + y + 1
   }
   }


Now lets pretend that we still want to increase x by 2 if it less than 5, and if it is 5 or more we want to add 1 to it. We use else. It looks like this
Now lets pretend that we still want to increase x by 2 if it less than 5, and if it is 5 or more we want to add 1 to it. We use else. It looks like this
Line 287: Line 288:
     <mode type="int">1</mode>  # Initialise mode to 1
     <mode type="int">1</mode>  # Initialise mode to 1
   </data>
   </data>
 
   <nasal>
   <nasal>
     <script>
     <script>
       <![CDATA[
       <nowiki><![CDATA[
  var self = cmdarg().getParent();
  var self = cmdarg().getParent();
  var data = self.getNode("data");
  var data = self.getNode("data");
Line 297: Line 298:
       ]]></script>
       ]]></script>
   </nasal>
   </nasal>
 
   var m  # Used whenever mode is accessed
   var m  # Used whenever mode is accessed</nowiki>


This goes right at the top of your xml file, just after </name>.
This goes right at the top of your xml file, just after </name>.
Line 323: Line 324:


Advantages:  
Advantages:  
  Mode is defined within the xml file.
Mode is defined within the xml file.


Disadvantages:
Disadvantages:
  Mode is not accessable from another xml file, such as for the rudder.
Mode is not accessable from another xml file, such as for the rudder.




Line 357: Line 358:


Advantages:  
Advantages:  
  Mode is available from any xml file, so you can make the rudders behave according to its value.
Mode is available from any xml file, so you can make the rudders behave according to its value.


Disadvantages:
Disadvantages:
  You have to have at <nowiki>--Prop:</nowiki> in the command line.
You have to have at <nowiki>--prop:</nowiki> in the command line.
  You need to choos a better name than ''mode'' to avoid possible conflicts.
You need to choos a better name than ''mode'' to avoid possible conflicts.
  You can't type <nowiki>--prop:</nowiki> in the comments section at the top of your file, because of the consecutive minus signs. You have to type &minus;&minus;prop:.
You can't type <nowiki>--prop:</nowiki> in the comments section at the top of your file, because of the consecutive minus signs. You have to type &amp;minus;&amp;minus;prop:


-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
Line 369: Line 370:


peraxisindexhandler
peraxisindexhandler
-----------------------------------------------------------------------------
Go back to
224

edits

Navigation menu