Scripter manual

From OPU Wiki

Table of contents

Introduction

AI-Scripter was created to make it easier for non-coders to create their own Outpost 2 mission DLLs, without having to learn C++ (http://en.wikipedia.org/wiki/C%2B%2B), the programming language used for creating the DLLs. Instead a simple and easy-to-learn scripting language has been developed, so just about anyone can design missions without much trouble, and without having to consult more experienced coders on a daily basis.


Basic understanding of how a script works is essential. The AIS scripts follow simple guidelines, which are simular to other scripting languages, such as BASIC (http://en.wikipedia.org/wiki/BASIC) or HTML (http://en.wikipedia.org/wiki/Html). The starting point for this project was to create something that 95% of the people would be able to work with, provided you understand the English language and have commonb sense.

Layout

Each script consists of several blocks. All commands must be placed within a block, so the script compiler knows what section the command belongs to.

Current version (0.2) has only 2 block sections:

If commands are placed outside a section, they automaticly go into the MAIN section. This also means you do not have to explicitly include the main block in your script.

Although section blacks can appear more than once, duplicate commands will overwrite any previous command of the same type.

BEGIN blockname
  COMMAND ( parameters )
END


Syntax

Each command must reside on one single line. You are not allowed to split up a command over more than one line. There is no limit to line length, but the editor will wrap the line if it is longer than 1024 characters.

The compiler is completely case-INsensitive. This means you can use Capitals whereever you like to increase readability of the script. Strings will be read with their case intact.


A command can have parantheses, but they are not required. There is only 1 rule: if you DO use parantheses, they must be correct. All other parameters must be entered as numbers or strings.

AI Scripter recognises these COMMANDS and map_ids.


Random numbers

There are two ways of adding random numbers:

  • RND
  • RANDOM


RND

RND creates a fixed random number: the number is generated by the Scripter and hard-coded into the mission, which means it will not change when you restart the mission. Only by recompiling your script you can create another random number. To get real random numbers use RANDOM instead.

RANDOM

RANDOM lets Outpost 2 create the random number and is the only REAL random number: if you restart the mission, Outpost 2 will generate other random numbers then before.

RANDOM can ONLY be used in a SET command, and not directly within a function call like UNIT or BEACON. The way to use it is to set a variable and then use the variable in the functions.

Variables

You can create variables in Scripter that can be used anywhere in the mission (a note to experienced coders: ALL variables are global, Scripter does not have local variables. Also note that the Scripter language is case-INsensitive).

A variable typically starts with a dollar-sign ($) and it can be upto 25 characters long. You are allowed to use letters and numbers, and the underscore character (_) in the variable name.

VAR $Variable_1

SET $variable_2 = 12
SET $VARIABLE_3 = "some string"
SET $RandomNumber = RANDOM(100)

As you can see above, variables can hold numbers or text-strings. Please be advised that $RandomNumber like it is declared above will ALWAYS reflect a certain number, it will NOT create a different number each time it is used. In the SET command, Outpost 2 will assign a randomly generated number to $RandomNumber and that same number will be inserted as a parameter each time it is used.

Before using any variable, it should be initialised with a SET command. If you use a variable without initialising it, its value in empty (not zero, but an empty string ""). The VAR command only defines the variable (stores its name), without assigning a value.

Personal tools