Loops scripting tutorial (Page 4 of 4)

Written by Roguey,

Loops scripting tutorial, written by Roguey


Adding the second loop

The eagle-eye ones will have spotted an fault with our script so far: x is increasing by one (so we are scanning left to right), however y is staying at zero. So we need increase y every so often. I dont fancy writing 20 loops, so why not encase our first while loop in another?

It sounds harder than it is! copy and paste the while line, so you have two lines which read while $x < 30. Change the first version to read while $y < 20. Now we need to complete our second loop. So goto line 9 (the inc $x= statement) and paste it at line 11. At line 11 change the variable from x to y.

Now we need to reset x when its reached 30. You can think of x like a type-writter. When we have reached right hand side, we need to go back to the left hand side. So copy line 1 and paste it at line 12, it should appear just after your inc $y=command.

Now we need to end the second loop. So next copy the end command from line 10 and paste it at line 13. If you done everything correct it should look like this:

Our script is now complete

So what this does is goes from left to right, checking if the sector exists and if so places a satellite in it for us. Once the script has gone right, we go down one line and check from left to right again.

Now press escape and save the script. We now need to run the script from the script list, so find Make.Sats and press r. You can just press enter twice (the two popups arent useful at this time).

Now exit the script editor and check your owned property list... wow, ive just got 200+ satellites in every known sector! Well, that saves exploring them all eh?... If you do decide to build mods, this script can be another really useful one. I do emit its a bit more complex than your normal while loops tutorials, however I rather teach you something useful!

Next: End of guide
<< Previous Page