OFPEC Forum
Editors Depot - Mission Editing and Scripting => Arma2 - Editing/Scripting General => Topic started by: Rasa on 19 Oct 2009, 18:33:03
-
Is it possible to make is so that one Radio trigger can change function as it is pressed?
I'm making a mission that has 5 sets of targets. I'd like a way that puts them on the map (height 0), and below it (-5). The problem is, there are only 8 radio buttons, which is 4 at 0 height, and 4 at -5)
I'd like to have a Radio button that does
Ctgt1 setpos [getPos Ctgt1 select 0, getPos Ctgt1 select 1, 0 ]; Ctgt2 setpos [getPos Ctgt2 select 0, getPos Ctgt2 select 1, 0 ]; Ctgt3 setpos [getPos Ctgt3 select 0, getPos Ctgt3 select 1, 0 ]; Ctgt4 setpos [getPos Ctgt4 select 0, getPos Ctgt4 select 1, 0 ]; Ctgt5 setpos [getPos Ctgt5 select 0, getPos Ctgt5 select 1, 0 ]; Ctgt6 setpos [getPos Ctgt6 select 0, getPos Ctgt6 select 1, 0 ]; Ctgt7 setpos [getPos Ctgt7 select 0, getPos Ctgt7 select 1, 0 ]; ";
And when it does that, the next time you press it, it does
Ctgt1 setpos [getPos Ctgt1 select 0, getPos Ctgt1 select 1, -5 ]; Ctgt2 setpos [getPos Ctgt2 select 0, getPos Ctgt2 select 1, -5 ]; Ctgt3 setpos [getPos Ctgt3 select 0, getPos Ctgt3 select 1, -5 ]; Ctgt4 setpos [getPos Ctgt4 select 0, getPos Ctgt4 select 1, -5 ]; Ctgt5 setpos [getPos Ctgt5 select 0, getPos Ctgt5 select 1, -5 ]; Ctgt6 setpos [getPos Ctgt6 select 0, getPos Ctgt6 select 1, -5 ]; Ctgt7 setpos [getPos Ctgt7 select 0, getPos Ctgt7 select 1, -5 ]; "
-
Trigger: Activation Radio, Repeatable, Text: Toggle Height
On Act:
RAS_Clist = [Ctgt1,Ctgt2,Ctgt3,Ctgt4,Ctgt5,Ctgt6,Ctgt7]; _tglhgt = [RAS_Clist, 5] execVM "tglhgt.sqf";
_list = _this select 0;
_hgt = _this select 1;
if(((getPosATL(_list select 0)) select 2) > 0) then {
{_x setPos [(getPos _x) select 0,(getPos _x) select 1,(((getPos _x) select 2) - _hgt)];} forEach _list;
} else {
{_x setPos [(getPos _x) select 0,(getPos _x) select 1,(((getPos _x) select 2) + _hgt)];} forEach _list;
};
-
thx for your effort, but something isn't functioning. Using the radio button, the target gets removed. But once removed, the button doesn't put the target back.
-
Oops edited the code above. The second forEach loop should have _fro instead of _to.
-
still no luck
-
Must be a issue with setPos, trying to get setPosATL working.
OK, I tested it and it works, height must have been out of range after my script changed it.
Updated above, including trigger On Act.
-
That works, thx a lot.
This will make for a great training tool.
***Edit***
Any ideas why on 4/6 target series this works, but for 2/6 it sets the targets 5m into the air?
These lines set em 5 high
RAS_Clist = [Atgt1,Atgt2,Atgt3,Atgt4,Atgt5,Atgt6,Atgt7]; _tglhgt = [RAS_Clist, 5] execVM "tglhgt.sqf";
RAS_Clist = [Gtgt1,Gtgt2,Gtgt3,Gtgt4,Gtgt5,Gtgt6,Gtgt7]; _tglhgt = [RAS_Clist, 5] execVM "tglhgt.sqf";
While this one buries them correctly
RAS_Clist = [Btgt1,Btgt2,Btgt3,Btgt4,Btgt5,Btgt6,Btgt7]; _tglhgt = [RAS_Clist, 5] execVM "tglhgt.sqf";
-
Change this line:
if(((getPosATL(_list select 0)) select 2) > 0) then {
To:
if(((getPosATL(_list select 0)) select 2) >= 0) then {
Or if that doesn't work:
if(((getPosATL(_list select 0)) select 2) <= ((getPos(_list select 0)) select 2)) then {
If was probably due to the fact that the target was exactly 0 meters high, which is something I overlooked earlier.