Tutorial
Basics of Scripting

On This Page
SC Files
+ Creating
+ Syntax
Exporting
Triggers
SC Commands
+"If" Statements
+Syntax
Comments
Sector-Triggered Commands
Help


SC Files
1) Creating
Before anything: In windows explorer, go to Tools>Folder Options. Click the 'view' tab and find "Hide extensions for known file types," and make sure the box is not checked.

To create a new .sc file, bring up your maps folder (usually games\meteor2\base\maps) and right-click in an inactive space in the maps folder. Point to new, then Text Document. Name this file the exact filename your map is, then type ".sc" at the end of it. You may get "If you change this file extension, it may become unusable. Are you sure?", click yes. Then, open your newly created script file. It will offer you which program you want to open the SC with, so tick "always use this program to open this type of file," and click Wordpad.

Now, paste this into your SC file:

#title ""
#author "your name here"

#include meteor2

export OnMapStart;

void OnMapStart()
{

}

2) Syntax
The easiest way to understand scripting is to know the syntax. Basically, the file is divided into two parts-the export section and the triggers.

Export Section
Under the:

#title ""
#author "your name here"

#include meteor2

you will find the export section. Here, you must depict which commands you're going to use in the triggers section. Export commands can be created by taking the trigger and removing the parenthesis after it. For example:

    OnWaypointReached_5()

This is a trigger. It is triggered when an object reached waypoint 5. Its export command would be:

    export OnWaypointReached_5;

Every export command has "export" in front of it, and a ";" after it. This is vitally important to remember.

Triggers Section
Under the export section you can start scripting. All the triggers can be found in the M2 documentary. To make a trigger, you need to export it in the export section and script it in the triggers section. Every trigger DOES NOT have a semicolon after it. Example:

    export
OnWaypointReached_5;


void
OnWaypointReached_5()
{

}


void - ALL triggers must have 'void' before them.
OnWaypointReached - The type of trigger you need.
_5 - The trigger's variable: For each trigger, you'll need a underscore then a variable. The variable is the waypoint ID in OnWaypointReached, the Object ID in OnEnterVehicle, etc.
{ } - Brackets are the organization of scripts. They need to 'wrap' around every set of SC commands under a trigger.
The Blue area - SC commands: Under every trigger are SC commands which are contained by brackets.

Both sections together

Here is what your SC file should look like:
The file (so far) prepares a trigger for when any unit hits waypoint ID 5.

#title ""
#author "your name here"

#include meteor2
export OnWaypointReached_5;

void OnWaypointReached_5()
{

}


 = Universal Beginning of ALL script documents

 = Export Section

 = Triggers Section





SC Commands
1) Syntax
ALL export commands have "SC_" in front of it and a ";" to finish it off.
Example:

SC_BindObjectToWaypoint(10,39);

This command binds object ID 10 to waypoint 39. The value of an SC command is depicted in the M2 documentation. Generally, the syntax is:

BindObjectToWaypoint <-- The type of command you want
SC_BindObjectToWaypoint <-- The prefix on EVERY SC command
SC_BindObjectToWaypoint(???,???) <-- The value
SC_BindObjectToWaypoint(???,???); <-- The semicolon which goes after EVERY SC command.

2) "If" Statements
Creating an if statement can be done like this:

void OnWaypointReached_5()
{
    if (<VALUE 1> == <VALUE 2>)
    { 
   
    }

}

<VALUE 1> = A "Get" SC command from the M2 documentation. One of these Get commands is:

    SC_GetItemCount("<ITEM>")

   
<ITEM> = The exact item name (you can check the Item editor for the object you want)


<VALUE 2> = The the amount of
<VALUE 1>, in this case it would be the amount of an item.

{  }    = Brackets, again, are the organization of SC files. If you create an if statement you must put brackets around the SC commands below it.

Example:

void OnWaypointReached_5()
{
    if ( SC_GetItemCount("Bullet") == 500 )< /SPAN >


SC_GameMessage("You have 500 bullets");
}
}

The blue area = SC commands

Comments
If you put a // in front of anything, that anything will be completely ignored by Meteor 2. The following would be ignored:

// this is a comment

// SC_SetObjectHidden(1,0);

Sector-Triggered Commands
Please note: In this section, "<TRIGGER>" is a variable you come up with, not simply "<TRIGGER>.
If you want to set a sector to trigger SC commands in the SC file, type "run <TRIGGER>" in a the script command for a sector, where <TRIGGER> is a name that you come up with (it can be anything, it should not be <TRIGGER>).

Scripting Screenshot


In your SC file, export this trigger by typing:

export <TRIGGER>;

where <TRIGGER> is that name you came up with. Then, treat it like a normal trigger:

void <TRIGGER>()
{

}



Help
If you're stumped and would like your script checked, please sign up to the JBServer.com forums and post under Help.

Go to the JBServer.com: Meteor 2 forum
Sign up

You can also send it to me at mikeMX3000@yahoo.com.