BIS fnc switchLamp: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\{\{ *cc*\| *([^}]+) *\}\}" to "// $1")
m (Text replacement - "(\|[pr][0-9]+ *= *[^-\r\n]+) *- *S([a-z])" to "$1 - s$2")
 
(One intermediate revision by the same user not shown)
Line 14: Line 14:
|r1= [[Nothing]]
|r1= [[Nothing]]


|p1= object: [[Object]] - Street Lamp
|p1= object: [[Object]] - street Lamp


|p2= state: [[Boolean]] - true to turn lamp on, false to turn it off
|p2= state: [[Boolean]] - true to turn lamp on, false to turn it off


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


|x2= <code>// simulates a damaged street light
|x2= <sqf>
aLamp [[spawn]] {
// simulates a damaged street light
[[private]] _lamp = [[param]] [0, [[objNull]], [<nowiki/>[[objNull]]]];
aLamp spawn {
[[while]] { [[player]] [[distance]] _lamp < 200; } [[do]]
params [
["_lamp", objNull, [objNull]]
];
while { player distance _lamp < 200 } do
{
{
[_lamp, [[selectRandom]] [<nowiki/>[[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;
};
};
};</code>
};
</sqf>


|seealso= [[switchLight]]
|seealso= [[switchLight]]
}}
}}

Latest revision as of 14:44, 8 November 2023

Hover & click on the images for description

Description

Description:
Switch streetlamp on/off.
Execution:
call
Groups:
Object Manipulation

Syntax

Syntax:
[object, state] call BIS_fnc_switchLamp
Parameters:
object: Object - street Lamp
state: Boolean - 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 { params [ ["_lamp", 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:
switchLight

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