Epyo Posted March 13, 2004 script 802 OPEN { int sector; sector++; Ceiling_LowerInstant(i: sector,s: 0, 304); delay(10); restart; }If you can't figure out what I'm trying to do, it's supposed to lower the ceiling of sector tag 1, then 2, then 3, then 4, and so on and so on. But I can't really figure out how to put the "sector" into the action. I know how to do it with hudmessages, but it doesn't seem to work the same with this. 0 Share this post Link to post
boris Posted March 13, 2004 I don't think it works that way. I guess your "sector" variable gets reset each time the script restarts. Use a loop like this: script 802 OPEN { int sector; for(sector=0; sector < 10; sector++) { Ceiling_LowerInstant(sector, 0, 304); delay(10); } } Of course you have to set the right values in the loop's head. 0 Share this post Link to post
Epyo Posted March 13, 2004 oh so I don't even need the i: and the s: thingys huh, ok that helps thanks. 0 Share this post Link to post
boris Posted March 13, 2004 They are not required, but maybe it works with them, I don't know. They are required with print and hudmessage though, IIRC. 0 Share this post Link to post
Cyb Posted March 13, 2004 OMG! script 802 OPEN { for(int sector=0; sector < 10; sector++) { Ceiling_LowerInstant(sector, 0, 304); delay(10); } } not that it matters, and yes boris is right, if you restart a script then the variable (sector) will get reinitialized every time to zero. You could, however, do this: script 802 OPEN { int sector; zuh: sector++; Ceiling_LowerInstant(sector, 0, 304); delay(10); goto zuh; } if you really wanted to, but then that will never terminate and in fact it'll probably overflow after a while and restart raising at sector 0 again (will take days tho I think) 0 Share this post Link to post
boris Posted March 13, 2004 Every time you use goto god kills a kitten. Please, think of the kittens! 0 Share this post Link to post
Graf Zahl Posted March 13, 2004 boris said:Every time you use goto god kills a kitten. Please, think of the kittens! Same old lame statement as ever. Why doesn't it die? 0 Share this post Link to post
Epyo Posted March 13, 2004 Umm actually no the variable isn't resetting to zero each time, and I still have my original script but without the s: and i: thingys. Weirdos! EDIT: Ok now in a totally different script I'm trying to use the goto thing but it says that my feh: is an invalid argument;script 777 (void) { int sectora; sectora = 251; feh: sectora--; Sector_SetDamage(sectora, 0, 14); changefloor(sectora, "GRASS2"); delay(1); Goto feh; } 0 Share this post Link to post
Chopkinsca Posted March 14, 2004 I usually declare variables above the script, and outside. Meh, it works. [B]int sectora; sectora = 251; script 777 (void) { sectora--; Sector_SetDamage(sectora, 0, 14); changefloor(sectora, "GRASS2"); delay(1); restart; }But really this should be in a for loop, or at least have a if(sectora < lowest_sector_tag_number){terminate;}between sectora--; and sector_setdamage. 0 Share this post Link to post
Bloodshedder Posted March 14, 2004 I suppose ACS doesn't support initializing a variable as static. 0 Share this post Link to post
Graf Zahl Posted March 14, 2004 Bloodshedder said:I suppose ACS doesn't support initializing a variable as static. Of course it does. Outside a script write int variable=1337; Just like in C! 0 Share this post Link to post
Bloodshedder Posted March 14, 2004 Eh, yes I know that will work, I meant with the static keyword. Local scope but global persistence. 0 Share this post Link to post
Graf Zahl Posted March 14, 2004 Bloodshedder said:Eh, yes I know that will work, I meant with the static keyword. Local scope but global persistence. Use a global variable that's only referenced to in one ACS file and you'll have exactly that. 0 Share this post Link to post