BIS fnc switchLamp: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (missing bracket in example)
m (Fix category, description and example)
Line 14: Line 14:
____________________________________________________________________________________________
____________________________________________________________________________________________


| [_object, _state] [[call]] '''BIS_fnc_switchLamp'''; |= Syntax
| [object, state] call [[BIS_fnc_switchLamp]] |= Syntax


| [[Nothing]] |= RETURNVALUE
| [[Nothing]] |= Return value


|p1= [[Object]] - Street Lamp |= Parameter 1
|p1= object: [[Object]] - Street Lamp |= Parameter 1


|p2= [[Bool]] - State: True to turn lamp on, false to turn it off|= Parameter 2
|p2= state: [[Bool]] - true to turn lamp on, false to turn it off |= Parameter 2


____________________________________________________________________________________________
____________________________________________________________________________________________


|x1= <code>
|x1= <code>{{codecomment|// Switches all lamps off in a radius of 200m}}
{  
[[private]] _lampsIn200m = [[nearestObjects]] <nowiki>[</nowiki>[[player]], ["Lamps_base_F", "PowerLines_base_F", "PowerLines_Small_base_F"], 200];
      [_x,[[true]]] call '''BIS_fnc_switchLamp''';
{ [_x, [[false]]] [[call]] [[BIS_fnc_switchLamp]]; } forEach _lampsIn200m;</code> |= Example 1
      [[false]];
} [[count]] [[nearestObjects]] [ [[player]],["Lamps_base_F","PowerLines_base_F","PowerLines_Small_base_F"],200]
</code> |= Example 1


 
|x2= <code>{{codecomment|// Simulates a damaged street light}}
|x1= <code>
aLamp [[spawn]] {
{  
[[private]] _lamp = [[param]] [0, [[objNull]], <nowiki>[</nowiki>[[objNull]]]];
      [_x,[[false]]] call '''BIS_fnc_switchLamp''';
[[while]] { [[player]] [[distance]] _lamp < 200; } [[do]]
      [[false]];
} [[count]] [[nearestObjects]] [ [[player]],["Lamps_base_F","PowerLines_base_F","PowerLines_Small_base_F"],200];//Switches all lamps in a radius of 200 off
</code> |= Example 1
 
|x2= <code>
[[spawn]] {
private _lamp = [[param]] [0, [[objNull]],[ [[objNull]] ]];
[[while]] {[[player]] [[distance]] _lamp < 200} [[do]]
{
{
[_lamp, [[selectRandom]] [ [[true]], [[false]] ]] [[call]] '''BIS_fnc_switchLamp''';
[_lamp, [[selectRandom]] [ [[true]], [[false]] ]] [[call]] [[BIS_fnc_switchLamp]];
[[sleep]] 0.1 + [[random]] 0.5;
[[sleep]] 0.1 + [[random]] 0.5;
};//Simulates a damaged street light
};
};
};</code> |= Example 2
</code> |= Example 2
____________________________________________________________________________________________
____________________________________________________________________________________________


| SEEALSO |= See Also
| |= See Also
 
}}
}}


<dl class="command_description">
<dl class="command_description">
<!-- BEGIN Note Section -->
<!-- BEGIN Note Section -->
<!-- For example:
 
<dd class="notedate">Posted on Month Day, Year - Time (UTC)</dd>
<dt class="note">'''[[User:User Name|User Name]]'''</dt>
<dd class="note">This is an example note. It is true and verifiable, and contains a little code snippet.
<code>[[if]] ([[_this]] == anExample) [[then]] { [[hint]] "Leave it here for others to read"; };</code></dd>
-->
<!-- END Note Section -->
<!-- END Note Section -->
</dl>
</dl>


<h3 style="display:none">Bottom Section</h3>
<h3 style="display:none">Bottom Section</h3>
<!-- Appropriate categories go here -->
[[Category:Arma 3: Functions|{{uc:switchLamp}}]]
[[Category:Arma 3: Functions|{{uc:{{PAGENAME}}}}]]

Revision as of 19:38, 21 April 2018

Hover & click on the images for description

Description

Description:
Switch streetlamp on/off
Execution:
call
Groups:
Uncategorised

Syntax

Syntax:
[object, state] call BIS_fnc_switchLamp
Parameters:
object: Object - Street Lamp
state: Bool - true to turn lamp on, false to turn it off
Return Value:
Nothing

Examples

Example 1:
// Switches all lamps off in a radius of 200m private _lampsIn200m = nearestObjects [player, ["Lamps_base_F", "PowerLines_base_F", "PowerLines_Small_base_F"], 200]; { [_x, false] call BIS_fnc_switchLamp; } forEach _lampsIn200m;
Example 2:
// Simulates a damaged street light aLamp spawn { private _lamp = param [0, objNull, [objNull]]; while { player distance _lamp < 200; } do { [_lamp, selectRandom [ true, false ]] call BIS_fnc_switchLamp; sleep 0.1 + random 0.5; }; };

Additional Information

See also:
See also needed

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

Bottom Section