First Steps with Your Editor
To get used to working with a programming editor, you’re going to create a new folder and file in the ScriptCraft plugins folder and save the new file.
Create a New Folder
In the File Browser pane (the Disk Browser in TextWrangler on Mac OS), locate and select the mcserver folder. Then navigate to the scriptcraft/plugins subfolder. Once that folder is selected, right-click the folder and choose New Folder from the menu (see FIGURE 4.11). Call your new folder learning for now. You can call it something else as long as it’s memorable—you’ll come back to this folder later.
FIGURE 4.11 Creating a new folder
Your new folder will now appear in the File/Disk Browser pane.
FIGURE 4.12 Creating a new file
The file has just been created but hasn’t been opened. If using TextWrangler, click the file to open it. If using gedit, double-click the file to open it. The file contents now appear in the editing pane on the right. The file is, as you’d expect, empty. Type in the following code exactly as you see it:
// TO DO : Add some code later
The previous code is just a comment you’ve added to remind yourself that you must add some proper code later. This comment isn’t understandable to the computer, so you can write whatever you like on a line beginning with //. The computer will not try to interpret and execute it. Comments like this can be useful for programmers because they make understanding code easier. Writing code is like any kind of writing—you should try to make your code readable by yourself and others, so if you look at your code later, you can figure out what you did.
Saving Your Work
Save the file by choosing Save from the File menu or by pressing Ctrl+S (Cmd+S on Mac OS). The file is now saved. You can verify this by closing the file and opening it once more. To close the file, choose File > Close or click the close icon next to the filename at the top of the editor pane.
Reopen the file by double-clicking it in the File/Disk Browser pane. The text you entered previously should still be present. Saving your work is really important because code you edit will not take effect unless you first save it. You’d be surprised how often even experienced programmers forget this simple rule and are left wondering why their code isn’t working as expected.
When using ScriptCraft, the folder where you save your work is important. You can’t just save your files anywhere and hope they’ll be executed by ScriptCraft.