| Blockland Forums > Modification Help |
| how would i slow a for statement? |
| (1/5) > >> |
| phflack:
for some reason in my for statements, they go quickly, even though i have a delay in the main part, is there a way to slow it down? |
| ThinkInvisible:
Well, you COULD use the extremely complicated way and do: %counter = 0; %counterLimit = how long to run the For loop for...; if(%counter < %counterLimit) { schedule(timeToLoopMS,0,commandcontainingthis,args); %counter ++; } etc. EDIT : Okay, i'll explain it above... You put that block in your function or whatever. %counter = 0; keep this %counterLimit = *IN HERE, put how many loops you want it to do.*; if(%counter < counterLimit) If the counter has reached the loop maximum, stop. { schedule(*HERE:Put how long you want it to be, in MS, between loops.*,0,*The command calling this in the first place.*Any args incmd*); %counter ++; auto-increment. handy, no? } etc. rest of code example edit: function serverCmdDelayedCounterLoop(%numToLoop,%delayzor) { if(%started = 0) //safety first. { %counter = 0; } %counterLimit = %numtoloop; if(%counter < %counterLimit) { schedule(%delayzor,0,serverCmdDelayedCounterLoop) %started = 1; commandToServer("A counter has reached "@%counter@"!"); } } when a player in your server says /DelayedCounterLoop 15 100, it will say an incrementing number every 1sec or so for 15 numbers. |
| MegaScientifical:
--- Code: ---function blahCommand(%stuff) { if((%s = strLen(%stuff)) > 4) cycleCommand(%stuff, 0, %s); } function cycleCommand(%stuff, %i, %s) { if(%i <= %s) { doStuff(%stuff); schedule(500, 0, cycleCommand, %i++, %s); } else echo("doneStuff"); } --- End code --- |
| phflack:
so basicaly you can't delay a for loop or something? |
| MegaScientifical:
Nope. |
| Navigation |
| Message Index |
| Next page |