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.

Dynamic arrays-like algorithms for ACS?

Postby Ravick » Sun Sep 03, 2017 12:35 am

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
Ravick
Do what thou wilt, since you don't bug the hell out of me!
 
Joined: 22 Aug 2010
Location: Tubarão, Brasil

Re: Dynamic arrays... for ACS?

Postby Graf Zahl » Sun Sep 03, 2017 12:39 am

Global arrays are dynamic, you can use any index you like to address them and they automatically resize if needed.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Dynamic arrays-like algorithms for ACS?

Postby Ravick » Sun Sep 03, 2017 1:43 am

Thanks, Graf! :)
User avatar
Ravick
Do what thou wilt, since you don't bug the hell out of me!
 
Joined: 22 Aug 2010
Location: Tubarão, Brasil


Return to Editing (Archive)

Who is online

Users browsing this forum: No registered users and 1 guest