482
edits
(→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; | ||
Note that "var" creates variables that are local in scope, which may cause problems if you are intending to use a variable globally among all different bindings in your joystick XML file. | |||
* You can include a section of script that runs on startup to initialize variables, create functions, etc. Example: | * You can include a section of script that runs on startup to initialize variables, create functions, etc. Example: | ||
| Line 339: | Line 341: | ||
<script> | <script> | ||
#initialize variables | #initialize variables | ||
f1 = f2 = 0; | |||
left_brake = right_brake = 0; | |||
# create a function to be used with all buttons | # create a function to be used with all buttons | ||
getmod = func { getprop("/input/joysticks/js[0]/t-flight-hotas-x-modifier" ) } | |||
</script> | </script> | ||
</nasal> | </nasal> | ||
edits