Home   Help Search Login Register  

Author Topic: Addaction using a condition that monitors _x [SOLVED]  (Read 2393 times)

0 Members and 1 Guest are viewing this topic.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
I am trying to add a condition to an addaction that monitors _x, which in this case is a BIS artillery module

the condition is                      [_x] call BIS_ARTY_F_Available

which returns a boolean

when testing, this condition is known to be true, but the addaction will not display in the user action list.
When I remove this condition, the addaction displays correctly.
Thus the rest of the code is correct and the implementation of the _x condition is not seen as true

Any ideas how to implement this condition correctly ?

Code: [Select]
 _object = _this select 0;
  _caller = _this select 1;
  _myBatterys = [];
  _id = 0;
  _title = "";

  {if(side _caller == side (_x call BIS_ARTY_F_BatteryLead))then
{
_myBatterys = _myBatterys + [_x];
_title = format ["    Select %1", _x];
_batteryID = call compile format ["Tx_batteryID_%1",_id];

_id = _object addaction [_title,   Tx_ActionPath + "Arty\Arty01_selectBattery.sqf", _x , -20 , false , false , "" , "(  Tx_DisplayActions) && (alive _target) && (_target getvariable ""Tx_ArtyStage"" == 1)&&([_x] call BIS_ARTY_F_Available)"];

_id = _id + 1;
}
  }foreach BIS_ARTY_BATTERYCAT;
« Last Edit: 03 Oct 2009, 16:20:38 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline i0n0s

  • Moderator
  • *****
Re: Addaction using a condition that monitors _x
« Reply #1 on: 01 Oct 2009, 23:56:36 »
Use a simple for-iteration and save the iteration variable (mostly _i).
So you can use BIS_ARTY_BATTERYCAT select ... to get the battery.

And be aware that "_i" will be "_i" and not "0" or another number. Use str _i which will return "0".

Offline tcp

  • Members
  • *
    • Violator Gaming
Re: Addaction using a condition that monitors _x
« Reply #2 on: 03 Oct 2009, 06:00:24 »
The addAction is probably not parsed during creation, so _x will remain _x, which is meaningless outside the scope of the forEach loop.

You probably need to use call compile format on the line that creates the action.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re: Addaction using a condition that monitors _x
« Reply #3 on: 03 Oct 2009, 16:17:33 »
Thanks for the input guys

working solution, thanks to killswitch... and input from you guys

Code: [Select]

_object = _this select 0;
_caller = _this select 1;
_title = "";

_c=count BIS_ARTY_BATTERYCAT;

if (_c>0) then
{
for [{_i=0}, {_i<_c}, {_i=_i+1}] do
{
_battery = BIS_ARTY_BATTERYCAT select _i;

if (side _caller == side(_battery call BIS_ARTY_F_BatteryLead)) then
{
_title = format ["    Select %1", _battery];
_condition = format ["Tx_DisplayActions&&(alive _target)&&(_target getVariable'Tx_ArtyStage'==1)&&([BIS_ARTY_BATTERYCAT select %1] call BIS_ARTY_F_Available)", _i];
_actionID = _object addAction [_title, Tx_ActionPath + "Arty\Arty01_selectBattery.sqf", _battery , -20 , false , false , "" , _condition];
_ArtyActions = _object getVariable "Tx_ArtyActions";
_object setVariable ["Tx_ArtyActions",(_ArtyActions + [_actionID])];
};
};
};
« Last Edit: 03 Oct 2009, 16:19:37 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123