Home   Help Search Login Register  

Author Topic: combination of arrays  (Read 601 times)

0 Members and 1 Guest are viewing this topic.

mARV

  • Guest
combination of arrays
« on: 30 Dec 2003, 01:27:22 »
I am having trouble combining multiple arrays in to one larger array. I was trying to move four groups into an array, count the number of units in that array, then activate a trigger to be TRUE when the array count reaches 0. It works fine when i use only one group(variables _a and _aunits) and remove the rest from the script, but when i add more groups the combined array value always seems to equal 0.

this works:

_a = _this Select 0

#Here
_aunits = units _a

_bigarray = _aunits

_j = count _bigarray

~5
?_j>=1: goto "Here"

?_j<=0: Hint "Script works"
condition01 = True
~5
exit


but this doesn't:

_a = _this Select 0
_b = _this Select 1
_c = _this Select 2
_d = _this Select 3

#Here
_aunits = units _a
_bunits = units _b
_cunits = units _c
_dunits = units _d

_bigarray = [_aunits + _bunits + _cunits + _dunits]

_j = count _bigarray

~5
?_j>=1: goto "Here"

?_j<=0: Hint "Script works"
condition01 = True
~5
exit


maybe just a syntax error.....but a few seconds after i start the mission the trigger is activated by condition01 = true

also i want to use this as a generic script so if I had 4 variable and only wanted to use one group , would i execute it like this:

[wave1group,grpnull,grpnull,grpnull] exec "script.sqs"

???

when i try :

[wave1group] exec "script.sqs"

i get an error say that _b , _c , and _d expect a group or unit, not a number. i guess if i leave it blank it uses 0 .


Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:combination of arrays
« Reply #1 on: 30 Dec 2003, 01:40:52 »
I don't know the answer, but I'd put some more debug hints in there so you can see what's going on.    For example, use the format command in a hint to check that each variable is getting the correct value.

Do you need the square brackets [ ] when defining _bigarray?   The component parts are already arrays and you don't have [ ] in the working version.
Plenty of reviewed ArmA missions for you to play

mARV

  • Guest
Re:combination of arrays
« Reply #2 on: 30 Dec 2003, 01:52:28 »
you mean :

[_bigarray] = [_aunits + _bunits + _cunits + _dunits]


im not really sure what the correct syntax is. i read in the comref that they could be combined but it really didn't have a good example of the syntax. I'll try it.

how do i put a variable into a hint?

Hint "first group has ",_aunits," units."

do you know if thats the correct format to include a variable in the text?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:combination of arrays
« Reply #3 on: 30 Dec 2003, 01:56:21 »
I think what he meant was, do you need this:

_bigarray = [_aunits + _bunits + _cunits + _dunits]

when maybe the following would work:

_bigarray = _aunits + _bunits + _cunits + _dunits



Planck
I know a little about a lot, and a lot about a little.

mARV

  • Guest
Re:combination of arrays
« Reply #4 on: 30 Dec 2003, 02:08:07 »
i know i tried it as :

_bigarray = _aunits + _bunits + _cunits + _dunits

maybe i should try :

_bigarray = [_aunits] + [_bunits] + [_cunits] + [_dunits]

i only bad thing is that it takes sooooo looong to go through a mission just to debug it , over and over again... I hope I don't seem too stupid but I tried to get this to work last night for over four hours...

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:combination of arrays
« Reply #5 on: 30 Dec 2003, 02:21:13 »
How do you activate the script?


Planck
I know a little about a lot, and a lot about a little.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:combination of arrays
« Reply #6 on: 30 Dec 2003, 03:48:02 »
Quote
but this doesn't:

_a = _this Select 0
_b = _this Select 1
_c = _this Select 2
_d = _this Select 3

#Here
_aunits = units _a
_bunits = units _b
_cunits = units _c
_dunits = units _d

_bigarray = [_aunits + _bunits + _cunits + _dunits]

This doesn't work because you cannot add something to
an array, as long as you have not specified (initialized) the
array.

_bigarray = []
_bigarray = [_aunits + _bunits + _cunits + _dunits]

should work  ;)

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

mARV

  • Guest
Re:combination of arrays
« Reply #7 on: 30 Dec 2003, 05:58:17 »
ok thanks . I have to initialize it first... makes good sense..

guess thats why it passed all my comparing up and went straight to activating the trigger.
« Last Edit: 30 Dec 2003, 06:11:21 by mARV »

mARV

  • Guest
Re:combination of arrays
« Reply #8 on: 30 Dec 2003, 06:08:06 »
To activate a script I put :

Condition01 = False

in the init.sqs file that I created.

I think "Condition01" can be any global variable

I then created a trigger and in the condition field I typed:

Condition01


in my script I had :

Condition01 = True


that makes the condition of the trigger true. then whatever I have syncronized, to the trigger inside  the editor, will happen.
« Last Edit: 30 Dec 2003, 06:09:28 by mARV »

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:combination of arrays
« Reply #9 on: 30 Dec 2003, 10:34:36 »
lol mARV, you aren't being stupid.   This is the kind of thing that happens to me ALL the time.    (Or maybe it's just you and me .....)     Although you can knock something together in twenty minutes a really good mission takes several hundred hours of work.

Your last post is exactly right.
Plenty of reviewed ArmA missions for you to play

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re:combination of arrays
« Reply #10 on: 30 Dec 2003, 13:46:41 »
Quote
really good mission takes several hundred hours of work.

nd den wait til u get it on beta testin :P

it takes years (realy ::)) 2 finish 1 good mision - if u make it all nd den u need 2 get ppl beta testing it  ;D

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta