HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

[noob] counting arrays

01-03-2004, 05:11 PM#1
tanzania
For me as a expirienced php-programmer the triggers in worldeditor are quite familiar, my only problem ist that i sometimes don´t find the right trigger command equivalent.


So my question for now (might that there will be some follow-ups):

How to count the items in an array.

i have an array startpoint[0]=startpoint0, startpoint[1]=startpoint1 and so on now i wanted to do something like

for a=1 to count(startpoint)

But i can´t find it as a trigger, can someone please show me where to find a "count" function?

thx

tanzania
01-03-2004, 07:16 PM#2
Ligature
You'll have to make your own, I'm afraid. Keep an integer to record the number of members in the array you want to find the size of. That's the only way I've heard of anyone else doing it.

And good luck!
01-03-2004, 07:23 PM#3
tanzania
Thanks, and instantly the next question.

I want to let all allys share one hero, so i do:

Quote:
Player Group - Pick every player in (All allies of Player 1 (Red)) and do (Game - Grant shared vision and full shared unit control of Player 11 (Dark Green) units with his/her allies)


Thats working fine, but how can i disable the "Shared Resources" Board?

thx

tanzania
01-03-2004, 07:28 PM#4
Bulletcatcher
How about using
Code:
Player - Make Player 11 (Dark Green) treat (Picked Player) as an Ally with shared vision and shared units
instead? I believe that would work.
01-03-2004, 07:46 PM#5
Scarlet-Russian
you have to use an key index because (like in most languages) an array is a set amount of data, so even if you were to "count" it it would always come up with the same number. What you do to counteract this is just keep the max index of the array in [0]. For example:

name[0] = 3
name[1] = sarah
name[2] = jim
name[3] = mat

then you do for a = 1 to name[0] instead of count(name)
01-03-2004, 08:12 PM#6
AllPainful
Quote:
Originally posted by tanzania
Thanks, and instantly the next question.

I want to let all allys share one hero, so i do:



Thats working fine, but how can i disable the "Shared Resources" Board?

thx

tanzania



Disableing the shared resources board is easy.

Its a multiboard, so RIGHT after you make them an ally, put an action "Hide all multiboards" and poof, no more shared resources multiboard.

If you are using a multiboard in your map, then you will want to Unhide yours/create & show yours AFTER hiding the resources one, and if you do, make sure not to Unhide all multiboards, or the resources one will reappear.


Quote:
Originally posted by Bulletcatcher
How about using

Player - Make Player 11 (Dark Green) treat (Picked Player) as an Ally with shared vision and shared units

instead? I believe that would work.



It won't, ANY time you have Shared Units the "Allies Resources" multiboard shows up. Or at least I think so....