Beginners scripting tutorial (Page 3 of 5)

Written by Roguey,

Beginners Scripting tutorial, written by Roguey


The script editor

Now we finally into the real script editor. In this section we can create and edit nearly all the scripts in the game. I say nearly because some scripts will be hidden from us. We dont need to worry about these scripts. Your script editor should look something like this (you may have different scripts in your list, as I have my mod installed).

The script editor showing a list of all the scripts

Making a ship?

So what shall we do now? add money to our account? nah... that's boring. hmmm.. lets make a ship!

So how the heck will make a ship? well, first step is to make a new script. So move your select bar to <New Script> and press enter. A box will come up asking us for a name. Lets make it simple for now, enter in Myship and press enter. You could name this script anything you like - but make it understandable.

You should see something like the following now:

A new blank script

So what does this screen mean? Well this screen shows us our script. As its a new one, its blank.

The first option version allows us to set a version. You can use this value to track changes in your code, say in version 2 you made your script more complex, if you saw it was version 1, you know it was an old version.

Next the description, this is not a required field, it just gives other scripters an idea what this script does. So press enter and change it to Creates a ship for me. This can be anything you like.

We dont need to worry about the others settings now. So move your selection to <New Line> and press enter.

This how we code in the script editor: by selecting <New Line> or a blank line and pressing enter. Once done a list of commands will appear, where we can choose from list of commands. The commands are grouped by function, which makes finding the commands a little easier.

The command list inside the script editor

Okies.... We want to make a ship eh? Well the first piece of information we need is the current location. We could do it the simply way and tell the script which sector to place the ship, however that has one big problem with it... What happens if move sectors or try another start position?

Well... lets found out the current sector for our ship before placing it. How do I do that?... its easy enough, go down to General Object Commands and press enter. Now we want this command:

<RetVar/If><RefObj> get sector

So what does this command do? ... well it can give us what sector something is in and either store it or use it for a if statement. We dont want to do a If statement, just store the value.

So press enter and your see another screen asking us what we want to do with the result from this command. Go down to <Variable> and press enter, we now need to write a name for this variable. I recommend that you use something meaningful, so lets use sector and press enter.

We will now be back at our script - this time we have one command there (get sector). It should look something like this:

Our script with one command

However we are not finished with this command. We need to tell it a object, so we can find out its location. So if not already high-lighted, select the first <?> (you know its selected when it turns red). Once high-lighted, press enter. Another list will appear.

Selecting a input for our get sector command

Move down and select PLAYERSHIP. This means that we are getting the sector where the player ship is. The player ship is the ship the player is using. The player must always be in a ship in one form or another.

So now you should have the following:

get sector command done

So to sum up, the variable we named as sector will now contain the sector where the player is. So... next we need to create the ship!
Next: Summoning the ship
<< Previous Page - Next Page >>