Home   Help Search Login Register  

Author Topic: ? passing variables to an addaction  (Read 759 times)

0 Members and 1 Guest are viewing this topic.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
? passing variables to an addaction
« on: 22 Mar 2004, 18:05:49 »


i want a line like this

((((tx_AllG_towns select _Gno)select _Tno)select 0) addaction ["take Flag","takeflag.sqs"])

to also pass the variables

_Gno  and _Tno  onto the "takeflag.sqs"
so i can use them to call upon another element in the same subarray

how do i do it

eg
[_Gno,_Tno] exec "takeflag.sqs"


Thx in advance
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:? passing variables to an addaction
« Reply #1 on: 22 Mar 2004, 18:17:30 »
I'm under the impression that you can't pass variables via addaction. The only way would be to hop the execution through another script, which passes the variables.
Not all is lost.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:? passing variables to an addaction
« Reply #2 on: 22 Mar 2004, 18:57:07 »
the problem i have is

The _Gno is the garrison number which the town is controlled by
_Tno is the actual town within the garrison

There are several garrisons and for each there are several towns

what i need to do is have an enemy soldier that has defeated the town, change the flag within that town, and in doing so set a boolean that is in the towns array to true

so at the moment i am using a looping script that
counts the number of garrisons,
counts the number of towns per garrison
and then for each town in turn sets the flagtexture and gives that specific flag an addaction
The script that the addaction then runs, will remove the action from that specific flag and set the towns "Towntaken" boolean to true
which will allow another looping script that is monitoring all the towns, to skip monitoring the "Taken" town

so any ideas


INIT.sqs
Quote
;;;###___ Garrison help booleans ___ ###;;;
tx_Gbools = [G1_Help,G2_Help,G3_Help,G4_Help]

;;;###___ Garrison 1 elements ___ ###;;;
;;;<<< Town 1 >>> ;;;
tx_G1T1_mg = [G1T1_mg1,G1T1_mg2,G1T1_mg3,G1T1_mg4]
tx_G1T1_d   = [G1T1_d1,G1T1_d2,G1T1_d3,G1T1_d4]
tx_G1T1_p   = [G1T1_p1,G1T1_p2,G1T1_p3,G1T1_p4]
tx_G1T1      = [G1T1_Flag,tx_Gbools,G1T1_attack,G1T1_taken,tx_G1T1_mg,tx_G1T1_d,tx_G1T1_p]

;;;<<< Town 2 >>> ;;;
tx_G1T2_mg = [G1T2_mg1,G1T2_mg2,G1T2_mg3,G1T2_mg4]
tx_G1T2_d   = [G1T2_d1,G1T2_d2,G1T2_d3,G1T2_d4]
tx_G1T2_p   = [G1T2_p1,G1T2_p2,G1T2_p3,G1T2_p4]
tx_G1T2      = [G1T2_Flag,tx_Gbools,G1T2_attack,G1T2_taken,tx_G1T2_mg,tx_G1T2_d,tx_G1T2_p]

;;;<<< Town 3 >>> ;;;
tx_G1T3_mg = [G1T3_mg1,G1T3_mg2,G1T3_mg3,G1T3_mg4]
tx_G1T3_d   = [G1T3_d1,G1T3_d2,G1T3_d3,G1T3_d4]
tx_G1T3_p   = [G1T3_p1,G1T3_p2,G1T3_p3,G1T3_p4]
tx_G1T3      = [G1T3_Flag,tx_Gbools,G1T3_attack,G1T3_taken,tx_G1T3_mg,tx_G1T3_d,tx_G1T3_p]

;;;<<< Town 4 >>> ;;;
tx_G1T4_mg = [G1T4_mg1,G1T4_mg2,G1T4_mg3,G1T4_mg4]
tx_G1T4_d   = [G1T4_d1,G1T4_d2,G1T4_d3,G1T4_d4]
tx_G1T4_p   = [G1T4_p1,G1T4_p2,G1T4_p3,G1T4_p4]
tx_G1T4      = [G1T4_Flag,tx_Gbools,G1T4_attack,G1T4_taken,tx_G1T4_mg,tx_G1T4_d,tx_G1T4_p]

;;;<<< Garrison1 HQ >>> ;;;
tx_G1 = [tx_G1T1,tx_G1T2,tx_G1T3,tx_G1T4]

;;;###___ MISC ARRAYS ___ ###;;;
tx_AllG_towns = [tx_G1]

[]exec "aiControl\town_monitor.sqs"
[]exec "setupflag.sqs"
exit

SETUPFLAGS.sqs
Quote
~ random 5
;;Sets all the flags up for all the towns in all the garrisons
?! (local server): exit

~ random 5
#START
_GNo = 0
_Gcount = count (tx_AllG_Towns)
_TNo = 0
goto "G_Loop"

#G_Start
_GNo = _GNo + 1
#G_Loop
? (_GNo >= _Gcount): _GNo = 0; goto "END"
goto "T_Loop"

