Input device: Difference between revisions

Jump to navigation Jump to search
→‎Useful hints for scripts: initial script start
(→‎Useful hints for scripts: initial script start)
Line 331: Line 331:
But [http://wiki.flightgear.org/index.php/Nasal_scripting_language#Variables for various reasons] it is much better to declare variables with the "var" statement:
But [http://wiki.flightgear.org/index.php/Nasal_scripting_language#Variables for various reasons] it is much better to declare variables with the "var" statement:
  var x = 10;
  var x = 10;
* You can include a section of script that runs on startup to initialize variables, create functions, etc.  Example:
<PropertyList>
  <name type="string">My joystick name</name>
  <name type="string">My joystick name #2</name>
  <nasal>
    <script>
        #initialize variables
        var f1 = f2 = 0;
        var left_brake = right_brake = 0;
        # create a function to be used with all buttons
        var getmod = func { return getprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier" ); }
    </script>
  </nasal>


==Resource==
==Resource==
* [http://www.flightgear.org/Docs/getstart/getstartch3.html#x8-360003.6 The FlightGear Manual]
* [http://www.flightgear.org/Docs/getstart/getstartch3.html#x8-360003.6 The FlightGear Manual]
482

edits

Navigation menu