Nasal library: Difference between revisions

Jump to navigation Jump to search
m
(→‎maketimer(): Add note about TimerObj class)
Line 2,002: Line 2,002:
{{WIP}}
{{WIP}}
{{Nasal doc
{{Nasal doc
|syntax = setlistener(node, code, init, type);
|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.''
|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 (depending on the '''type'''). A unique integer ID is returned; this can later be used as the argument to {{func link|removelistener}}.
|text = Creates a listener which will be triggered when the given property is changed (depending on the '''type'''). A unique integer ID is returned; this can later be used as the argument to {{func link|removelistener}}.
Line 2,011: Line 2,011:
}}
}}
|param1 = node
|param1 = node
|param1text = String or <code>props.Node</code> object pointing to a property in the [[Property Tree]].
|param1text = Mandatory string or <code>props.Node</code> object pointing to a property in the [[Property Tree]].
|param2 = code
|param2 = code
|param2text = Callback function to execute when the listener is triggered. The function can take up to four arguments in the following order:
|param2text = Mandatory callback function to execute when the listener is triggered. The function can take up to four arguments in the following order:
* '''changed''': a <code>props.Node</code> object pointing to the changed node.
* '''changed''': a <code>props.Node</code> object pointing to the changed node.
* '''listen''': a <code>props.Node</code> object pointing to the listened-to node. Note that this argument maybe different depending on the '''type'''.
* '''listen''': a <code>props.Node</code> object pointing to the listened-to node. Note that this argument maybe different depending on the '''type'''.
Line 2,019: Line 2,019:
* '''is_child''': boolean telling whether '''changed''' is a child property of the listened-to '''node''' or not. 1 (true) if it is, 0 (false) otherwise.
* '''is_child''': boolean telling whether '''changed''' is a child property of the listened-to '''node''' or not. 1 (true) if it is, 0 (false) otherwise.
|param3 = init
|param3 = init
|param3text = If set to 1 (true), the listener will additionally be triggered when it is created. Defaults to 0 (false).
|param3text = If set to 1 (true), the listener will additionally be triggered when it is created. This argument is optional and defaults to 0 (false).
|param4 = type
|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. Defaults to 1.
|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. This argument is optional and defaults to 1.
}}
}}


Navigation menu