SOF2Fragger Posted May 10, 2023 I want to repeat an action an "x" number of times. Or a tutorial. Thanks in advance. 0 Quote Share this post Link to post
1 Kan3 Posted May 10, 2023 Several ways to do it. You can just have your actions inside your script and then just use Restart; Or make while or for loops. You could even use conveyor belts and teleportation lines if not using ACS 1 Quote Share this post Link to post
0 SOF2Fragger Posted May 10, 2023 I need it to run a limited number of times, and restart would just keep it going. I know I need a loop, but my knowledge is very limited. 0 Quote Share this post Link to post
0 SOF2Fragger Posted May 10, 2023 I'm working on this, and a script like that would help me. 0 Quote Share this post Link to post
0 Kan3 Posted May 11, 2023 That's why I put the links to the while and for loop... Everything's explained there on how to make a script run a certain amount of times. 0 Quote Share this post Link to post
0 SOF2Fragger Posted May 11, 2023 I feel like the guy in "Mallrats" who couldn't see the sailboat. 0 Quote Share this post Link to post
0 smeghammer Posted May 12, 2023 (edited) Here you go. Three different ones: Spoiler #include "zcommon.acs" /* declare some variables used by script 2 */ bool triggered = 0; int counter = 0; /* start a loop that checks for imp count being greater than zero */ script 2 OPEN{ while(ThingCount(T_IMP,0) > 0){ log(s:"Still ",i:ThingCount(T_IMP,0),s:" imps left!"); delay(35); } // loop exited when all imps killed: print(s:"All Dead! Get the fuck out!!!!"); } /* a counter that tracks whether all platforms are lowered. */ script 1 (void){ counter++; print(i:counter); /* lower plats on each increment: */ int tagnum = -1; switch(counter){ case 1: tagnum=2; break; case 2: tagnum=3; break; case 3: tagnum=4; break; case 4: tagnum=5; break; default: break; } /* lowers platform identified by tagnum by 56 units */ floor_lowerbyvalue(tagnum,16,56); } /* and a simple 'for' loop. doesn't do anything much... */ script 3(void){ for (int x=0; x < 5; x++){ log(s:"iteration ",i:x); } } WHILE: Continues until condition is not met. Counts imps, and prints a message when all dead (the ENTER script) VARIABLE COUNTER: script 1 - increments a counter on each script call and does something (lowers the platforms in turn) FOR: loops for specified number of times. You can use a variable as well if you need to. Simple map (DiHF) acs_loops.zip Edited May 12, 2023 by smeghammer removed irrelevant code 0 Quote Share this post Link to post
Question
SOF2Fragger
I want to repeat an action an "x" number of times. Or a tutorial.
Thanks in advance.
Share this post
Link to post
6 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.