Getting Started with Scripting


Excercise 3 - Making a simple script

Drag from the "star turn by 5" line of the viewer, and drop onto the "desktop" of the world. A Scriptor will result - your own script, with the "star turn by 5" command already in there as its first line.

Drag from the "star forward by 5" line of the viewer, and drop that down inside the same Scriptor. You have now created a two-line script, that tells the star to turn and move forward.Let the cursor drift over each of the five buttons at the top of the Scriptor, and read the balloon help of each to get an idea of what they do.

Click on the "!" and the script runs. Hold down, it keeps running. Change the amount-to-turn-by and the amount-to-move-forward-by and run again.

Now try out various alternatives for when the script should run. Initially, when it says "Normal" in the Scriptor, it's just cold code waiting to be called by someone, such as by the yellow "!" button.

So now make it run continuously - choose "ticking" from the script-status menu that pops up when you click on "Normal". The star should now start animating continuously, until you change its status or until you hit the "Stop" button.

While it's animating, change the parameters to "forward" and "turn" in the Scriptor, to achieve different curvature and speed as it putts along.

Now for fun you might find the "Pen" area in the star's Viewer, and change the star's "PenDown" to true. It will start laying down ink as it moves, and now by adjusting parameters to move and turn in the Scriptor, you can do a kind of scripted drawing.
Once you've started this, resist the temptation to change the pen's color and size in the viewer, because you might get distracted from the real business of scripting.