The EAX Scripting language
Project X scripts are based on a custom scripting language, named EAX, its syntax is similar to c++, with a number of singularities.
Contents
Variables
Local variables need local identifier
local k = 5;
EAX doesnt need variable declarations, nor type. Variables are allocated upon the first use, and type is determined with iterational solver, for example:
local variable = GetFirstWorm();
Variable will be of type CWorm, and initialized with GetFirstWorm() return value.
Fields
Class fields do not need declaration, nor type, and can be defined anywhere in class methods:
override void CWorm::CWorm(CObject* Parent,int aTeam,int aIndex,CWormParams* params) { field = 5; }
The super macro
This macro, whose syntax is super( BASE CLASS ARGUMENTS ), can be used to call base class (game original class) method, for example:
override void CWorm::FireFinal(CWeapon* Weap,CShootDesc* Desc) { local Weapon = GetWeaponByName("Bazooka"); super(&Weapon, Desc); }
second line calls CWorm::FireFinal() with custom arguments.
If we derivate a class like:
CWormA : CWorm;
And then define method:
CWormA::FireFinal(CWeapon* Weap,CShootDesc* Desc) { local Weapon = GetWeaponByName("Bazooka"); super(&Weapon, Desc); }
Second line will ALSO call CWorm::Firefinal();
Overriding Game Functions
Identifier override is used to override execution of game functions to add custom routines, for example:
override void CMissile::ExplodeAt(fixed x,fixed y) { j = x/2; super(j,y); }
will call original function with parameter x at half value.
The require identifier
Used to include libraries in the code:
require utils;
Include utils library.