woodstock 10 Posted May 14, 2013 I need to shut down all street lights and decorative lamps within a radius. Tried some old A2 scripts and they don't seem to work. Any of you code experts help me out? Linking to a named unit or trigger or logic point and then a specified distance would be ideal. Thanks! Woodstock Playin' on a Mac. Share this post Link to post Share on other sites
loyalguard 15 Posted May 14, 2013 I have not checked the latest dev builds, but at least in the stable branch, the switchLight command to turn off street lamps is not yet working in the Alpha. Once it does, my AEG - ArmA Electrical Grids Script Pack and Addon for ArmA 3 will help you accomplish that easily. In the meantime the only option is to use setDammage or hideObject to destroy or hide them. Share this post Link to post Share on other sites
woodstock 10 Posted May 14, 2013 Whats the syntax I need to do this, and where do I put it? Gamnelogic item? I've tried placing a gamelogic and using: objectnumber setdamage 1; Get an error. I'm new to this so some real specifics would help. Maybe something that sets damage to all decorativelamps or streetlights within a radius? Thanks Laoyal. Share this post Link to post Share on other sites
KevsNoTrev 44 Posted May 14, 2013 i think its nearestobjects id# setdamage 1; Share this post Link to post Share on other sites
woodstock 10 Posted May 14, 2013 (position this nearestobject 143871) setdammage 1; This works for one object at a time. How do I expand to to "any" object in a radius? Woodstock Share this post Link to post Share on other sites
KevsNoTrev 44 Posted May 14, 2013 i would say you would have ot build an array of all the lights in that radius and then use that array to 'turn off' the lights. [i]position [/i]nearObjects [i]radius [/i]or [[i]typeName[/i], [i]radius[/i]][/size] Can't find hte typename of light objects just yet, but this should help for a start. Share this post Link to post Share on other sites
mindstorm 8 Posted May 15, 2013 (edited) This will get all objects includings objects without a classname like lights, trees, rocks. It will then output their "readable name". it's a ID + name. You will have to filter it for the ones you need. _obj = _this select 0; _radius = _this select 1; _nearObjects = nearestObjects [_obj, [], _radius]; { _objName = format ["%1", _obj]; diag_log _objName; } forEach _nearObjects; You could use this function to look if the name equals one in a set of names: Fill the VAR_LIGHT_NAMES with all the streetlights you want to destroy (or turn of w/e). I did not test this, but it should work. VAR_LIGHT_NAMES = {"streelight1","streetlight2"}; FNC_IsStreetLight = { _obj = _this select 0; _objName = format ["%1", _obj]; _isStreetLight = false; { _streetlight = _x; if([_objName, _streetlight] call FNC_Find) then { _isStreetLight = true; }; } forEach VAR_LIGHT_NAMES; _isStreetLight; }; FNC_Find = { _haystack = _this select 0; _needle = _this select 1; _initialIndex = 0; private ["_haystackCount", "_needleCount", "_foundPos", "_needleIndex", "_doexit", "_notfound"]; if (typeName _haystack == "STRING") then { _haystack = toArray _haystack; }; if (typeName _needle == "STRING") then { _needle = toArray _needle; }; _haystackCount = count _haystack; _needleCount = count _needle; _foundPos = -1; if ((_haystackCount - _initialIndex) < _needleCount) exitWith {_foundPos}; _needleIndex = 0; _doexit = false; for "_i" from _initialIndex to (_haystackCount - 1) do { if (_haystack select _i == _needle select _needleIndex) then { if (_needleCount == 1) exitWith { _foundPos = _i; _doexit = true; }; if (_haystackCount - _i < _needleCount) exitWith {_doexit = true}; _needleIndex = _needleIndex + 1; _notfound = false; for "_j" from (_i + 1) to (_i + _needleCount - 1) do { if (_haystack select _j != _needle select _needleIndex) exitWith { _notfound = true; }; _needleIndex = _needleIndex + 1; }; if (_notfound) then { _needleIndex = 0; } else { _foundPos = _i; _doexit = true; }; }; if (_doexit) exitWith {}; }; _foundPos }; Edited May 15, 2013 by mindstorm Share this post Link to post Share on other sites