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

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
DracoNoir
Posts: 46
Joined: Wed Oct 28, 2015 4:45 pm
Location: UK

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

Post 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...
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

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

Post by Blue Shadow »

Yes, an [wiki]array[/wiki] and a [wiki=Loops]for or while loops[/wiki] would be best.
User avatar
DracoNoir
Posts: 46
Joined: Wed Oct 28, 2015 4:45 pm
Location: UK

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

Post 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?
User avatar
arookas
Posts: 265
Joined: Mon Jan 24, 2011 6:04 pm
Contact:

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

Post 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);
  }
}
User avatar
DracoNoir
Posts: 46
Joined: Wed Oct 28, 2015 4:45 pm
Location: UK

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

Post by DracoNoir »

Ahh that makes sense! Thanks!
Locked

Return to “Editing (Archive)”