Home   Help Search Login Register  

Author Topic: Using a radio trigger as a switch on/switch off  (Read 1511 times)

0 Members and 1 Guest are viewing this topic.

Offline Rasa

  • Members
  • *
Using a radio trigger as a switch on/switch off
« 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

Code: [Select]
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

Code: [Select]
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 ];  "
« Last Edit: 19 Oct 2009, 20:09:20 by Rasa »

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Using a radio trigger as a switch on/switch off
« Reply #1 on: 19 Oct 2009, 21:15:14 »
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";

Code: (tglhgt.sqf) [Select]
_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;
};
« Last Edit: 19 Oct 2009, 23:56:58 by tcp »

Offline Rasa

  • Members
  • *
Re: Using a radio trigger as a switch on/switch off
« Reply #2 on: 19 Oct 2009, 22:12:48 »
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.

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Using a radio trigger as a switch on/switch off
« Reply #3 on: 19 Oct 2009, 22:44:23 »
Oops edited the code above. The second forEach loop should have _fro instead of _to.

Offline Rasa

  • Members
  • *
Re: Using a radio trigger as a switch on/switch off
« Reply #4 on: 19 Oct 2009, 23:09:29 »
still no luck

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Using a radio trigger as a switch on/switch off
« Reply #5 on: 19 Oct 2009, 23:50:06 »
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.
« Last Edit: 19 Oct 2009, 23:56:35 by tcp »

Offline Rasa

  • Members
  • *
Re: Using a radio trigger as a switch on/switch off
« Reply #6 on: 20 Oct 2009, 00:24:46 »
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

Code: [Select]
RAS_Clist = [Atgt1,Atgt2,Atgt3,Atgt4,Atgt5,Atgt6,Atgt7]; _tglhgt = [RAS_Clist, 5] execVM "tglhgt.sqf";
Code: [Select]
RAS_Clist = [Gtgt1,Gtgt2,Gtgt3,Gtgt4,Gtgt5,Gtgt6,Gtgt7]; _tglhgt = [RAS_Clist, 5] execVM "tglhgt.sqf";
While this one buries them correctly

Code: [Select]
RAS_Clist = [Btgt1,Btgt2,Btgt3,Btgt4,Btgt5,Btgt6,Btgt7]; _tglhgt = [RAS_Clist, 5] execVM "tglhgt.sqf";
« Last Edit: 20 Oct 2009, 19:16:29 by Rasa »

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Using a radio trigger as a switch on/switch off
« Reply #7 on: 21 Oct 2009, 01:54:41 »
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.