truerun 2 Posted April 26, 2022 Hey folks, so I need some help figuring out what I'm doing wrong here. I'm ultimately trying to make a switch that allows me to turn off and on lights, but specified lights, like light 1, 2, 3, and 4. more specifically I've been trying to use the transfer switch. I've been using this script: DistanceToReach = 300; this addAction [ "Turn Off", { params ["_target", "_caller", "_actionId", "_arguments"]; { [_x, "OFF"] remoteExec ["switchLight",0,true]; } forEach (nearestObjects [_caller, [], DistanceToReach]); light1 switchLight "OFF"; _target animateSource ["switchposition",1]; _target animateSource ["light",0]; _target setDamage 0; }, [], 1.5, true, true, "", "alive _target", 3, false, "", "" ]; this addAction [ "Turn On", { params ["_target", "_caller", "_actionId", "_arguments"]; { [_x, "ON"] remoteExec ["switchLight",0,true]; } forEach (nearestObjects [_caller, [], DistanceToReach]); Light1 switchlight "ON"; _target animateSource ["switchposition",-1]; _target animateSource ["light",1]; _target setDamage 0; }, [], 1.5, true, true, "", "!alive _target", 3, false, "", "" ]; What happens: when I plug in this script and test it out, it only turns off the light and I get no option to turn it on. what I want: for the light to be able to turn on and off. In addition only turn "light1" on and off then add more lights to that. please ask questions if you don't understand. Thanks. Share this post Link to post Share on other sites
pierremgi 4738 Posted April 26, 2022 _target setDamage 0.95; // (or 1, not tested) should work for the turn off addAction. Share this post Link to post Share on other sites
dreadedentity 278 Posted April 26, 2022 In your "Turn on" addAction you have the condition "!alive _target", but in the turn off action code you setDamage 0. You should setDamage 1 and then I think the light should be "dead" and the action will show Share this post Link to post Share on other sites
truerun 2 Posted April 26, 2022 I see, but when I set it to 0 it destroys the light which is not what I want because it falls over. im using the double light stand Share this post Link to post Share on other sites
Harzach 2505 Posted April 26, 2022 For just "Light1": this addAction [ "Turn Off", { params ["_target", "_caller", "_actionId", "_arguments"]; light1 switchLight "OFF"; _target animateSource ["switchposition",1]; _target animateSource ["light",1]; }, [], 1.5, true, true, "", "lightIsOn light1 == 'ON'", 3, false, "", "" ]; this addAction [ "Turn On", { params ["_target", "_caller", "_actionId", "_arguments"]; Light1 switchlight "ON"; _target animateSource ["switchposition",-1]; _target animateSource ["light",0]; }, [], 1.5, true, true, "", "lightIsOn light1 == 'OFF'", 3, false, "", "" ]; Pretty sure the lights on the box itself (red and green indicators) are accessed via "switchLight" and not "light," but I can only get the red one to turn on. Share this post Link to post Share on other sites
Larrow 2797 Posted April 27, 2022 19 hours ago, truerun said: im using the double light stand What lights? Portable lighs double (Land_PortableLight_double_F) or the rugged ones ie Land_PortableLight_02_double_black_F. Spoiler this setVariable[ "LightActionID", this addAction[ "Light Off", { params [ "_target", "_caller", "_id", "_args" ]; _objectName = if ( vehicleVarName _target == "" ) then { _target call BIS_fnc_objectVar; }; _info = if ( lightIsOn _target == "ON" ) then { [ "OFF", "Light On" ] }else{ [ "ON", "Light Off" ] }; _info params[ "_switch", "_text" ]; [ _target, _switch ] remoteExec[ "switchLight", 0, format[ "%1_lightState", _objectName ] ]; [ [ _target, _text ], { params[ "_target", "_text" ]; _target setUserActionText[ _target getVariable "LightActionID", _text ] } ] remoteExec[ "BIS_fnc_call", 0, format[ "%1_actionState", _objectName ] ]; }, [], 1, true, false ] ]; 1 Share this post Link to post Share on other sites
truerun 2 Posted April 27, 2022 yeah the portable lights double (Land_PortableLight_double_F). So what im trying to achieve is to have the switch turn on the double portable lights and off simple on and off switch for them specifically Share this post Link to post Share on other sites
truerun 2 Posted April 27, 2022 2 hours ago, Larrow said: What lights? Portable lighs double (Land_PortableLight_double_F) or the rugged ones ie Land_PortableLight_02_double_black_F. Reveal hidden contents this setVariable[ "LightActionID", this addAction[ "Light Off", { params [ "_target", "_caller", "_id", "_args" ]; _objectName = if ( vehicleVarName _target == "" ) then { _target call BIS_fnc_objectVar; }; _info = if ( lightIsOn _target == "ON" ) then { [ "OFF", "Light On" ] }else{ [ "ON", "Light Off" ] }; _info params[ "_switch", "_text" ]; [ _target, _switch ] remoteExec[ "switchLight", 0, format[ "%1_lightState", _objectName ] ]; [ [ _target, _text ], { params[ "_target", "_text" ]; _target setUserActionText[ _target getVariable "LightActionID", _text ] } ] remoteExec[ "BIS_fnc_call", 0, format[ "%1_actionState", _objectName ] ]; }, [], 1, true, false ] ]; yeah the portable lights double (Land_PortableLight_double_F). So what im trying to achieve is to have the switch turn on the double portable lights and off simple on and off switch for them specifically, sorry im new to using this form and scripting in general lol. Share this post Link to post Share on other sites
Larrow 2797 Posted April 28, 2022 Something like this? Example_Mission Spoiler /***** ****** Original file: switchLights.sqf Written by Larrow Thursday, 28 April 2022 Originally posted @: https://forums.bohemia.net/forums/topic/238442-how-do-i-use-the-transfer-switch/ ****** Description: MP compatible script used on a gamelogic that has a Land_TransferSwitch_01_F and any number of Land_PortableLight_double_F synchronised to it. Applies action to switch to operate the lights. Designed as is to be placed in the gameLogics init. ****** ****** ******/ _objs = synchronizedObjects this; _switch = _objs select{ _x isKindOf "Land_TransferSwitch_01_F" } select 0; _lights = _objs select{ _x isKindOf "Land_PortableLight_double_F" }; TAG_fnc_lightsState = { params[ "_lights", "_lightState" ]; { _x switchLight _lightState; }forEach _lights; }; _switch setVariable[ "LightActionID", _switch addAction[ "Light Off", { params [ "_target", "_caller", "_id", "_args" ]; _args params[ "_lights" ]; _info = if ( _target animationSourcePhase "SwitchPosition" == 0 ) then { [ "OFF", "Light On", 1, 0 ] }else{ [ "ON", "Light Off", 0, 1 ] }; _info params[ "_lightState", "_actionText", "_switchPosition", "_switchLight" ]; _target animateSource[ "SwitchPosition", _switchPosition ]; _target animateSource[ "SwitchLight", _switchLight ]; [ [ _target, _actionText ], { params[ "_target", "_actionText" ]; _target setUserActionText[ _target getVariable "LightActionID", _actionText ] } ] remoteExec[ "BIS_fnc_call", 0, format[ "%1_actionState", _target call BIS_fnc_objectVar ] ]; [ _lights, _lightState ] remoteExec[ "TAG_fnc_lightsState", 0, format[ "%1_lightState", _target call BIS_fnc_objectVar ] ]; }, [ _lights ], 1, true, false ] ]; 3 Share this post Link to post Share on other sites
truerun 2 Posted April 28, 2022 4 hours ago, Larrow said: Something like this? Example_Mission Reveal hidden contents /***** ****** Original file: switchLights.sqf Written by Larrow Thursday, 28 April 2022 Originally posted @: https://forums.bohemia.net/forums/topic/238442-how-do-i-use-the-transfer-switch/ ****** Description: MP compatible script used on a gamelogic that has a Land_TransferSwitch_01_F and any number of Land_PortableLight_double_F synchronised to it. Applies action to switch to operate the lights. Designed as is to be placed in the gameLogics init. ****** ****** ******/ _objs = synchronizedObjects this; _switch = _objs select{ _x isKindOf "Land_TransferSwitch_01_F" } select 0; _lights = _objs select{ _x isKindOf "Land_PortableLight_double_F" }; TAG_fnc_lightsState = { params[ "_lights", "_lightState" ]; { _x switchLight _lightState; }forEach _lights; }; _switch setVariable[ "LightActionID", _switch addAction[ "Light Off", { params [ "_target", "_caller", "_id", "_args" ]; _args params[ "_lights" ]; _info = if ( _target animationSourcePhase "SwitchPosition" == 0 ) then { [ "OFF", "Light On", 1, 0 ] }else{ [ "ON", "Light Off", 0, 1 ] }; _info params[ "_lightState", "_actionText", "_switchPosition", "_switchLight" ]; _target animateSource[ "SwitchPosition", _switchPosition ]; _target animateSource[ "SwitchLight", _switchLight ]; [ [ _target, _actionText ], { params[ "_target", "_actionText" ]; _target setUserActionText[ _target getVariable "LightActionID", _actionText ] } ] remoteExec[ "BIS_fnc_call", 0, format[ "%1_actionState", _target call BIS_fnc_objectVar ] ]; [ _lights, _lightState ] remoteExec[ "TAG_fnc_lightsState", 0, format[ "%1_lightState", _target call BIS_fnc_objectVar ] ]; }, [ _lights ], 1, true, false ] ]; This is great. It worked like I wanted it to, what do you mean by look at game logic, I dont know how to see the game logic. Share this post Link to post Share on other sites
major-stiffy 269 Posted April 28, 2022 I think he means there is a module in the editor called gameLogic. The logic has an init field where code can be placed. Someone else should confirm. Share this post Link to post Share on other sites
Harzach 2505 Posted April 28, 2022 21 minutes ago, major-stiffy said: I think he means there is a module in the editor called gameLogic. The logic has an init field where code can be placed. Someone else should confirm. Yes, it is essentially an "empty" module. It's kind of a relic from the old days, but it still has its uses. Share this post Link to post Share on other sites
Larrow 2797 Posted April 29, 2022 16 hours ago, truerun said: what do you mean by look at game logic, I dont know how to see the game logic. This is a gameLogic... ... the white flag on a blue background. Double click on it to open it like any other entity and you will see it has an init area for code. You can find them in the editor under Systems(F5) > Logic Entities > Objects. Some info 16 hours ago, Harzach said: Yes, it is essentially an "empty" module. It's kind of a relic from the old days, Meh relic is a little disingenuous, makes it sound like they are deprecated. TBH I'd describe it differently saying, a module is a gameLogic that automatically runs predefined code. Modules inherit from Logic the configName for a gameLogic. pedantic but true 😄 2 1 Share this post Link to post Share on other sites
Harzach 2505 Posted April 29, 2022 3 hours ago, Larrow said: Meh relic is a little disingenuous How DARE you, sir! I did qualify it with "kind of"... 2 Share this post Link to post Share on other sites
truerun 2 Posted April 30, 2022 On 4/29/2022 at 7:36 AM, Larrow said: This is a gameLogic... ... the white flag on a blue background. Double click on it to open it like any other entity and you will see it has an init area for code. You can find them in the editor under Systems(F5) > Logic Entities > Objects. Some info Meh relic is a little disingenuous, makes it sound like they are deprecated. TBH I'd describe it differently saying, a module is a gameLogic that automatically runs predefined code. Modules inherit from Logic the configName for a gameLogic. pedantic but true 😄 Thanks for the help dude. 2 Share this post Link to post Share on other sites