Nasal library: Difference between revisions

Jump to navigation Jump to search
(→‎printlog(): Add note about "none")
Line 2,000: Line 2,000:


=== setlistener() ===
=== setlistener() ===
{{Callback Disclaimer}}
{{WIP}}
{{Nasal doc
|syntax = setlistener(node, code, init, type);
|source = {{flightgear file|src/Scripting/Nasal|l=499|t=Part 1}} {{!}} {{flightgear file|src/Scripting/Nasal|l=1350|t=Part 2}}<br>''Listener implemented using the {{API Link|flightgear|class|FGNasalListener}} class.''
|text = Creates a listener which will be triggered when the given property is changed (depenning on the '''type'''). A unique integer ID is returned; this can later be used as the argument to {{func link|removelistener}}.
{{note|Listeners are known to be a source of resource leaks. To avoid this, please take measures such as:
* Using {{func link|removelistener}} when they are not needed any more.
* Using a single initialization listener.
* Avoiding tying listeners to properties that are rapidly updated (e.g., many times per frame).
}}
|param1 = node
|param1text = String or <code>props.Node</code> object pointing to a property in the [[Property Tree]].
|param2 = code
|param2text = Callback function to execute when the listener is triggered.
|param3 = init
|param3text = If set to 1 (true), the listener will additionally be triggered when it is created. Defaults to 0 (false).
|param4 = type
|param4text = Integer specifying the listener's behavior. 0 means that the listener will only trigger when the property is changed. 1 means that the trigger will always be triggered when the property is written to. 2 will mean that the listener will be triggered even if child properties are modified.
}}


=== setprop() ===
=== setprop() ===

Navigation menu