Page 1 of 1

list of TiD's passed to a script...

Posted: Thu Aug 04, 2016 1:13 pm
by DracoNoir
A bit unclear maybe on the title but basically what I want to do is make multiple lines or sectors change (all the same way) using one script, sort of like:

Code: Select all

setlineactivation([1,2,3,4,5,6,etc...], SPAC_None);
Can I do this with an array where the script pulls all values, or do I have to do:

Code: Select all

setlineactivation(1, SPAC_None);
setlineactivation(2, SPAC_None);
setlineactivation(3, SPAC_None);
setlineactivation(4, SPAC_None);
etc...?



I have no problem doing this (there'll be about 100 lines of code for what I want) but I'm just wondering if theres a tidier way of doing this?

thanks

EDIT:

If not, thinking about it, my tags in this instance are consecutive, so I suppose I could do something like:

Code: Select all

int LiD =1 ;
while (LiD<=20)
       {
            setlineactivation(LiD, SPAC_None);
            LiD ++;
       }
should work. An array solution would be handy though for non-consecutive TiD's...

Re: list of TiD's passed to a script...

Posted: Fri Aug 05, 2016 1:30 am
by Blue Shadow
Yes, an [wiki]array[/wiki] and a [wiki=Loops]for or while loops[/wiki] would be best.

Re: list of TiD's passed to a script...

Posted: Sat Aug 06, 2016 5:55 am
by DracoNoir
hmm ok, but how would you pass ALL elements of an array to the script? I mean, I suppose you would use a while loop to increment the array index, but I'm not exactly sure of the syntax (being very new to arrays in acs). Something like this to move all sector floors with the following tags to the same value:

Code: Select all

#include zcommon.acs

script 1 (void)
{
int arraySecID[20] = { 1, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 20, 22, 27, 28, 29, 31};
int SecIDindex
while (SecIDindex<=19)
   {
      move_floortovalue([SecIDindex], 2, 128, 0);
      SecIDindex ++;
   }
}
This is off the top of my head so apologies for any other syntax errors in there. I suppose this would refer to arraySecID? How would this work with multiple arrays? How would you tell the function to refer to the correct array?

Re: list of TiD's passed to a script...

Posted: Sat Aug 06, 2016 9:54 am
by arookas
You specify the array name, then the index in square brackets, like so:

Code: Select all

#include zcommon.acs

script 1 (void) {
  int sectortags[20] = { 1, 3, 4, 5, 7, 8, 9, 10, 12, 13, 14, 15, 16, 18, 20, 22, 27, 28, 29, 31 };
  for (int i = 0; i < 20; ++i) {
    Floor_MoveToValue(sectortags[i], 2, 128, 0);
  }
}

Re: list of TiD's passed to a script...

Posted: Sat Aug 06, 2016 1:18 pm
by DracoNoir
Ahh that makes sense! Thanks!