Nasal library: Difference between revisions

Jump to navigation Jump to search
→‎getprop(): Some typos
(→‎getprop(): Some typos)
Line 1,511: Line 1,511:
=== getprop() ===
=== getprop() ===
{{Nasal doc
{{Nasal doc
|syntax = getprop(arg[, arg[, ...]]);
|syntax = getprop(path[, path[, ...]]);
|source = {{flightgear file|src/Scripting/NasalSys.cxx|l=345|t=Source}}
|source = {{flightgear file|src/Scripting/NasalSys.cxx|l=345|t=Source}}
|text = Returns the value of a node in the [[property tree]] or <code>'''nil'''</code> if the node does not exist or the value is not a number (NaN).
|text = Returns the value of a node in the [[Property Tree]] or <code>'''nil'''</code> if the node does not exist or the value is not a number (NaN).
|param1 = arg
|param1 = path
|param1text = There needs to be at least one argument, but there is no limit to the maximum amount of arguments that can be given. The arguments will be concatenated together to form a property tree path. The arguments must be strings, but in FlightGear v3.2 onwards, there is support (added by {{flightgear commit|34ed79}}) for numeric arguments as indices. See example 2 below.
|param1text = There needs to be at least one argument, but there is no limit to the maximum amount of arguments that can be given. The arguments will be concatenated together to form a property tree path. The arguments must be strings, but in FlightGear v3.2 onwards, there is also support (added by {{flightgear commit|34ed79}}) for numeric arguments as indices. See example 2 below.
|example1 = print("You have FlightGear v", getprop("/sim/version/flightgear")); # prints FlightGear version
|example1 = print("You have FlightGear v", getprop("/sim/version/flightgear")); # prints FlightGear version
|example2text = Note that the example below will only work in FlightGear 3.2 and above.
|example2text = Note that the example below will only work in FlightGear 3.2 and above.
Line 1,521: Line 1,521:
     print("View #", i + 1, " is named ", getprop("/sim/view", i, "name"));
     print("View #", i + 1, " is named ", getprop("/sim/view", i, "name"));
}
}
|example3text = Same as above, but is supported by all version of FlightGear.
|example3text = Same as above, but is supported by all versions of FlightGear.
|example3 = for(var i = 0; i < 8; i += 1){
|example3 = for(var i = 0; i < 8; i += 1){
     print("View #", i + 1, " is named ", getprop("/sim/view[" ~ i ~ "]/name"));
     print("View #", i + 1, " is named ", getprop("/sim/view[" ~ i ~ "]/name"));

Navigation menu