| Blockland Forums > Modification Help |
| Iban Explains it All |
| << < (7/39) > >> |
| Iban:
--- Quote from: Treynolds416 on March 03, 2011, 10:09:58 PM ---So that when the loop ends of its own accord, the action will happen once, only once, and only after the loop terminates. --- End quote --- The answer to this is so amazingly simple you're going to hit yourself for overthinking this. --- Code: ---function doSomething() { for(%a = 0; %a < 10; %a++) { echo("Loop Iteration #" @ %a); } doSomethingElse(); // Post-Loop Function Call } --- End code --- Just put the function call after the loop. --- Quote from: otto-san on March 03, 2011, 10:10:52 PM ---The whole cat/datablock comparison really helped me understand how datablocks work better. :D --- End quote --- :3 |
| Treynolds416:
--- Quote from: Iban on March 03, 2011, 10:11:50 PM ---The answer to this is so amazingly simple you're going to hit yourself for overthinking this. --- Code: ---function doSomething() { for(%a = 0; %a < 10; %a++) { echo("Loop Iteration #" @ %a); } doSomethingElse(); // Post-Loop Function Call } --- End code --- Just put the function call after the loop. --- End quote --- Hmmm. I did that, and it appears that you can only do a function call after the loop, because an echo statement feeds back syntax errors. |
| Iban:
What are you talking about? Post the actual script you're doing something terribly, terribly wrong. |
| Treynolds416:
--- Quote from: Iban on March 03, 2011, 10:21:56 PM ---What are you talking about? Post the actual script you're doing something terribly, terribly wrong. --- End quote --- --- Code: ---function GenerateTerrain(%dim1,%dim2) { for(%i=0;%i<%dim1;%i++) { ServerCmdPlantBrick(5975); ServerCmdSuperShiftBrick(5975, 1, 0, 0); } echo("whatever words" SPC %i) } --- End code --- |
| Iban:
Dude, there's no semicolon after the echo. |
| Navigation |
| Message Index |
| Next page |
| Previous page |