#T_Start
_TNo = _TNo + 1
#T_Loop
_Tcount = count (tx_AllG_Towns select _GNo)
? (_TNo >= _Tcount): _TNo = 0; goto "G_Start"
goto "TOWNcheck"

#TOWNcheck
hint format ["_Gno = %1 .......... _Tno = %2\n\n_Gcount = %3 .........._Tcount = %4",_Gno,_Tno,_Gcount,_Tcount]
~1
((((tx_AllG_towns select _Gno)select _Tno)select 0) setflagtexture "rus_vlajka.pac")
Gno = _Gno
Tno = _Tno
((((tx_AllG_towns select _Gno)select _Tno)select 0) addaction ["take Flag","takeflag.sqs")])
goto "T_Start"

#END
hint "At End flagsetup"
Exit

and the addaction script that i need to pass the location of the flag "element" in its array is

TAKEFLAG.sqs
Quote
_Gno = this select 0
_Tno = this select 1

~3
((((tx_AllG_towns select _Gno)select _Tno)select 0) setflagtexture "usa_vlajka.pac" )
((((tx_AllG_towns select _Gno)select _Tno)select 0) setflagside WEST)
((((tx_AllG_towns select _Gno)select _Tno)select 0) removeaction 0)
(((tx_AllG_towns select _Gno)select _Tno) set [3,true])
hint "Removed action"
exit


am stuck with assigning the correct select %




« Last Edit: 22 Mar 2004, 19:05:54 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Igor Drukov

  • Contributing Member
  • **
  • Conscientious Subjector
Re:? passing variables to an addaction
« Reply #3 on: 22 Mar 2004, 19:52:24 »
I agree with Artak, AFAIK you can't pass local variables via "AddAction".

But a work-around could be to use global variables.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:? passing variables to an addaction
« Reply #4 on: 22 Mar 2004, 20:26:58 »
if i used
Gno = _Gno
 and
Tno = _Tno



then all the flags that had the addaction would simply update one specific array, not their array, or rather their town info

(((tx_allGtowns select Gno)select Tno) select 3)
and
Gno = 0
if Tno = 2

it would update the array
(((tx_allGtowns select 0)select 2) set [3,true])
which is tx_G1T3
(Town 3 in Garrison 1)

i need the system to update the array, that the specific flag is from

otherwise if i took towns A, B or C, it would also state that i actually took X every time
« Last Edit: 22 Mar 2004, 20:27:34 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline MI_Fred

  • Members
  • *
  • AA
    • OFP Team Finlanders
Re:? passing variables to an addaction
« Reply #5 on: 22 Mar 2004, 21:29:18 »
I wouldn't go with actions, as they defeat the idea of making variables public. But if you go with it, I suggest you check who is close to what flagpole in an array. That atleast is very possible.
There's gooks over there, there's mines over there, and watch out those goddamn monkeys talk, I'll bite ya.

Don_T_Shoot

  • Guest
Re:? passing variables to an addaction
« Reply #6 on: 22 Mar 2004, 21:39:14 »
This problem may be beyond my limited understanding but here it  goes.  

Actions pass two varaibles that I know of,  the unit with the action (_this select 0) and the unit initiating the action (_this select 1).

You might be able to check the side or garrison of the initiating unit and then do some fancy scripting to figure out what town the unit with the action (in this case the flag?) is located.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:? passing variables to an addaction
« Reply #7 on: 23 Mar 2004, 15:49:07 »
Problem solved, thanks to Killswitch.

I simply needed to have the takeflag.sqs search through all the garrison town arrays until it found the array flag to be equal to the addaction script, _this select 0

eg
Addaction script, Takeflag.sqs
Quote
;;checks  all the flags for all the towns in all the garrisons to see which one is running the addaction take flag
;;and then does stuff to the flag
?! (local server): exit
_Flag = _this select 0
_unit = _this select 1
_ID = _this select 2
~ 3
#START
_GNo = 0
_Gcount = count (tx_AllG_Towns)
_TNo = 0
goto "G_Loop"

#G_Start
~0.1
_GNo = _GNo + 1
#G_Loop
? (_GNo >= _Gcount):  goto "NOTFOUND"
goto "T_Loop"

#T_Start
~0.1
_TNo = _TNo + 1
#T_Loop
_Tcount = count (tx_AllG_Towns select _GNo)
? (_TNo >= _Tcount): _TNo = 0; goto "G_Start"
goto "TOWNcheck"

#TOWNCHECK
_TFlag =(((tx_AllG_towns select _Gno)select _Tno)select 0)
? (_Tflag == _Flag): hint "Found flag"; goto "FOUND"


#FOUND
((((tx_AllG_towns select _Gno)select _Tno)select 0) setflagtexture "usa_vlajka.pac" )
;;((((tx_AllG_towns select _Gno)select _Tno)select 0) setflagside WEST)
((((tx_AllG_towns select _Gno)select _Tno)select 0) removeaction _ID)
(((tx_AllG_towns select _Gno)select _Tno) set [3,true])
goto "END"



#NOTFOUND
hint "Addaction Takeflag _flag Not Found"
#END
exit
« Last Edit: 23 Mar 2004, 15:49:26 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123