Dynamic arrays-like algorithms for ACS?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Ravick
Posts: 2046
Joined: Sun Aug 22, 2010 10:59 pm
Location: Tubarão, Brasil
Contact:

Dynamic arrays-like algorithms for ACS?

Post by Ravick »

Hi there,

so, I was looking at the wiki about arrays (I'm kinda noob at using arrays...), it seems that dinamic arrays are only avaible to ZScript, not to ACS.
Well, lets say, in a ACS script, if you have a pool os possibilities and need to pick up just a few of them, how'd you do that?
For example, you have 10 monsters in a map, and need to ramdonly choose 3 to use in a script. If I could use dinamic arrays, I could make an array of size 10, randomize monster's numbers from 0-9, pick the monster with the corresponding index number; And then, decrease the array size to 9 and choose betwen 0-8 monsters; and so on.

How'd you do that (avoinding kludges just like having bool vars to all the 10 monsters)?

Maybe this question is ridiculously noobish, but, as I said, I'm kinda noob at this arrays-in-ACS thing anyway.

Thanks in adavced. :)
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49225
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Dynamic arrays... for ACS?

Post by Graf Zahl »

Global arrays are dynamic, you can use any index you like to address them and they automatically resize if needed.
User avatar
Ravick
Posts: 2046
Joined: Sun Aug 22, 2010 10:59 pm
Location: Tubarão, Brasil
Contact:

Re: Dynamic arrays-like algorithms for ACS?

Post by Ravick »

Thanks, Graf! :)
Locked

Return to “Editing (Archive)”