Scripting tutorial #3: Your first script
Starting Out Simple
If you've read the first two pages of this tutorial, then you should be ready to start playing around with scripts!
To begin, let's recreate one of the most famous "programs". Aside from being an extremely simple script you can build on later, it's also a good way to ensure that everything is working the way it should. Just open up your text editor, and copy the following lines into it:
START ALERT "Hello World" END
Save this text to a file of your choice, and then load Mike's Sprite Editor. Once the window comes up, select "Run Batch Script" from the Effects menu and choose your new text file. Once you click OK on the open file dialog, a little box like this should appear:
However, if you get an error message instead, check ![ref_errors.html](this page) to see what might be wrong. If everything looks right in your text editor but you get a strange or garbled error message, then your text editor may not be saving files as plain text, and you'll need to try another program. This is why you always start with the simplest of programs; it highlights problems with your tools before you've invested a lot of time and effort into creating something!
Black and Blue All Over
Now that you can get a script working, let's move on to a more practical example. This scripting feature exists to help you reuse filters or even create some of your own by combining the existing effects, so let's create a neat little filter.
First, copy this next block of code into your text editor and save it like before.
START FILTER.GROW FILTER.GROW BUMP COLOR.NEW 0x5555FF STORE BLUE COLOR.NEW 0x000000 STORE BLACK COLOR.NEW 0xFFFFFF STORE WHITE FILTER.SWAP BLACK BLUE FILTER.SWAP WHITE .ALPHA END
Now, to see this script in action, you'll need to draw something in the editor. It doesn't need to be fancy; it just needs to be something black on a white background.
On the next page, I'll break down exactly what each line means and how this filter works. In the meantime, use the "Run Batch Script" option to execute your new script and see what happens!
On to the next tutorial page -->
<-- Back to the previous tutorial page