BZ98R ScriptUtils
===================================================

ScriptUtils

BZ98R ScriptUtils Stub.

Definitions for Lua Language Server

>>
---------------------------------------------------
Types
[section]

Type declarations

>>
---------------------------------------------------
Handle
[type]

A handle to a game object. This is a unique identifier for the object in the game world.

---------------------------------------------------
ParameterDB
[type]

ODF ParameterDB

---------------------------------------------------
AudioMessage : integer
[alias]

A handle to an audio message.

---------------------------------------------------
TeamNum : 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15
[alias]

Team Number

---------------------------------------------------
ColorLabel : string
[alias]

Objective Color Label

---------------------------------------------------
TeamSlotInteger : integer
[alias]

TeamSlot Integer

<<
---------------------------------------------------
Enums
[section]
>>
---------------------------------------------------
ClassId
[enum]

Many of these values likely never appear in game and are leftover from Interstate '76

>>
@field NONE = 0: integer
@field HELICOPTER = 1: integer
@field STRUCTURE1 = 2: integer

Wooden Structures

@field POWERUP = 3: integer
@field PERSON = 4: integer
@field SIGN = 5: integer
@field VEHICLE = 6: integer
@field SCRAP = 7: integer
@field BRIDGE = 8: integer

A structure which can contain the floor

@field FLOOR = 9: integer

The floor in a bridge

@field STRUCTURE2 = 10: integer

Metal Structures

@field SCROUNGE = 11: integer
@field SPINNER = 15: integer
@field HEADLIGHT_MASK = 38: integer
@field EYEPOINT = 40: integer
@field COM = 42: integer
@field WEAPON = 50: integer
@field ORDNANCE = 51: integer
@field EXPLOSION = 52: integer
@field CHUNK = 53: integer
@field SORT_OBJECT = 54: integer
@field NONCOLLIDABLE = 55: integer
@field VEHICLE_GEOMETRY = 60: integer
@field STRUCTURE_GEOMETRY = 61: integer
@field WEAPON_GEOMETRY = 63: integer
@field ORDNANCE_GEOMETRY = 64: integer
@field TURRET_GEOMETRY = 65: integer
@field ROTOR_GEOMETRY = 66: integer
@field NACELLE_GEOMETRY = 67: integer
@field FIN_GEOMETRY = 68: integer
@field COCKPIT_GEOMETRY = 69: integer
@field WEAPON_HARDPOINT = 70: integer
@field CANNON_HARDPOINT = 71: integer
@field ROCKET_HARDPOINT = 72: integer
@field MORTAR_HARDPOINT = 73: integer
@field SPECIAL_HARDPOINT = 74: integer
@field FLAME_EMITTER = 75: integer
@field SMOKE_EMITTER = 76: integer
@field DUST_EMITTER = 77: integer
@field PARKING_LOT = 81: integer
@field [0] = "NONE": string
@field [1] = "HELICOPTER": string
@field [2] = "STRUCTURE1": string

Wooden Structures

@field [3] = "POWERUP": string
@field [4] = "PERSON": string
@field [5] = "SIGN": string
@field [6] = "VEHICLE": string
@field [7] = "SCRAP": string
@field [8] = "BRIDGE": string

A structure which can contain the floor

@field [9] = "FLOOR": string

The floor in a bridge

@field [10] = "STRUCTURE2": string

Metal Structures

@field [11] = "SCROUNGE": string
@field [15] = "SPINNER": string
@field [38] = "HEADLIGHT_MASK": string
@field [40] = "EYEPOINT": string
@field [42] = "COM": string
@field [50] = "WEAPON": string
@field [51] = "ORDNANCE": string
@field [52] = "EXPLOSION": string
@field [53] = "CHUNK": string
@field [54] = "SORT_OBJECT": string
@field [55] = "NONCOLLIDABLE": string
@field [60] = "VEHICLE_GEOMETRY": string
@field [61] = "STRUCTURE_GEOMETRY": string
@field [63] = "WEAPON_GEOMETRY": string
@field [64] = "ORDNANCE_GEOMETRY": string
@field [65] = "TURRET_GEOMETRY": string
@field [66] = "ROTOR_GEOMETRY": string
@field [67] = "NACELLE_GEOMETRY": string
@field [68] = "FIN_GEOMETRY": string
@field [69] = "COCKPIT_GEOMETRY": string
@field [70] = "WEAPON_HARDPOINT": string
@field [71] = "CANNON_HARDPOINT": string
@field [72] = "ROCKET_HARDPOINT": string
@field [73] = "MORTAR_HARDPOINT": string
@field [74] = "SPECIAL_HARDPOINT": string
@field [75] = "FLAME_EMITTER": string
@field [76] = "SMOKE_EMITTER": string
@field [77] = "DUST_EMITTER": string
@field [81] = "PARKING_LOT": string
<<
---------------------------------------------------
TeamSlot
[enum]

For maintainability, always use this enum instead of raw team slot numbers. Slots starting with MIN_ and MAX_ represent the lower and upper bound of a range of slots.

>>
@field PLAYER = 0: integer
@field RECYCLER = 1: integer
@field FACTORY = 2: integer
@field ARMORY = 3: integer
@field CONSTRUCT = 4: integer
@field MIN_OFFENSE = 5: integer
@field MAX_OFFENSE = 14: integer
@field MIN_DEFENSE = 15: integer
@field MAX_DEFENSE = 24: integer
@field MIN_UTILITY = 25: integer
@field MAX_UTILITY = 34: integer
@field MIN_BEACON = 35: integer
@field MAX_BEACON = 44: integer
@field MIN_POWER = 45: integer
@field MAX_POWER = 54: integer
@field MIN_COMM = 55: integer
@field MAX_COMM = 59: integer
@field MIN_REPAIR = 60: integer
@field MAX_REPAIR = 64: integer
@field MIN_SUPPLY = 65: integer
@field MAX_SUPPLY = 69: integer
@field MIN_SILO = 70: integer
@field MAX_SILO = 74: integer
@field MIN_BARRACKS = 75: integer
@field MAX_BARRACKS = 79: integer
@field MIN_GUNTOWER = 80: integer
@field MAX_GUNTOWER = 89: integer
@field PORTAL = 90: integer
[version 2.2.315+]
@field [0] = "PLAYER": string
@field [1] = "RECYCLER": string
@field [2] = "FACTORY": string
@field [3] = "ARMORY": string
@field [4] = "CONSTRUCT": string
@field [5] = "MIN_OFFENSE": string
@field [14] = "MAX_OFFENSE": string
@field [15] = "MIN_DEFENSE": string
@field [24] = "MAX_DEFENSE": string
@field [25] = "MIN_UTILITY": string
@field [34] = "MAX_UTILITY": string
@field [35] = "MIN_BEACON": string
@field [44] = "MAX_BEACON": string
@field [45] = "MIN_POWER": string
@field [54] = "MAX_POWER": string
@field [55] = "MIN_COMM": string
@field [59] = "MAX_COMM": string
@field [60] = "MIN_REPAIR": string
@field [64] = "MAX_REPAIR": string
@field [65] = "MIN_SUPPLY": string
@field [69] = "MAX_SUPPLY": string
@field [70] = "MIN_SILO": string
@field [74] = "MAX_SILO": string
@field [75] = "MIN_BARRACKS": string
@field [79] = "MAX_BARRACKS": string
@field [80] = "MIN_GUNTOWER": string
@field [89] = "MAX_GUNTOWER": string
@field [90] = "PORTAL": string
[version 2.2.315+]
<<
---------------------------------------------------
AiCommand
[enum]

For maintainability, always use this enum instead of raw command numbers.

>>
@field NONE = 0: integer
@field SELECT = 1: integer
@field STOP = 2: integer
@field GO = 3: integer
@field ATTACK = 4: integer
@field FOLLOW = 5: integer
@field FORMATION = 6: integer
@field PICKUP = 7: integer
@field DROPOFF = 8: integer
@field NO_DROPOFF = 9: integer
@field GET_REPAIR = 10: integer
@field GET_RELOAD = 11: integer
@field GET_WEAPON = 12: integer
@field GET_CAMERA = 13: integer
@field GET_BOMB = 14: integer
@field DEFEND = 15: integer
@field GO_TO_GEYSER = 16: integer
@field RESCUE = 17: integer
@field RECYCLE = 18: integer
@field SCAVENGE = 19: integer
@field HUNT = 20: integer
@field BUILD = 21: integer
@field PATROL = 22: integer
@field STAGE = 23: integer
@field SEND = 24: integer
@field GET_IN = 25: integer
@field LAY_MINES = 26: integer
@field CLOAK = 27: integer
[version 2.1+]
@field DECLOAK = 28: integer
[version 2.1+]
@field [0] = "NONE": string
@field [1] = "SELECT": string
@field [2] = "STOP": string
@field [3] = "GO": string
@field [4] = "ATTACK": string
@field [5] = "FOLLOW": string
@field [6] = "FORMATION": string
@field [7] = "PICKUP": string
@field [8] = "DROPOFF": string
@field [9] = "NO_DROPOFF": string
@field [10] = "GET_REPAIR": string
@field [11] = "GET_RELOAD": string
@field [12] = "GET_WEAPON": string
@field [13] = "GET_CAMERA": string
@field [14] = "GET_BOMB": string
@field [15] = "DEFEND": string
@field [16] = "GO_TO_GEYSER": string
@field [17] = "RESCUE": string
@field [18] = "RECYCLE": string
@field [19] = "SCAVENGE": string
@field [20] = "HUNT": string
@field [21] = "BUILD": string
@field [22] = "PATROL": string
@field [23] = "STAGE": string
@field [24] = "SEND": string
@field [25] = "GET_IN": string
@field [26] = "LAY_MINES": string
@field [27] = "CLOAK": string
[version 2.1+]
@field [28] = "DECLOAK": string
[version 2.1+]
<<
<<
---------------------------------------------------
Globals
[section]

The Lua scripting system defines some global variables that can be of use to user scripts.

>>
---------------------------------------------------
_G . GameVersion
[string] [global]

Contains current build version

Battlezone 1.5 versions start with "1"

Battlezone 98 Redux versions start with "2"

For example "1.5.2.27u1" or "2.2.301"

---------------------------------------------------
_G . Language
[integer] [global] [version 2.0+]

Contains the index of the current language.

1. English
2. French
3. German
4. Spanish
5. Italian
6. Portuguese
7. Russian
---------------------------------------------------
_G . LanguageName
[string] [global] [version 2.0+]

Contains the full name of the current language in all-caps: "ENGLISH", "FRENCH", "GERMAN", "SPANISH", "ITALIAN", "PORTUGUESE", or "RUSSIAN"

---------------------------------------------------
_G . LanguageSuffix
[string] [global] [version 2.0+]

Contains the two-letter language code of the current language: "en", "fr", "de", "es", "it", "pt" or "ru"

---------------------------------------------------
_G . LastGameKey
[string] [global]

Contains the most recently pressed game key (e.g. "Ctrl+Z")

<<
---------------------------------------------------
Callbacks
[section]

These are functions you are expected to implement in your script. The game will call these functions if they exist for game logic events.

>>
---------------------------------------------------
_G . Save ( ) -> ...: any
[function callback] [global]
@return ... any

Save is called when you save a game

---------------------------------------------------
_G . Load ( ...: any )
[function callback] [global]
@param ... any

Load is called when you load a game, or when a Resync is loaded.

---------------------------------------------------
_G . Start ( )
[function callback] [global]

Called when the mission starts for the first time. Use this function to perform any one-time script initialization.

---------------------------------------------------
_G . GameKey ( key: string )
[function callback] [global]
@param key string

The key that was pressed.

Called any time a game key is pressed. Key is a string that consisting of zero or more modifiers (Ctrl, Shift, Alt) and a base key. The base key for keys corresponding to a printable ASCII character is the upper-case version of that character. The base key for other keys is the label on the keycap (e.g. PageUp, PageDown, Home, End, Backspace, and so forth).

---------------------------------------------------
_G . CreateObject ( h: Handle )
[function callback] [global]
@param h Handle

The game object handle that was created.

Called after any game object is created. Handle is the game object that was created. This function will get a lot of traffic so it should not do too much work. Note that many game object functions may not work properly here.

---------------------------------------------------
_G . AddObject ( h: Handle )
[function callback] [global]
@param h Handle

The game object handle that was created.

Called after any game object is created. Handle is the game object that was created. This function will get a lot of traffic so it should not do too much work. Note that many game object functions may not work properly here.

---------------------------------------------------
_G . DeleteObject ( h: Handle )
[function callback] [global]
@param h Handle

The game object handle to be deleted.

Called before a game object is deleted. Handle is the game object to be deleted. This function will get a lot of traffic so it should not do too much work. Note: This is called after the object is largely removed from the game, so most Get functions won't return a valid value.

---------------------------------------------------
_G . Update ( dtime: number )
[function callback] [global]
@param dtime number

The time since the last tick in seconds.

Called once per tick after updating the network system and before simulating game objects. This function performs most of the mission script's game logic.

---------------------------------------------------
_G . CreatePlayer ( id: integer, name: string, team: integer )
[function callback] [global]
@param id integer

DPID number for this player

@param name string

name for this player

@param team integer

Team number for this player

Called when a player joins the game world.

---------------------------------------------------
_G . AddPlayer ( id: integer, name: string, team: integer )
[function callback] [global]
@param id integer

DPID number for this player

@param name string

name for this player

@param team integer

Team number for this player

Called when a player joins the game world.

---------------------------------------------------
_G . DeletePlayer ( id: integer, name: string, team: integer )
[function callback] [global]
@param id integer

DPID number for this player

@param name string

name for this player

@param team integer

Team number for this player

Called when a player leaves the game world.

---------------------------------------------------
_G . Command ( command: string, ...: any )
[function callback] [global]
@param command string

the command string

@param ... any

additional arguments

Command

---------------------------------------------------
_G . Receive ( from: integer, type: string, ...: any )
[function callback] [global]
@param from integer

x

@param type string

x

@param ... any

data

Receive

<<
---------------------------------------------------
Audio Messages
[section]

These functions control audio messages, 2D sounds typically used for radio messages, voiceovers, and narration. Audio messages use the Voice Volume setting from the Audio Options menu.

>>
---------------------------------------------------
_G . RepeatAudioMessage ( )
[function] [global]

Repeat the last audio message.

---------------------------------------------------
_G . AudioMessage ( filename: string ) -> [1]: AudioMessage
[function] [global]
@param filename string
@return [1] AudioMessage

Plays the given audio file, which must be an uncompressed RIFF WAVE (.WAV) file. Returns an audio message handle.

---------------------------------------------------
_G . IsAudioMessageDone ( msg: AudioMessage ) -> [1]: boolean
[function] [global]
@param msg AudioMessage
@return [1] boolean

Returns true if the audio message has stopped. Returns false otherwise.

---------------------------------------------------
_G . StopAudioMessage ( msg: AudioMessage )
[function] [global]
@param msg AudioMessage

Stops the given audio message.

---------------------------------------------------
_G . IsAudioMessagePlaying ( ) -> [1]: boolean
[function] [global]
@return [1] boolean

Returns true if any audio message is playing. Returns false otherwise.

<<
---------------------------------------------------
Sound Effects
[section]

These functions control sound effects, either positional 3D sounds attached to objects or global 2D sounds. Sound effects use the Effects Volume setting from the Audio Options menu.

>>
---------------------------------------------------
_G . StartSound ( filename: string, h: Handle?, priority: integer?, loop: boolean?, volume: integer?, rate: integer? )
[function] [global]
@param filename string
@param h Handle?
@param priority integer?
@param loop boolean?
@param volume integer?
@param rate integer?

Plays the given audio file, which must be an uncompressed RIFF WAVE (.WAV) file. Specifying an object handle creates a positional 3D sound that follows the object as it moves and stops automatically when the object goes away. Otherwise, the sound plays as a global 2D sound. Priority ranges from 0 to 100, with higher priorities taking precedence over lower priorities when there are not enough channels. The default priority is 50 if not specified. Looping sounds will play forever until explicitly stopped with StopSound or the object to which it is attached goes away. Non-looping sounds will play once and stop. The default is non-looping if not specified. Volume ranges from 0 to 100, with 0 being silent and 100 being maximum volume. The default volume is 100 if not specified. Rate overrides the playback rate of the sound file, so a value of 22050 would cause a sound file recorded at 11025 Hz to play back twice as fast. The rate defaults to the file's native rate if not specified.

---------------------------------------------------
_G . StopSound ( filename: string, h: Handle? )
[function] [global]
@param filename string
@param h Handle?

Stops the sound using the given filename and associated with the given object. Use a handle of none or nil to stop a global 2D sound.

<<
---------------------------------------------------
Game Object
[section]

These functions create, manipulate, and query game objects (vehicles, buildings, people, powerups, and scrap) and return or take as a parameter a game object handle. Object handles are always safe to use, even if the game object itself is missing or destroyed.

>>
---------------------------------------------------
_G . GetHandle ( label: string ) -> [1]: Handle?
[function] [global]
@param label string
@return [1] Handle?

Returns the handle of the game object with the given label. Returns nil if none exists.

---------------------------------------------------
_G . BuildObject ( odfname: string, teamnum: TeamNum, location: Handle|Matrix|Vector|string, point: integer? ) -> [1]: Handle?
[function] [global]
@param odfname string
@param teamnum TeamNum
@param location Handle|Matrix|Vector|string

Position vector, transform matrix, Object, or path name.

@param point integer?

If the location is a path this is the path point index, defaults to 0.

@return [1] Handle?

Creates a game object with the given odf name, team number, and location.

---------------------------------------------------
_G . RemoveObject ( h: Handle )
[function] [global]
@param h Handle

Removes the game object with the given handle.

---------------------------------------------------
_G . IsOdf ( h: Handle, odfname: string ) -> [1]: boolean
[function] [global]
@param h Handle
@param odfname string
@return [1] boolean

Returns true if the game object's odf name matches the given odf name. Returns false otherwise.

---------------------------------------------------
_G . GetOdf ( h: Handle ) -> [1]: string?
[function] [global]
@param h Handle
@return [1] string?

Returns the odf name of the game object. Returns nil if none exists.

---------------------------------------------------
_G . GetBase ( h: Handle ) -> [1]: string?
[function] [global]
@param h Handle
@return [1] string?

Returns the base config of the game object which determines what VDF/SDF model it uses. Returns nil if none exists.

---------------------------------------------------
_G . GetLabel ( h: Handle ) -> [1]: string?
[function] [global]
@param h Handle
@return [1] string?

Returns the label of the game object (e.g. "avtank0_wingman"). Returns nil if none exists.

---------------------------------------------------
_G . SetLabel ( h: Handle, label: string )
[function] [global]
@param h Handle
@param label string

Set the label of the game object (e.g. "tank1").

---------------------------------------------------
_G . GetClassSig ( h: Handle ) -> [1]: string?
[function] [global]
@param h Handle
@return [1] string?

Returns the four-character class signature of the game object (e.g. "WING"). Returns nil if none exists.

---------------------------------------------------
_G . GetClassLabel ( h: Handle ) -> [1]: string?
[function] [global]
@param h Handle
@return [1] string?

Returns the class label of the game object (e.g. "wingman"). Returns nil if none exists.

---------------------------------------------------
_G . GetClassId ( h: Handle ) -> [1]: integer?
[function] [global]
@param h Handle
@return [1] integer?

Returns the numeric class identifier of the game object. Returns nil if none exists. Looking up the class id number in the ClassId table will convert it to a string. Looking up the class id string in the ClassId table will convert it back to a number.

---------------------------------------------------
_G . ClassId : ClassId
[enum ClassId] [global]

This is a global table that converts between class identifier numbers and class identifier names. Many of these values likely never appear in game and are leftover from Interstate '76

---------------------------------------------------
_G . GetNation ( h: Handle ) -> [1]: string
[function] [global]
@param h Handle
@return [1] string

Returns the one-letter nation code of the game object (e.g. "a" for American, "b" for Black Dog, "c" for Chinese, and "s" for Soviet). The nation code is usually but not always the same as the first letter of the odf name. The ODF file can override the nation in the [GameObjectClass] section, and player.odf is a hard-coded exception that uses "a" instead of "p".

---------------------------------------------------
_G . IsValid ( h: Handle ) -> [1]: boolean
[function] [global]
@param h Handle
@return [1] boolean

Returns true if the game object exists. Returns false otherwise.

---------------------------------------------------
_G . IsAlive ( h: Handle ) -> [1]: boolean
[function] [global]
@param h Handle
@return [1] boolean

Returns true if the game object exists and (if the object is a vehicle) controlled. Returns false otherwise.

---------------------------------------------------
_G . IsAliveAndPilot ( h: Handle ) -> [1]: boolean
[function] [global]
@param h Handle
@return [1] boolean

Returns true if the game object exists and (if the object is a vehicle) controlled and piloted. Returns false otherwise.

---------------------------------------------------
_G . IsCraft ( h: Handle ) -> [1]: boolean
[function] [global]
@param h Handle
@return [1] boolean

Returns true if the game object exists and is a vehicle. Returns false otherwise.

---------------------------------------------------
_G . IsBuilding ( h: Handle ) -> [1]: boolean
[function] [global]
@param h Handle
@return [1] boolean

Returns true if the game object exists and is a building. Returns false otherwise.

---------------------------------------------------
_G . IsPerson ( h: Handle ) -> [1]: boolean
[function] [global]
@param h Handle
@return [1] boolean

Returns true if the game object exists and is a person. Returns false otherwise.

---------------------------------------------------
_G . IsDamaged ( h: Handle, threshold: number? ) -> [1]: boolean
[function] [global]
@param h Handle
@param threshold number?

float

@return [1] boolean

Returns true if the game object exists and has less health than the threshold. Returns false otherwise.

---------------------------------------------------
_G . IsRecycledByTeam ( h: Handle, team: TeamNum ) -> [1]: boolean
[function] [global] [version 2.1+]
@param h Handle
@param team TeamNum
@return [1] boolean

Returns true if the game object was recycled by a Construction Rig on the given team.

<<
---------------------------------------------------
Team Number
[section]

These functions get and set team number. Team 0 is the neutral or environment team.

>>
---------------------------------------------------
_G . GetTeamNum ( h: Handle ) -> [1]: TeamNum
[function] [global]
@param h Handle
@return [1] TeamNum

Returns the game object's team number.

---------------------------------------------------
_G . SetTeamNum ( h: Handle, team: TeamNum )
[function] [global]
@param h Handle
@param team TeamNum

Sets the game object's team number.

---------------------------------------------------
_G . GetPerceivedTeam ( h: Handle ) -> [1]: TeamNum
[function] [global]
@param h Handle
@return [1] TeamNum

Returns the game object's perceived team number (as opposed to its real team number). The perceived team will differ from the real team when a player enters an empty enemy vehicle without being seen until they attack something.

---------------------------------------------------
_G . SetPerceivedTeam ( h: Handle, t: TeamNum )
[function] [global]
@param h Handle
@param t TeamNum

Set the game object's perceived team number (as opposed to its real team number). Units on the game object's perceived team will treat it as friendly until it "blows its cover" by attacking, at which point it will revert to its real team. Units on the game object's real team will treat it as friendly regardless of its perceived team.

<<
---------------------------------------------------
Target
[section]

These function get and set a unit's target.

>>
---------------------------------------------------
_G . SetUserTarget ( t: Handle? )
[function] [global]
@param t Handle?

Sets the local player's target. @todo confirm target can be nil, if it can't this should be depricated

---------------------------------------------------
_G . GetUserTarget ( ) -> [1]: Handle?
[function] [global]
@return [1] Handle?

Returns the local player's target. Returns nil if it has none.

---------------------------------------------------
_G . SetTarget ( h: Handle, t: Handle? )
[function] [global]
@param h Handle
@param t Handle?

Sets the game object's target.

---------------------------------------------------
_G . GetTarget ( h: Handle ) -> [1]: Handle?
[function] [global]
@param h Handle
@return [1] Handle?

Returns the game object's target. Returns nil if it has none.

<<
---------------------------------------------------
Owner
[section]

These functions get and set owner. The default owner for a game object is the game object that created it.

>>
---------------------------------------------------
_G . SetOwner ( h: Handle, o: Handle? )
[function] [global]
@param h Handle
@param o Handle?

Sets the game object's owner. @todo confirm o can be nil

---------------------------------------------------
_G . GetOwner ( h: Handle ) -> [1]: Handle?
[function] [global]
@param h Handle
@return [1] Handle?

Returns the game object's owner. Returns nil if it has none.

<<
---------------------------------------------------
Pilot Class
[section]

These functions get and set vehicle pilot class.

>>
---------------------------------------------------
_G . SetPilotClass ( h: Handle, odfname: string? )
[function] [global]
@param h Handle
@param odfname string?

Sets the vehicle's pilot class to the given odf name. This does nothing useful for non-vehicle game objects. An odf name of nil resets the vehicle to the default assignment based on nation.

---------------------------------------------------
_G . GetPilotClass ( h: Handle ) -> [1]: string?
[function] [global]
@param h Handle
@return [1] string?

Returns the odf name of the vehicle's pilot class. Returns nil if none exists.

<<
---------------------------------------------------
Position and Orientation
[section]

These functions get and set position and orientation.

>>
---------------------------------------------------
_G . SetPosition ( h: Handle, target: Matrix|Vector|string, point: integer? )
[function] [global]
@param h Handle
@param target Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param point integer?

If the target is a path this is the path point index, defaults to 0.

Teleports the game object to a target location.

---------------------------------------------------
_G . GetPosition ( target: Handle|string, point: integer? ) -> [1]: Vector?
[function] [global]
@param target Handle|string
@param point integer?

If the target is a path this is the path point index, defaults to 0.

@return [1] Vector?

Returns the game object's or path point's position vector. Returns nil if none exists. @todo Can't depricate this because it's used for paths too, at least for now

---------------------------------------------------
_G . GetFront ( h: Handle ) -> [1]: Vector?
[function] [global]
@param h Handle
@return [1] Vector?

Returns the game object's front vector. Returns nil if none exists.

---------------------------------------------------
_G . SetTransform ( h: Handle, transform: Matrix )
[function] [global]
@param h Handle
@param transform Matrix

Teleports the game object to the given transform matrix.

---------------------------------------------------
_G . GetTransform ( h: Handle ) -> [1]: Matrix?
[function] [global]
@param h Handle
@return [1] Matrix?

Returns the game object's transform matrix. Returns nil if none exists.

<<
---------------------------------------------------
Linear Velocity
[section]

These functions get and set linear velocity.

>>
---------------------------------------------------
_G . GetVelocity ( h: Handle ) -> [1]: Vector
[function] [global]
@param h Handle
@return [1] Vector

Returns the game object's linear velocity vector. Returns nil if none exists.

---------------------------------------------------
_G . SetVelocity ( h: Handle, velocity: Vector )
[function] [global]
@param h Handle
@param velocity Vector

Sets the game object's angular velocity vector.

<<
---------------------------------------------------
Angular Velocity
[section]

These functions get and set angular velocity.

>>
---------------------------------------------------
_G . GetOmega ( h: Handle ) -> [1]: Vector
[function] [global]
@param h Handle
@return [1] Vector

Returns the game object's angular velocity vector. Returns nil if none exists.

---------------------------------------------------
_G . SetOmega ( h: Handle, omega: Vector )
[function] [global]
@param h Handle
@param omega Vector

Sets the game object's angular velocity vector.

<<
---------------------------------------------------
Position Helpers
[section]

These functions help generate position values close to a center point.

>>
---------------------------------------------------
_G . GetCircularPos ( center: Vector, radius: number?, angle: number? ) -> [1]: Vector
[function] [global]
@param center Vector
@param radius number?
@param angle number?
@return [1] Vector

Returns a ground position offset from the center by the radius in a direction controlled by the angle. If no radius is given, it uses a default radius of zero. If no angle is given, it uses a default angle of zero. An angle of zero is +X (due east), pi * 0.5 is +Z (due north), pi is -X (due west), and pi * 1.5 is -Z (due south).

---------------------------------------------------
_G . GetPositionNear ( center: Vector, minradius: number?, maxradius: number? ) -> [1]: Vector
[function] [global]
@param center Vector
@param minradius number?
@param maxradius number?
@return [1] Vector

Returns a ground position in a ring around the center between minradius and maxradius with roughly the same terrain height as the terrain height at the center. This is good for scattering spawn positions around a point while excluding positions that are too high or too low. If no radius is given, it uses the default radius of zero.

<<
---------------------------------------------------
Shot
[section]

These functions query a game object for information about ordnance hits.

>>
---------------------------------------------------
_G . GetWhoShotMe ( h: Handle ) -> [1]: Handle
[function] [global]
@param h Handle
@return [1] Handle

Returns who scored the most recent hit on the game object. Returns nil if none exists.

---------------------------------------------------
_G . GetLastEnemyShot ( h: Handle ) -> float: number
[function] [global]
@param h Handle
@return float number

Returns the last time an enemy shot the game object.

---------------------------------------------------
_G . GetLastFriendShot ( h: Handle ) -> float: number
[function] [global]
@param h Handle
@return float number

Returns the last time a friend shot the game object.

<<
---------------------------------------------------
Alliances
[section]

These functions control and query alliances between teams. The team manager assigns each player a separate team number, starting with 1 and going as high as 15. Team 0 is the neutral "environment" team. Unless specifically overridden, every team is friendly with itself, neutral with team 0, and hostile to everyone else.

>>
---------------------------------------------------
_G . DefaultAllies ( )
[function] [global]

Sets team alliances back to default.

---------------------------------------------------
_G . LockAllies ( lock: boolean )
[function] [global]
@param lock boolean

Sets whether team alliances are locked. Locking alliances prevents players from allying or un-allying, preserving alliances set up by the mission script.

---------------------------------------------------
_G . Ally ( team1: integer, team2: integer )
[function] [global]
@param team1 integer
@param team2 integer

Makes the two teams allies of each other. This function affects both teams so Ally(1, 2) and Ally(2, 1) produces the identical results, unlike the "half-allied" state created by the "ally" game key. {(i)(i)BZCC would require the use of Ally(1, 2) and Ally(2, 1) so if you are making portable code you will need both or will need to monkey-patch BZCC's version.}

---------------------------------------------------
_G . UnAlly ( team1: integer, team2: integer )
[function] [global]
@param team1 integer
@param team2 integer

Makes the two teams enemies of each other. This function affects both teams so UnAlly(1, 2) and UnAlly(2, 1) produces the identical results, unlike the "half-enemy" state created by the "unally" game key. {(i)(i)BZCC would require the use of UnAlly(1, 2) and UnAlly(2, 1) so if you are making portable code you will need both or will need to monkey-patch BZCC's version.}

---------------------------------------------------
_G . IsTeamAllied ( team1: integer, team2: integer ) -> [1]: boolean
[function] [global]
@param team1 integer
@param team2 integer
@return [1] boolean

Returns true if team1 considers team2 an ally. Returns false otherwise. Due to the possibility of player-initiated "half-alliances", IsTeamAllied(team1, team2) might not return the same result as IsTeamAllied(team2, team1).

---------------------------------------------------
_G . IsAlly ( me: Handle, him: Handle ) -> [1]: boolean
[function] [global]
@param me Handle
@param him Handle
@return [1] boolean

Returns true if game object "me" considers game object "him" an ally. Returns false otherwise. Due to the possibility of player-initiated "half-alliances", IsAlly(me, him) might not return the same result as IsAlly(him, me).

<<
---------------------------------------------------
Objective Marker
[section]

These functions control objective markers. Objectives are visible to all teams from any distance and from any direction, with an arrow pointing to off-screen objectives. There is currently no way to make team-specific objectives.

>>
---------------------------------------------------
_G . SetObjectiveOn ( h: Handle )
[function] [global]
@param h Handle

Sets the game object as an objective to all teams.

---------------------------------------------------
_G . SetObjectiveOff ( h: Handle )
[function] [global]
@param h Handle

Sets the game object back to normal.

---------------------------------------------------
_G . IsObjectiveOn ( h: Handle ) -> [1]: boolean
[function] [global]
@param h Handle
@return [1] boolean

Get the objective on status of object. [UNRELEASED]

---------------------------------------------------
_G . GetObjectiveName ( h: Handle ) -> [1]: string
[function] [global]
@param h Handle
@return [1] string

Gets the game object's visible name.

---------------------------------------------------
_G . SetObjectiveName ( h: Handle, name: string )
[function] [global]
@param h Handle
@param name string

Sets the game object's visible name.

---------------------------------------------------
_G . SetName ( h: Handle, name: string )
[function] [global] [version 2.1+]
@param h Handle
@param name string

Sets the game object's visible name. This function is effectively an alias for SetObjectiveName.

<<
---------------------------------------------------
Distance
[section]

These functions measure and return the distance between a game object and a reference point.

>>
---------------------------------------------------
_G . GetDistance ( h1: Handle, target: Handle|Matrix|Vector|string, point: integer? ) -> [1]: number
[function] [global]
@param h1 Handle
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param point integer?

If the target is a path this is the path point index, defaults to 0.

@return [1] number

Returns the distance in meters between the game object and a position vector, transform matrix, another object, or point on a named path.

---------------------------------------------------
_G . IsWithin ( h1: Handle, h2: Handle, dist: number ) -> [1]: boolean
[function] [global]
@param h1 Handle
@param h2 Handle
@param dist number
@return [1] boolean

Returns true if the units are closer than the given distance of each other. Returns false otherwise. (This function is equivalent to GetDistance (h1, h2) < d)

---------------------------------------------------
_G . IsTouching ( h1: Handle, h2: Handle, tolerance: number? ) -> [1]: boolean
[function] [global] [version 2.1+]
@param h1 Handle
@param h2 Handle
@param tolerance number?
@return [1] boolean

Returns true if the bounding spheres of the two game objects are within the specified tolerance. The default tolerance is 1.3 meters if not specified.

<<
---------------------------------------------------
Nearest
[section]

These functions find and return the game object of the requested type closest to a reference point.

>>
---------------------------------------------------
_G . GetNearestObject ( target: Handle|Matrix|Vector|string, point: integer? ) -> [1]: Handle
[function] [global]
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param point integer?

If the target is a path this is the path point index, defaults to 0.

@return [1] Handle

Returns the game object closest to a position vector, transform matrix, another object, or point on a named path.

---------------------------------------------------
_G . GetNearestVehicle ( target: Handle|Matrix|Vector|string, point: integer? ) -> [1]: Handle
[function] [global]
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param point integer?

If the target is a path this is the path point index, defaults to 0.

@return [1] Handle

Returns the craft closest to a position vector, transform matrix, another object, or point on a named path.

---------------------------------------------------
_G . GetNearestBuilding ( target: Handle|Matrix|Vector|string, point: integer? ) -> [1]: Handle
[function] [global]
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param point integer?

If the target is a path this is the path point index, defaults to 0.

@return [1] Handle

Returns the building closest to a position vector, transform matrix, another object, or point on a named path.

---------------------------------------------------
_G . GetNearestEnemy ( target: Handle|Matrix|Vector|string, point: integer? ) -> [1]: Handle
[function] [global]
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param point integer?

If the target is a path this is the path point index, defaults to 0.

@return [1] Handle

Returns the enemy closest to a position vector, transform matrix, another object, or point on a named path.

---------------------------------------------------
_G . GetNearestFriend ( target: Handle|Matrix|Vector|string, point: integer? ) -> [1]: Handle
[function] [global] [version 2.0+]
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param point integer?

If the target is a path this is the path point index, defaults to 0.

@return [1] Handle

Returns the friend closest to a position vector, transform matrix, another object, or point on a named path.

---------------------------------------------------
_G . GetNearestUnitOnTeam ( h: Handle ) -> handle: Handle?
[function overload] [global] [version 2.0+]
_G . GetNearestUnitOnTeam ( position: Vector ) -> handle: Handle?
[function overload] [global] [version 2.1+]
_G . GetNearestUnitOnTeam ( transform: Matrix ) -> handle: Handle?
[function overload] [global] [version 2.1+]
_G . GetNearestUnitOnTeam ( path: string, point: integer? ) -> handle: Handle?
[function overload] [global] [version 2.1+]
@param h Handle

The reference game object.

@param position Vector

The position vector.

@param transform Matrix

The transform matrix.

@param path string

The path name.

@param point integer?

The point on the path (optional).

@return handle Handle?

closest friend, or nil if none exists.

Returns the friend closest to the given reference point. Returns nil if none exists.

---------------------------------------------------
_G . CountUnitsNearObject ( h: Handle, dist: number, team: TeamNum, odfname: string ) -> [1]: integer
[function] [global]
@param h Handle
@param dist number
@param team TeamNum
@param odfname string
@return [1] integer

Returns how many objects with the given team and odf name are closer than the given distance.

<<
---------------------------------------------------
Iterators
[section]

These functions return iterator functions for use with Lua's "for in do ... end" form. For example: "for h in AllCraft() do print(h, GetLabel(h)) end" will print the game object handle and label of every craft in the world.

>>
---------------------------------------------------
_G . ObjectsInRange ( dist: number, target: Handle|Matrix|Vector|string, point: integer? ) -> iterator: fun():Handle
[function] [global]
@param dist number
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param point integer?

If the target is a path this is the path point index, defaults to 0.

@return iterator fun():Handle

Enumerates game objects within the given distance a target.

---------------------------------------------------
_G . AllObjects ( ) -> iterator: fun():Handle
[function] [global]
@return iterator fun():Handle

Enumerates all game objects. Use this function sparingly at runtime since it enumerates all game objects, including every last piece of scrap. If you're specifically looking for craft, use AllCraft() instead.

---------------------------------------------------
_G . AllCraft ( ) -> iterator: fun():Handle
[function] [global]
@return iterator fun():Handle

Enumerates all craft.

---------------------------------------------------
_G . SelectedObjects ( ) -> iterator: fun():Handle
[function] [global]
@return iterator fun():Handle

Enumerates all game objects currently selected by the local player.

---------------------------------------------------
_G . ObjectiveObjects ( ) -> iterator: fun():Handle
[function] [global]
@return iterator fun():Handle

Enumerates all game objects marked as objectives.

<<
---------------------------------------------------
Scrap Management
[section]

These functions remove scrap, either to reduce the global game object count or to remove clutter around a location.

>>
---------------------------------------------------
_G . GetRidOfSomeScrap ( limit: integer? )
[function] [global]
@param limit integer?

While the global scrap count is above the limit, remove the oldest scrap piece. It no limit is given, it uses the default limit of 300.

---------------------------------------------------
_G . ClearScrapAround ( distance: number, target: Handle|Matrix|Vector|string, point: integer? )
[function] [global]
@param distance number
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param point integer?

Clear all scrap within the given distance of a position vector, transform matrix, game object, or named path. It uses the start of the path if no point is given.

<<
---------------------------------------------------
Team Slots
[section]

These functions look up game objects in team slots.

>>
---------------------------------------------------
_G . TeamSlot : TeamSlot
[enum TeamSlot] [global]

This is a global table that converts between team slot numbers and team slot names. For example, TeamSlot.PLAYER or TeamSlot["PLAYER"] returns the team slot (0) for the player; TeamSlot[0] returns the team slot name ("PLAYER") for team slot 0. For maintainability, always use this table instead of raw team slot numbers. Slots starting with MIN_ and MAX_ represent the lower and upper bound of a range of slots.

---------------------------------------------------
_G . GetTeamSlot ( slot: TeamSlotInteger, team: TeamNum? ) -> [1]: Handle
[function] [global]
@param slot TeamSlotInteger
@param team TeamNum?
@return [1] Handle

Get the game object in the specified team slot. It uses the local player team if no team is given. @note Team slots badly lag behind for remote players, even though the object will exist on the local machine as a remote tagged object. This affects all TeamSlot based functions.

---------------------------------------------------
_G . GetPlayerHandle ( team: TeamNum? ) -> [1]: Handle
[function] [global]
@param team TeamNum?
@return [1] Handle

Returns the game object controlled by the player on the given team. Returns nil if none exists. It uses the local player team if no team is given.

---------------------------------------------------
_G . GetRecyclerHandle ( team: TeamNum? ) -> [1]: Handle
[function] [global]
@param team TeamNum?
@return [1] Handle

Returns the Recycler on the given team. Returns nil if none exists. It uses the local player team if no team is given.

---------------------------------------------------
_G . GetFactoryHandle ( team: TeamNum? ) -> [1]: Handle
[function] [global]
@param team TeamNum?
@return [1] Handle

Returns the Factory on the given team. Returns nil if none exists. It uses the local player team if no team is given.

---------------------------------------------------
_G . GetArmoryHandle ( team: TeamNum? ) -> [1]: Handle
[function] [global]
@param team TeamNum?
@return [1] Handle

Returns the Armory on the given team. Returns nil if none exists. It uses the local player team if no team is given.

---------------------------------------------------
_G . GetConstructorHandle ( team: TeamNum? ) -> [1]: Handle
[function] [global]
@param team TeamNum?
@return [1] Handle

Returns the Constructor on the given team. Returns nil if none exists. It uses the local player team if no team is given.

<<
---------------------------------------------------
Team Pilots
[section]

These functions get and set pilot counts for a team.

>>
---------------------------------------------------
_G . AddPilot ( team: TeamNum, count: integer ) -> [1]: integer
[function] [global]
@param team TeamNum
@param count integer
@return [1] integer

Adds pilots to the team's pilot count, clamped between zero and maximum count. Returns the new pilot count.

---------------------------------------------------
_G . SetPilot ( team: TeamNum, count: integer ) -> [1]: integer
[function] [global]
@param team TeamNum
@param count integer
@return [1] integer

Sets the team's pilot count, clamped between zero and maximum count. Returns the new pilot count.

---------------------------------------------------
_G . GetPilot ( team: TeamNum ) -> [1]: integer
[function] [global]
@param team TeamNum
@return [1] integer

Returns the team's pilot count.

---------------------------------------------------
_G . AddMaxPilot ( team: TeamNum, count: integer ) -> [1]: integer
[function] [global]
@param team TeamNum
@param count integer
@return [1] integer

Adds pilots to the team's maximum pilot count. Returns the new pilot count.

---------------------------------------------------
_G . SetMaxPilot ( team: TeamNum, count: integer ) -> [1]: integer
[function] [global]
@param team TeamNum
@param count integer
@return [1] integer

Sets the team's maximum pilot count. Returns the new pilot count.

---------------------------------------------------
_G . GetMaxPilot ( team: TeamNum ) -> [1]: integer
[function] [global]
@param team TeamNum
@return [1] integer

Returns the team's maximum pilot count.

<<
---------------------------------------------------
Team Scrap
[section]

These functions get and set scrap values for a team.

>>
---------------------------------------------------
_G . AddScrap ( team: TeamNum, count: integer ) -> [1]: integer
[function] [global]
@param team TeamNum
@param count integer
@return [1] integer

Adds to the team's scrap count, clamped between zero and maximum count. Returns the new scrap count.

---------------------------------------------------
_G . SetScrap ( team: TeamNum, count: integer ) -> [1]: integer
[function] [global]
@param team TeamNum
@param count integer
@return [1] integer

Sets the team's scrap count, clamped between zero and maximum count. Returns the new scrap count.

---------------------------------------------------
_G . GetScrap ( team: TeamNum ) -> [1]: integer
[function] [global]
@param team TeamNum
@return [1] integer

Returns the team's scrap count.

---------------------------------------------------
_G . AddMaxScrap ( team: TeamNum, count: integer ) -> [1]: integer
[function] [global]
@param team TeamNum
@param count integer
@return [1] integer

Adds to the team's maximum scrap count. Returns the new maximum scrap count.

---------------------------------------------------
_G . SetMaxScrap ( team: TeamNum, count: integer ) -> [1]: integer
[function] [global]
@param team TeamNum
@param count integer
@return [1] integer

Sets the team's maximum scrap count. Returns the new maximum scrap count.

---------------------------------------------------
_G . GetMaxScrap ( team: TeamNum ) -> [1]: integer
[function] [global]
@param team TeamNum
@return [1] integer

Returns the team's maximum scrap count.

<<
---------------------------------------------------
Deploy
[section]

These functions control deployable craft (such as Turret Tanks or Producer units).

>>
---------------------------------------------------
_G . IsDeployed ( h: Handle ) -> [1]: boolean
[function] [global]
@param h Handle
@return [1] boolean

Returns true if the game object is a deployed craft. Returns false otherwise.

---------------------------------------------------
_G . Deploy ( h: Handle )
[function] [global]
@param h Handle

Tells the game object to deploy.

<<
---------------------------------------------------
Selection
[section]

These functions access selection state (i.e. whether the player has selected a game object)

>>
---------------------------------------------------
_G . IsSelected ( h: Handle ) -> [1]: boolean
[function] [global]
@param h Handle
@return [1] boolean

Returns true if the game object is selected. Returns false otherwise.

<<
---------------------------------------------------
Mission-Critical
[section] [version 2.0+]

The "mission critical" property indicates that a game object is vital to the success of the mission and disables the "Pick Me Up" and "Recycle" commands that (eventually) cause IsAlive() to report false.

>>
---------------------------------------------------
_G . IsCritical ( h: Handle ) -> [1]: boolean
[function] [global] [version 2.0+]
@param h Handle
@return [1] boolean

Returns true if the game object is marked as mission-critical. Returns false otherwise.

---------------------------------------------------
_G . SetCritical ( h: Handle, critical: boolean? )
[function] [global] [version 2.0+]
@param h Handle
@param critical boolean?

Sets the game object's mission-critical status. If critical is true or not specified, the object is marked as mission-critical. Otherwise, the object is marked as not mission critical.

<<
---------------------------------------------------
Weapon
[section]

These functions access unit weapons and damage.

>>
---------------------------------------------------
_G . SetWeaponMask ( h: Handle, mask: integer )
[function] [global]
@param h Handle
@param mask integer

Sets what weapons the unit's AI process will use. To calculate the mask value, add up the values of the weapon hardpoint slots you want to enable. weaponHard1: 1 weaponHard2: 2 weaponHard3: 4 weaponHard4: 8 weaponHard5: 16

---------------------------------------------------
_G . GiveWeapon ( h: Handle, weaponname: string?, slot: integer? ) -> success: boolean
[function] [global]
@param h Handle
@param weaponname string?
@param slot integer?
@return success boolean

Gives the game object the named weapon in the given slot. If no slot is given, it chooses a slot based on hardpoint type and weapon priority like a weapon powerup would. If the weapon name is empty, nil, or blank and a slot is given, it removes the weapon in that slot. Returns true if it succeeded. Returns false otherwise.

---------------------------------------------------
_G . GetWeaponClass ( h: Handle, slot: integer ) -> [1]: string?
[function] [global]
@param h Handle
@param slot integer
@return [1] string?

Returns the odf name of the weapon in the given slot on the game object. Returns nil if the game object does not exist or the slot is empty. For example, an "avtank" game object would return "gatstab" for index 0 and "gminigun" for index 1.

Remarks: Unsafe in CreateObject, will always return nil, should be deferred until the next Update

---------------------------------------------------
_G . FireAt ( me: Handle, him: Handle )
[function] [global]
@param me Handle
@param him Handle

Tells the game object to fire at the given target.

---------------------------------------------------
_G . Damage ( h: Handle, amount: number )
[function] [global]
@param h Handle
@param amount number

Applies damage to the game object.

<<
---------------------------------------------------
Time
[section]

These function report various global time values.

>>
---------------------------------------------------
_G . GetTime ( ) -> [1]: number
[function] [global]
@return [1] number

Returns the elapsed time in seconds since the start of the mission.

---------------------------------------------------
_G . GetTimeStep ( ) -> [1]: number
[function] [global]
@return [1] number

Returns the simulation time step in seconds.

---------------------------------------------------
_G . GetTimeNow ( ) -> [1]: number
[function] [global]
@return [1] number

Returns the current system time in milliseconds. This is mostly useful for performance profiling.

<<
---------------------------------------------------
Mission
[section]

These functions control general mission properties like strategic AI and mission flow

>>
---------------------------------------------------
_G . SetAIControl ( team: TeamNum, control: boolean? )
[function] [global]
@param team TeamNum
@param control boolean?

defaults to true

Enables (or disables) strategic AI control for a given team. As of version 1.5.2.7, mission scripts must enable AI control for any team that intends to use an AIP.

---------------------------------------------------
_G . GetAIControl ( team: TeamNum ) -> [1]: boolean
[function] [global]
@param team TeamNum
@return [1] boolean

Returns true if a given team is AI controlled. Returns false otherwise. Unlike SetAIControl, this function may be called at any time.

---------------------------------------------------
_G . GetAIP ( team: TeamNum? ) -> [1]: string
[function] [global]
@param team TeamNum?
@return [1] string

Returns the current AIP for the team. It uses team 2 if no team number is given.

---------------------------------------------------
_G . SetAIP ( aipname: string, team: TeamNum? )
[function] [global]
@param aipname string
@param team TeamNum?

Switches the team's AI plan. It uses team 2 if no team number is given.

---------------------------------------------------
_G . FailMission ( time: number, filename: string? )
[function] [global]
@param time number
@param filename string?

Fails the mission after the given time elapses. If supplied with a filename (usually a .des), it sets the failure message to text from that file.

---------------------------------------------------
_G . SucceedMission ( time: number, filename: string? )
[function] [global]
@param time number
@param filename string?

Succeeds the mission after the given time elapses. If supplied with a filename (usually a .des), it sets the success message to text from that file.

<<
---------------------------------------------------
Objective Messages
[section]

These functions control the objective panel visible at the right of the screen.

>>
---------------------------------------------------
_G . ClearObjectives ( )
[function] [global]

Clears all objective messages.

---------------------------------------------------
_G . AddObjective ( name: string, color: ColorLabel?, duration: number?, text: string? )
[function] [global]
@param name string

Unique name for objective, usually a filename ending with otf from which data is loaded

@param color ColorLabel?

Default to "WHITE".

@param duration number?

defaults to 8 seconds

@param text string?
[version 2.0+]

Override text from the target objective file.

Adds an objective message with the given name and properties.

---------------------------------------------------
_G . UpdateObjective ( name: string, color: ColorLabel?, duration: number?, text: string? )
[function] [global]
@param name string

Unique name for objective, usually a filename ending with otf from which data is loaded

@param color ColorLabel?

Default to "WHITE".

@param duration number?

defaults to 8 seconds

@param text string?
[version 2.0+]

Override text from the target objective file.

Updates the objective message with the given name. If no objective exists with that name, it does nothing.

---------------------------------------------------
_G . RemoveObjective ( name: string )
[function] [global]
@param name string

Removes the objective message with the given file name. Messages after the removed message will be moved up to fill the vacancy. If no objective exists with that file name, it does nothing.

<<
---------------------------------------------------
Cockpit Timer
[section]

These functions control the large timer at the top of the screen.

>>
---------------------------------------------------
_G . StartCockpitTimer ( time: integer, warn: integer?, alert: integer? )
[function] [global]
@param time integer
@param warn integer?
@param alert integer?

Starts the cockpit timer counting down from the given time. If a warn time is given, the timer will turn yellow when it reaches that value. If an alert time is given, the timer will turn red when it reaches that value. All time values are in seconds. The start time can be up to 35999, which will appear on-screen as 9:59:59. If the remaining time is an hour or less, the timer will show only minutes and seconds.

---------------------------------------------------
_G . StartCockpitTimerUp ( time: integer, warn: integer?, alert: integer? )
[function] [global]
@param time integer
@param warn integer?
@param alert integer?

Starts the cockpit timer counting up from the given time. If a warn time is given, the timer will turn yellow when it reaches that value. If an alert time is given, the timer will turn red when it reaches that value. All time values are in seconds. The on-screen timer will always show hours, minutes, and seconds The hours digit will malfunction after 10 hours.

---------------------------------------------------
_G . StopCockpitTimer ( )
[function] [global]

Stops the cockpit timer.

---------------------------------------------------
_G . HideCockpitTimer ( )
[function] [global]

Hides the cockpit timer.

---------------------------------------------------
_G . GetCockpitTimer ( ) -> [1]: integer
[function] [global]
@return [1] integer

Returns the current time in seconds on the cockpit timer.

<<
---------------------------------------------------
Earthquake
[section]

These functions control the global earthquake effect.

>>
---------------------------------------------------
_G . StartEarthquake ( magnitude: number )
[function] [global]
@param magnitude number

Starts a global earthquake effect.

---------------------------------------------------
_G . UpdateEarthQuake ( magnitude: number )
[function] [global]
@param magnitude number

Changes the magnitude of an existing earthquake effect. Important: note the inconsistent capitalization, which matches the internal C++ script utility functions.

---------------------------------------------------
_G . StopEarthquake ( )
[function] [global]

Stops the global earthquake effect.

<<
---------------------------------------------------
Path Type
[section]

These functions get and set the looping type of a path. Looking up the path type number in the PathType table will convert it to a string. Looking up the path type string in the PathType table will convert it to a number.

  1. one-way
  2. round-trip
  3. loop
>>
---------------------------------------------------
_G . SetPathType ( path: string, type: integer )
[function] [global] [version 2.0+]
@param path string
@param type integer

Changes the named path to the given path type.

---------------------------------------------------
_G . GetPathType ( path: string ) -> [1]: integer
[function] [global] [version 2.0+]
@param path string
@return [1] integer

Returns the type of the named path.

---------------------------------------------------
_G . SetPathOneWay ( path: string )
[function] [global]
@param path string

Changes the named path to one-way. Once a unit reaches the end of the path, it will stop.

---------------------------------------------------
_G . SetPathRoundTrip ( path: string )
[function] [global]
@param path string

Changes the named path to round-trip. Once a unit reaches the end of the path, it will follow the path backwards to the start and begin again.

---------------------------------------------------
_G . SetPathLoop ( path: string )
[function] [global]
@param path string

Changes the named path to looping. Once a unit reaches the end of the path, it will continue along to the start and begin again.

<<
---------------------------------------------------
Path Points
[section] [version 2.0+]
>>
---------------------------------------------------
_G . GetPathPointCount ( path: string ) -> [1]: integer
[function] [global] [version 2.0+]
@param path string
@return [1] integer

Returns the number of points in the named path, or 0 if the path does not exist.

<<
---------------------------------------------------
Path Area
[section] [version 2.0+]

These functions treat a path as the boundary of a closed polygonal area.

>>
---------------------------------------------------
_G . GetWindingNumber ( path: string, target: Matrix|Vector|string ) -> [1]: integer
[function] [global] [version 2.0+]
@param path string
@param target Matrix|Vector|string
@return [1] integer

Returns how many times the named path loops around the given position vector, transform matrix, or object. Each full counterclockwise loop adds one and each full clockwise loop subtracts one.

---------------------------------------------------
_G . IsInsideArea ( path: string, target: Handle|Matrix|Vector ) -> [1]: boolean
[function] [global] [version 2.0+]
@param path string
@param target Handle|Matrix|Vector
@return [1] boolean

Returns true if the given position vector, transform matrix, or object is inside the area bounded by the named path. Returns false otherwise. This function is equivalent to

GetWindingNumber( path, h ) ~= 0

<<
---------------------------------------------------
Unit Commands
[section]

These These functions send commands to units or query their command state.

>>
---------------------------------------------------
_G . AiCommand : AiCommand
[enum AiCommand] [global]

This is a global table that converts between command numbers and command names. For example, AiCommand.GO or AiCommand["GO"] returns the command number (3) for the "go" command; AiCommand[3] returns the command name ("GO") for command number 3. For maintainability, always use this table instead of raw command numbers.

---------------------------------------------------
_G . CanCommand ( me: Handle ) -> [1]: boolean
[function] [global]
@param me Handle
@return [1] boolean

Returns true if the game object can be commanded. Returns false otherwise.

---------------------------------------------------
_G . CanBuild ( me: Handle ) -> [1]: boolean
[function] [global]
@param me Handle
@return [1] boolean

Returns true if the game object is a producer that can build at the moment. Returns false otherwise.

---------------------------------------------------
_G . IsBusy ( me: Handle ) -> [1]: boolean
[function] [global]
@param me Handle
@return [1] boolean

Returns true if the game object is a producer and currently busy. Returns false otherwise.

---------------------------------------------------
_G . IsAtEndOfPath ( me: Handle, path: string ) -> [1]: boolean
[function] [global] [version 2.1+]
@param me Handle
@param path string
@return [1] boolean

Returns true if the game object has reached the end of the named path. Returns false otherwise.

---------------------------------------------------
_G . GetCurrentCommand ( me: Handle ) -> [1]: AiCommand
[function] [global]
@param me Handle
@return [1] AiCommand

Returns the current command for the game object. Looking up the command number in the AiCommand table will convert it to a string. Looking up the command string in the AiCommand table will convert it back to a number.

---------------------------------------------------
_G . GetCurrentWho ( me: Handle ) -> [1]: Handle
[function] [global]
@param me Handle
@return [1] Handle

Returns the target of the current command for the game object. Returns nil if it has none.

---------------------------------------------------
_G . GetIndependence ( me: Handle ) -> [1]: integer
[function] [global]
@param me Handle
@return [1] integer

Gets the independence of a unit.

---------------------------------------------------
_G . SetIndependence ( me: Handle, independence: integer )
[function] [global]
@param me Handle
@param independence integer

Sets the independence of a unit. 1 (the default) lets the unit take initiative (e.g. attack nearby enemies), while 0 prevents that.

---------------------------------------------------
_G . SetCommand ( me: Handle, command: integer, priority: integer?, who: Handle?, where: Matrix|Vector|string|nil, when: number?, param: string? )
[function] [global]
@param me Handle
@param command integer
@param priority integer?
@param who Handle?
@param where Matrix|Vector|string|nil
@param when number?
@param param string?

Commands the unit using the given parameters. Be careful with this since not all commands work with all units and some have strict requirements on their parameters. "Command" is the command to issue, normally chosen from the global AiCommand table (e.g. AiCommand.GO). "Priority" is the command priority; a value of 0 leaves the unit commandable by the player while the default value of 1 makes it uncommandable. "Who" is an optional target game object. "Where" is an optional destination, and can be a matrix (transform), a vector (position), or a string (path name). "When" is an optional absolute time value only used by command AiCommand.STAGE. "Param" is an optional odf name only used by command AiCommand.BUILD.

---------------------------------------------------
_G . Attack ( me: Handle, him: Handle, priority: integer? )
[function] [global]
@param me Handle
@param him Handle
@param priority integer?

Commands the unit to attack the given target. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Goto ( me: Handle, target: Handle|Matrix|Vector|string, priority: integer? )
[function] [global]
@param me Handle
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param priority integer?

Commands the unit to go to the position vector, transform matrix, game object location, or named path. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Mine ( me: Handle, target: Matrix|Vector|string, priority: integer? )
[function] [global]
@param me Handle
@param target Matrix|Vector|string
@param priority integer?

Commands the unit to lay mines at the given position vector, transform matrix, or named path. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Follow ( me: Handle, him: Handle, priority: integer? )
[function] [global]
@param me Handle
@param him Handle
@param priority integer?

Commands the unit to follow the given target. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . IsFollowing ( me: Handle, him: Handle ) -> [1]: boolean
[function] [global] [version 2.1+]
@param me Handle
@param him Handle
@return [1] boolean

Returns true if the unit is currently following the given target.

---------------------------------------------------
_G . Defend ( me: Handle, priority: integer? )
[function] [global]
@param me Handle
@param priority integer?

Commands the unit to defend its current location. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Defend2 ( me: Handle, him: Handle, priority: integer? )
[function] [global]
@param me Handle
@param him Handle
@param priority integer?

Commands the unit to defend the given target. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Stop ( me: Handle, priority: integer? )
[function] [global]
@param me Handle
@param priority integer?

Commands the unit to stop at its current location. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Patrol ( me: Handle, path: string, priority: integer? )
[function] [global]
@param me Handle
@param path string
@param priority integer?

Commands the unit to patrol along the named path. This is equivalent to Goto with an independence of 1. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Retreat ( me: Handle, target: Handle|string, priority: integer? )
[function] [global]
@param me Handle
@param target Handle|string
@param priority integer?

Commands the unit to retreat to the given target or named path. This is equivalent to Goto with an independence of 0. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . GetIn ( me: Handle, him: Handle, priority: integer? )
[function] [global]
@param me Handle
@param him Handle
@param priority integer?

Commands the pilot to get into the target vehicle. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Pickup ( me: Handle, him: Handle, priority: integer? )
[function] [global]
@param me Handle
@param him Handle
@param priority integer?

Commands the unit to pick up the target object. Deployed units pack up (ignoring the target), scavengers pick up scrap, and tugs pick up and carry objects. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Dropoff ( me: Handle, target: Matrix|Vector|string, priority: integer? )
[function] [global]
@param me Handle
@param target Matrix|Vector|string
@param priority integer?

Commands the unit to drop off at the position vector, transform matrix, or named path. Tugs drop off their cargo and Construction Rigs build the selected item at the location using their current facing. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Build ( me: Handle, odfname: string, priority: integer? )
[function] [global]
@param me Handle
@param odfname string
@param priority integer?

Commands a producer to build the given odf name. The Armory and Construction Rig need an additional Dropoff to give them a location to build but first need at least one simulation update to process the Build. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . BuildAt ( me: Handle, odfname: string, target: Handle|Matrix|Vector|string, priority: integer? )
[function] [global]
@param me Handle
@param odfname string
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param priority integer?

Commands a producer to build the given odf name at the position vector, transform matrix, game object location, or named path. A Construction Rig will build at the location and an Armory will launch the item to the location. Other producers will ignore the location. Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Formation ( me: Handle, him: Handle, priority: integer? )
[function] [global] [version 2.2.315+]
@param me Handle
@param him Handle
@param priority integer?

Commands the unit to follow the given target closely. This function is equivalent to SetCommand(me, AiCommand.FORMATION, priority, him). Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

{(!!)Version(!!)While this was added in version 2.1 it is broken and must be monkey-patched to use SetCommand instead. The game in error treats the function as if it was Formation(me, priority) before version 2.2.315+.}

---------------------------------------------------
_G . Hunt ( me: Handle, priority: integer? )
[function] [global] [version 2.1+]
@param me Handle
@param priority integer?

Commands the unit to hunt for targets autonomously. This function is equivalent to SetCommand(me, AiCommand.HUNT, priority). Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

---------------------------------------------------
_G . Recycle ( me: Handle, priority: integer? )
[function] [global] [version 2.1+]
@param me Handle
@param priority integer?

Commands the unit to recycle. This function is equivalent to SetCommand(me, AiCommand.RECYCLE, priority). Priority 0 leaves the unit commandable while the default priority 1 makes it uncommandable.

<<
---------------------------------------------------
Tug Cargo
[section]

These functions query Tug and Cargo.

>>
---------------------------------------------------
_G . HasCargo ( tug: Handle ) -> [1]: boolean
[function] [global]
@param tug Handle
@return [1] boolean

Returns true if the unit is a tug carrying cargo.

---------------------------------------------------
_G . GetCargo ( tug: Handle ) -> [1]: Handle?
[function] [global] [version 2.1+]
@param tug Handle
@return [1] Handle?

Returns the handle of the cargo if the unit is a tug carrying cargo. Returns nil otherwise.

---------------------------------------------------
_G . GetTug ( cargo: Handle ) -> [1]: Handle
[function] [global]
@param cargo Handle
@return [1] Handle

Returns the handle of the tug carrying the object. Returns nil if not carried.

<<
---------------------------------------------------
Pilot Actions
[section]

These functions control the pilot of a vehicle.

>>
---------------------------------------------------
_G . EjectPilot ( h: Handle )
[function] [global]
@param h Handle

Commands the vehicle's pilot to eject.

---------------------------------------------------
_G . HopOut ( h: Handle )
[function] [global]
@param h Handle

Commands the vehicle's pilot to hop out.

---------------------------------------------------
_G . KillPilot ( h: Handle )
[function] [global]
@param h Handle

Kills the vehicle's pilot as if sniped.

---------------------------------------------------
_G . RemovePilot ( h: Handle )
[function] [global]
@param h Handle

Removes the vehicle's pilot cleanly.

---------------------------------------------------
_G . HoppedOutOf ( h: Handle ) -> [1]: Handle
[function] [global]
@param h Handle
@return [1] Handle

Returns the vehicle that the pilot most recently hopped out of.

<<
---------------------------------------------------
Health Values
[section]

These functions get and set health values on a game object.

>>
---------------------------------------------------
_G . GetHealth ( h: Handle ) -> [1]: number
[function] [global]
@param h Handle
@return [1] number

Returns the fractional health of the game object between 0 and 1.

---------------------------------------------------
_G . GetCurHealth ( h: Handle ) -> [1]: number
[function] [global]
@param h Handle
@return [1] number

Returns the current health value of the game object.

---------------------------------------------------
_G . GetMaxHealth ( h: Handle ) -> [1]: number
[function] [global]
@param h Handle
@return [1] number

Returns the maximum health value of the game object.

---------------------------------------------------
_G . SetCurHealth ( h: Handle, health: number )
[function] [global]
@param h Handle
@param health number

Sets the current health of the game object.

---------------------------------------------------
_G . SetMaxHealth ( h: Handle, health: number )
[function] [global]
@param h Handle
@param health number

Sets the maximum health of the game object.

---------------------------------------------------
_G . AddHealth ( h: Handle, health: number )
[function] [global]
@param h Handle
@param health number

Adds to the current health of the game object.

---------------------------------------------------
_G . GiveMaxHealth ( h: Handle )
[function] [global] [version 2.1+]
@param h Handle

Sets the unit's current health to maximum.

<<
---------------------------------------------------
Ammo Values
[section]

These functions get and set ammo values on a game object.

>>
---------------------------------------------------
_G . GetAmmo ( h: Handle ) -> [1]: number
[function] [global]
@param h Handle
@return [1] number

Returns the fractional ammo of the game object between 0 and 1.

---------------------------------------------------
_G . GetCurAmmo ( h: Handle ) -> [1]: number
[function] [global]
@param h Handle
@return [1] number

Returns the current ammo value of the game object.

---------------------------------------------------
_G . GetMaxAmmo ( h: Handle ) -> [1]: number
[function] [global]
@param h Handle
@return [1] number

Returns the maximum ammo value of the game object.

---------------------------------------------------
_G . SetCurAmmo ( h: Handle, ammo: number )
[function] [global]
@param h Handle
@param ammo number

Sets the current ammo of the game object.

---------------------------------------------------
_G . SetMaxAmmo ( h: Handle, ammo: number )
[function] [global]
@param h Handle
@param ammo number

Sets the maximum ammo of the game object.

---------------------------------------------------
_G . AddAmmo ( h: Handle, ammo: number )
[function] [global]
@param h Handle
@param ammo number

Adds to the current ammo of the game object.

---------------------------------------------------
_G . GiveMaxAmmo ( h: Handle )
[function] [global] [version 2.1+]
@param h Handle

Sets the unit's current ammo to maximum.

<<
---------------------------------------------------
Cinematic Camera
[section]

These functions control the cinematic camera for in-engine cut scenes (or "cineractives" as the Interstate '76 team at Activision called them).

>>
---------------------------------------------------
_G . CameraReady ( ) -> [1]: boolean
[function] [global]
@return [1] boolean

Starts the cinematic camera and disables normal input. Always returns true.

---------------------------------------------------
_G . CameraPath ( path: string, height: integer, speed: integer, target: Handle ) -> [1]: boolean
[function] [global]
@param path string
@param height integer
@param speed integer
@param target Handle
@return [1] boolean

Moves a cinematic camera along a path at a given height and speed while looking at a target game object. Returns true when the camera arrives at its destination. Returns false otherwise.

---------------------------------------------------
_G . CameraPathDir ( path: string, height: integer, speed: integer ) -> [1]: boolean
[function] [global]
@param path string
@param height integer
@param speed integer
@return [1] boolean

Moves a cinematic camera long a path at a given height and speed while looking along the path direction. Returns true when the camera arrives at its destination. Returns false otherwise.

---------------------------------------------------
_G . CameraPathPath ( path: string, height: integer, speed: integer, target: string ) -> [1]: boolean
[function] [global]
@param path string
@param height integer
@param speed integer
@param target string
@return [1] boolean

Moves a cinematic camera along a path at a given height and speed while looking at a target path. Returns true when the camera arrives at its destination. Returns false otherwise.

---------------------------------------------------
_G . PanDone ( ) -> [1]: boolean
[function] [global]
@return [1] boolean

Returns true when the camera arrives at its destination. Returns false otherwise.

---------------------------------------------------
_G . CameraObject ( base: Handle, right: integer, up: integer, forward: integer, target: Handle ) -> [1]: boolean
[function] [global]
@param base Handle
@param right integer
@param up integer
@param forward integer
@param target Handle
@return [1] boolean

Offsets a cinematic camera from a base game object while looking at a target game object. The right, up, and forward offsets are in centimeters. Returns true if the base or handle game object does not exist. Returns false otherwise.

---------------------------------------------------
_G . CameraFinish ( ) -> [1]: boolean
[function] [global]
@return [1] boolean

Finishes the cinematic camera and enables normal input. Always returns true.

---------------------------------------------------
_G . CameraCancelled ( ) -> [1]: boolean
[function] [global]
@return [1] boolean

Returns true if the player canceled the cinematic. Returns false otherwise.

<<
---------------------------------------------------
Info Display
[section]
>>
---------------------------------------------------
_G . IsInfo ( odfname: string ) -> [1]: boolean
[function overload] [global]
_G . IsInfo ( h: Handle ) -> [1]: boolean
[function overload] [global]
@param odfname string
@param h Handle
@return [1] boolean

Returns true if the game object inspected by the info display matches the given odf or is the given handle.

<<
---------------------------------------------------
Network
[section]

LuaMission currently has limited network support, but can detect if the mission is being run in multiplayer and if the local machine is hosting.

>>
---------------------------------------------------
_G . IsNetGame ( ) -> [1]: boolean
[function] [global]
@return [1] boolean

Returns true if the game is a network game. Returns false otherwise.

---------------------------------------------------
_G . IsHosting ( ) -> [1]: boolean
[function] [global]
@return [1] boolean

Returns true if the local machine is hosting a network game. Returns false otherwise.

---------------------------------------------------
_G . SetLocal ( h: Handle )
[function] [global]
@param h Handle

Sets the game object as local to the machine the script is running on, transferring ownership from its original owner if it was remote.

---------------------------------------------------
_G . IsLocal ( h: Handle ) -> [1]: boolean
[function] [global]
@param h Handle
@return [1] boolean

Returns true if the game is local to the machine the script is running on. Returns false otherwise.

---------------------------------------------------
_G . IsRemote ( h: Handle ) -> [1]: boolean
[function] [global]
@param h Handle
@return [1] boolean

Returns true if the game object is remote to the machine the script is running on. Returns false otherwise.

---------------------------------------------------
_G . DisplayMessage ( message: string )
[function] [global]
@param message string

Adds a system text message to the chat window on the local machine.

---------------------------------------------------
_G . Send ( to: integer, type: string, ...: any )
[function] [global]
@param to integer
@param type string
@param ... any

Send a script-defined message across the network. To is the player network id of the recipient. None, nil, or 0 broadcasts to all players. Type is a one-character string indicating the script-defined message type. Other parameters will be sent as data and passed to the recipient's Receive function as parameters. Send supports nil, boolean, handle, integer, number, string, vector, and matrix data types. It does not support function, thread, or arbitrary userdata types. The sent packet can contain up to 244 bytes of data (255 bytes maximum for an Anet packet minus 6 bytes for the packet header and 5 bytes for the reliable transmission header)

TypeBytes
nil1
boolean1
handleinvalid (zero)1
valid (nonzero)1 + sizeof(int) = 5
numberzero1
char (integer -128 to 127)1 + sizeof(char) = 2
short (integer -32768 to 32767)1 + sizeof(short) = 3
int (integer)1 + sizeof(int) = 5
double (non-integer)1 + sizeof(double) = 9
stringlength < 311 + length
length >= 312 + length
tablecount < 311 + count + size of keys and values
count >= 312 + count + size of keys and values
userdataVECTOR_3D1 + sizeof(VECTOR_3D) = 13
MAT_3D1 + sizeof(REDUCED_MAT) = 12
<<
---------------------------------------------------
Read ODF
[section]

These functions read values from an external ODF, INI, or TRN file.

>>
---------------------------------------------------
_G . OpenODF ( filename: string ) -> [1]: ParameterDB
[function] [global]
@param filename string
@return [1] ParameterDB

Opens the named file as an ODF. If the file name has no extension, the function will append ".odf" automatically. If the file is not already open, the function reads in and parses the file into an internal database. If you need to read values from it relatively frequently, save the handle into a global variable to prevent it from closing. Returns the file handle if it succeeded. Returns nil if it failed.

---------------------------------------------------
_G . GetODFBool ( odf: ParameterDB, section: string?, label: string, default: boolean? ) -> [1]: boolean, [2]: boolean
[function] [global]
@param odf ParameterDB
@param section string?
@param label string
@param default boolean?
@return [1] boolean
@return [2] boolean

Reads a boolean value from the named label in the named section of the ODF file. Use a nil section to read labels that aren't in a section. It considers values starting with 'Y', 'y', 'T', 't', or '1' to be true and value starting with 'N', 'n', 'F', 'f', or '0' to be false. Other values are considered undefined. If a value is not found or is undefined, it uses the default value. If no default value is given, the default value is false. Returns the value and whether the value was found.

---------------------------------------------------
_G . GetODFInt ( odf: ParameterDB, section: string?, label: string, default: integer? ) -> [1]: boolean, [2]: boolean
[function] [global]
@param odf ParameterDB
@param section string?
@param label string
@param default integer?
@return [1] boolean
@return [2] boolean

Reads an integer value from the named label in the named section of the ODF file. Use nil as the section to read labels that aren't in a section. If no value is found, it uses the default value. If no default value is given, the default value is 0. Returns the value and whether the value was found.

---------------------------------------------------
_G . GetODFFloat ( odf: ParameterDB, section: string?, label: string, default: number? ) -> [1]: boolean, [2]: boolean
[function] [global]
@param odf ParameterDB
@param section string?
@param label string
@param default number?
@return [1] boolean
@return [2] boolean

Reads a floating-point value from the named label in the named section of the ODF file. Use nil as the section to read labels that aren't in a section. If no value is found, it uses the default value. If no default value is given, the default value is 0.0. Returns the value and whether the value was found.

---------------------------------------------------
_G . GetODFString ( odf: ParameterDB, section: string?, label: string, default: string? ) -> [1]: boolean, [2]: boolean
[function] [global]
@param odf ParameterDB
@param section string?
@param label string
@param default string?
@return [1] boolean
@return [2] boolean

Reads a string value from the named label in the named section of the ODF file. Use nil as the section to read labels that aren't in a section. If a value is not found, it uses the default value. If no default value is given, the default value is nil. Returns the value and whether the value was found.

<<
---------------------------------------------------
Terrain
[section]

These functions return height and normal from the terrain height field.

>>
---------------------------------------------------
_G . GetTerrainHeightAndNormal ( target: Handle|Matrix|Vector|string, point: integer? ) -> [1]: Vector, [2]: Vector
[function] [global]
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param point integer?
@return [1] Vector
@return [2] Vector

Returns the terrain height and normal vector at a position vector, transform matrix, object, or point on a named path.

<<
---------------------------------------------------
Floor
[section]

These functions return height and normal from the terrain height field and the upward-facing polygons of any entities marked as floor owners.

>>
---------------------------------------------------
_G . GetFloorHeightAndNormal ( target: Handle|Matrix|Vector|string, point: integer? ) -> [1]: Vector, [2]: Vector
[function] [global]
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

@param point integer?
@return [1] Vector
@return [2] Vector

Returns the floor height and normal vector at a position vector, transform matrix, object, or point on a named path.

<<
---------------------------------------------------
Map
[section]
>>
---------------------------------------------------
_G . GetMissionFilename ( ) -> [1]: string
[function] [global] [version 2.0+]
@return [1] string

Returns the name of the BZN file for the map. This can be used to generate an ODF name for mission settings.

---------------------------------------------------
_G . GetMapTRNFilename ( ) -> [1]: string
[function] [global]
@return [1] string

Returns the name of the TRN file for the map. This can be used with OpenODF() to read values from the TRN file.

<<
---------------------------------------------------
Files
[section] [version 2.0+]
>>
---------------------------------------------------
_G . UseItem ( filename: string )
[function] [global] [version 2.0+]
@param filename string

Returns the contents of the named file as a string, or nil if the file could not be opened.

<<
---------------------------------------------------
Effects
[section] [version 2.0+]
>>
---------------------------------------------------
_G . ColorFade ( ratio: number, rate: number, r: integer, g: integer, b: integer )
[function] [global] [version 2.0+]
@param ratio number
@param rate number
@param r integer
@param g integer
@param b integer

Starts a full screen color fade. Ratio sets the opacity, with 0.0 transparent and 1.0 almost opaque Rate sets how fast the opacity decreases over time. R, G, and B set the color components and range from 0 to 255

<<
---------------------------------------------------
Vector
[section]

This is a custom userdata representing a position or direction. It has three number components: x, y, and z.

>>
---------------------------------------------------
Vector
[type]

A Vector in 3D space

>>
---------------------------------------------------
Vector . x
[number]

The x-coordinate.

---------------------------------------------------
Vector . y
[number]

The y-coordinate.

---------------------------------------------------
Vector . z
[number]

The z-coordinate.

<<
---------------------------------------------------
_G . SetVector ( x: number?, y: number?, z: number? ) -> [1]: Vector
[function] [global]
@param x number?
@param y number?
@param z number?
@return [1] Vector

Returns a vector whose components have the given number values. If no value is given for a component, the default value is 0.0.

---------------------------------------------------
_G . DotProduct ( a: Vector, b: Vector ) -> [1]: number
[function] [global]
@param a Vector
@param b Vector
@return [1] number

Returns the dot product between vectors a and b. Equivalent to a.x * b.x + a.y * b.y + a.z * b.z.

---------------------------------------------------
_G . CrossProduct ( a: Vector, b: Vector ) -> [1]: Vector
[function] [global]
@param a Vector
@param b Vector
@return [1] Vector

Returns the cross product between vectors a and b. Equivalent to SetVector(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x).

---------------------------------------------------
_G . Normalize ( v: Vector ) -> [1]: Vector
[function] [global]
@param v Vector
@return [1] Vector

Returns the vector scaled to unit length. Equivalent to SetVector(v.x * scale, v.y * scale, v.z * scale) where scale is 1.0f / sqrt(v.x2 + v.y2 + v.z2).

---------------------------------------------------
_G . Length ( v: Vector ) -> [1]: number
[function] [global]
@param v Vector
@return [1] number

Returns the length of the vector. Equivalent to sqrt(v.x2 + v.y2 + v.z2).

---------------------------------------------------
_G . LengthSquared ( v: Vector ) -> [1]: number
[function] [global]
@param v Vector
@return [1] number

Returns the squared length of the vector. Equivalent to v.x2 + v.y2 + v.z2.

---------------------------------------------------
_G . Distance2D ( a: Vector, b: Vector ) -> [1]: number
[function] [global]
@param a Vector
@param b Vector
@return [1] number

Returns the 2D distance between vectors a and b. Equivalent to sqrt((b.x - a.x)2 + (b.z - a.z)2).

---------------------------------------------------
_G . Distance2DSquared ( a: Vector, b: Vector ) -> [1]: number
[function] [global]
@param a Vector
@param b Vector
@return [1] number

Returns the squared 2D distance of the vector. Equivalent to (b.x - a.x)2 + (b.z - a.z)2.

---------------------------------------------------
_G . Distance3D ( a: Vector, b: Vector ) -> [1]: number
[function] [global]
@param a Vector
@param b Vector
@return [1] number

Returns the 3D distance between vectors a and b. Equivalent to sqrt((b.x - a.x)2 + (b.y - a.y)2 + (b.z - a.z)2).

---------------------------------------------------
_G . Distance3DSquared ( a: Vector, b: Vector ) -> [1]: number
[function] [global]
@param a Vector
@param b Vector
@return [1] number

Returns the squared 3D distance of the vector. Equivalent to (b.x - a.x)2 + (b.y - a.y)2 + (b.z - a.z)2.

<<
---------------------------------------------------
Matrix
[section]

This is a custom userdata representing an orientation and position in space. It has four vector components (right, up, front, and posit) sharing space with twelve number components (right_x, right_y, right_z, up_x, up_y, up_z, front_x, front_y, front_z, posit_x, posit_y, posit_z).

>>
---------------------------------------------------
Matrix
[type]

A Matrix

>>
---------------------------------------------------
Matrix . right_x
[number]
---------------------------------------------------
Matrix . right_y
[number]
---------------------------------------------------
Matrix . right_z
[number]
---------------------------------------------------
Matrix . up_x
[number]
---------------------------------------------------
Matrix . up_y
[number]
---------------------------------------------------
Matrix . up_z
[number]
---------------------------------------------------
Matrix . front_x
[number]
---------------------------------------------------
Matrix . front_y
[number]
---------------------------------------------------
Matrix . front_z
[number]
---------------------------------------------------
Matrix . posit_x
[number]
---------------------------------------------------
Matrix . posit_y
[number]
---------------------------------------------------
Matrix . posit_z
[number]
<<
---------------------------------------------------
_G . SetMatrix ( right_x: number?, right_y: number?, right_z: number?, up_x: number?, up_y: number?, up_z: number?, front_x: number?, front_y: number?, front_z: number?, posit_x: number?, posit_y: number?, posit_z: number? ) -> [1]: Matrix
[function] [global]
@param right_x number?
@param right_y number?
@param right_z number?
@param up_x number?
@param up_y number?
@param up_z number?
@param front_x number?
@param front_y number?
@param front_z number?
@param posit_x number?
@param posit_y number?
@param posit_z number?
@return [1] Matrix

Returns a matrix whose components have the given number values. If no value is given for a component, the default value is zero. Be careful with this since it's easy to build a non-orthonormal matrix that will break all kinds of built-in assumptions.

---------------------------------------------------
_G . IdentityMatrix ( ) -> [1]: Matrix
[function] [global]
@return [1] Matrix

Global value representing the identity matrix. Equivalent to SetMatrix(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0).

---------------------------------------------------
_G . BuildAxisRotationMatrix ( angle: number?, axis: Vector ) -> [1]: Matrix
[function overload] [global]
_G . BuildAxisRotationMatrix ( angle: number?, axis_x: number?, axis_y: number?, axis_z: number? ) -> [1]: Matrix
[function overload] [global]
@param angle number?

Angle in radians defaulting to 0

@param axis Vector

The axis must be unit-length (i.e. axis.x2 + axis.y2 + axis.z2 = 1.0 or the resulting matrix will be wrong.

@param axis_x number?
@param axis_y number?
@param axis_z number?
@return [1] Matrix

Build a matrix representing a rotation by an angle around an axis.

---------------------------------------------------
_G . BuildPositionRotationMatrix ( pitch: number?, yaw: number?, roll: number?, position: Vector ) -> [1]: Matrix
[function overload] [global]
_G . BuildPositionRotationMatrix ( pitch: number?, yaw: number?, roll: number?, posit_x: number?, posit_y: number?, posit_z: number? ) -> [1]: Matrix
[function overload] [global]
@param pitch number?

Pitch angle in radians defaulting to 0

@param yaw number?

Yaw angle in radians defaulting to 0

@param roll number?

Roll angle in radians defaulting to 0

@param position Vector
@param posit_x number?

X position defaulting to 0

@param posit_y number?

Y position defaulting to 0

@param posit_z number?

Z position defaulting to 0

@return [1] Matrix

Build a matrix with the given pitch, yaw, and roll angles and position.

---------------------------------------------------
_G . BuildOrthogonalMatrix ( up: Vector?, heading: Vector? ) -> [1]: Matrix
[function] [global]
@param up Vector?
@param heading Vector?
@return [1] Matrix

Build a matrix with zero position, its up axis along the specified up vector, oriented so that its front axis points as close as possible to the heading vector. If up is not specified, the default value is the Y axis. If heading is not specified, the default value is the Z axis.

---------------------------------------------------
_G . BuildDirectionalMatrix ( position: Vector?, direction: Vector? ) -> [1]: Matrix
[function] [global]
@param position Vector?
@param direction Vector?
@return [1] Matrix

Build a matrix with the given position vector, its front axis pointing along the direction vector, and zero roll. If position is not specified, the default value is a zero vector. If direction is not specified, the default value is the Z axis.

<<
---------------------------------------------------
Portal Functions
[section] [version 2.1+]

These functions control the Portal building introduced in The Red Odyssey expansion.

>>
---------------------------------------------------
_G . PortalOut ( portal: Handle )
[function] [global] [version 2.1+]
@param portal Handle

Sets the specified Portal direction to "out", indicated by a blue visual effect while active.

---------------------------------------------------
_G . PortalIn ( portal: Handle )
[function] [global] [version 2.1+]
@param portal Handle

Sets the specified Portal direction to "in", indicated by an orange visual effect while active.

---------------------------------------------------
_G . DeactivatePortal ( portal: Handle )
[function] [global] [version 2.1+]
@param portal Handle

Deactivates the specified Portal, stopping the visual effect.

---------------------------------------------------
_G . ActivatePortal ( portal: Handle )
[function] [global] [version 2.1+]
@param portal Handle

Activates the specified Portal, starting the visual effect.

---------------------------------------------------
_G . IsIn ( portal: Handle ) -> [1]: boolean
[function] [global] [version 2.1+]
@param portal Handle
@return [1] boolean

Returns true if the specified Portal direction is "in". Returns false otherwise.

---------------------------------------------------
_G . isPortalActive ( portal: Handle ) -> [1]: boolean
[function] [global] [version 2.1+]
@param portal Handle
@return [1] boolean

Returns true if the specified Portal is active. Returns false otherwise. Important: note the capitalization!

---------------------------------------------------
_G . BuildObjectAtPortal ( odfname: string, teamnum: TeamNum, portal: Handle ) -> [1]: Handle
[function] [global] [version 2.1+]
@param odfname string
@param teamnum TeamNum
@param portal Handle
@return [1] Handle

Creates a game object with the given odf name and team number at the location of a portal. The object is created at the location of the visual effect and given a 50 m/s initial velocity.

<<
---------------------------------------------------
Cloak
[section] [version 2.1+]

These functions control the cloaking state of craft capable of cloaking.

>>
---------------------------------------------------
_G . Cloak ( h: Handle )
[function] [global] [version 2.1+]
@param h Handle

Makes the specified unit cloak if it can. Note: unlike SetCommand(h, AiCommand.CLOAK), this does not change the unit's current command.

---------------------------------------------------
_G . Decloak ( h: Handle )
[function] [global] [version 2.1+]
@param h Handle

Makes the specified unit de-cloak if it can. Note: unlike SetCommand(h, AiCommand.DECLOAK), this does not change the unit's current command.

---------------------------------------------------
_G . SetCloaked ( h: Handle )
[function] [global] [version 2.1+]
@param h Handle

Instantly sets the unit as cloaked (with no fade out).

---------------------------------------------------
_G . SetDecloaked ( h: Handle )
[function] [global] [version 2.1+]
@param h Handle

Instant sets the unit as uncloaked (with no fade in).

---------------------------------------------------
_G . IsCloaked ( h: Handle ) -> [1]: boolean
[function] [global] [version 2.1+]
@param h Handle
@return [1] boolean

Returns true if the unit is cloaked. Returns false otherwise

---------------------------------------------------
_G . EnableCloaking ( h: Handle, enable: boolean )
[function] [global] [version 2.1+]
@param h Handle
@param enable boolean

Enable or disable cloaking for a specified cloaking-capable unit. Note: this does not grant a non-cloaking-capable unit the ability to cloak.

---------------------------------------------------
_G . EnableAllCloaking ( enable: boolean )
[function] [global] [version 2.1+]
@param enable boolean

Enable or disable cloaking for all cloaking-capable units. Note: this does not grant a non-cloaking-capable unit the ability to cloak.

<<
---------------------------------------------------
Hide
[section] [version 2.1+]

These functions hide and show game objects. When hidden, the object is invisible (similar to Phantom VIR and cloak) and undetectable on radar (similar to RED Field and cloak). The effect is similar to but separate from cloaking. For the most part, AI units ignore the hidden state.

>>
---------------------------------------------------
_G . Hide ( h: Handle )
[function] [global] [version 2.1+]
@param h Handle

Hides a game object.

---------------------------------------------------
_G . UnHide ( h: Handle )
[function] [global] [version 2.1+]
@param h Handle

Un-hides a game object.

<<
---------------------------------------------------
Explosion
[section] [version 2.1+]

These functions create explosions at a specified location. They do not return a handle because explosions are not game objects and thus not visible to the scripting system.

>>
---------------------------------------------------
_G . MakeExplosion ( odfname: string, target: Handle|Matrix|Vector|string )
[function] [global] [version 2.1+]
@param odfname string
@param target Handle|Matrix|Vector|string

Position vector, ransform matrix, Object, or path name.

Creates an explosion with the given odf name at the target position vector, transform matrix, object, or the start of the named path.

<<
---------------------------------------------------
Bitwise
[section]

Bitwise operations on 32-bit integers.

>>
---------------------------------------------------
_G . bit
[table] [global]

Table of bitwise operation functions.

>>
---------------------------------------------------
_G . bit . tobit ( x: integer ) -> [1]: integer
[function]
@param x integer
@return [1] integer

Normalizes a number to the numeric range for bit operations and returns it. This function is usually not needed since all bit operations already normalize all of their input arguments. Check the operational semantics for details.

function printx(x) print("0x"..bit.tohex(x)) end
print(0xffffffff)                --> 4294967295
print(bit.tobit(0xffffffff))     --> -1
printx(bit.tobit(0xffffffff))    --> 0xffffffff
print(bit.tobit(0xffffffff + 1)) --> 0
print(bit.tobit(2^40 + 1234))    --> 1234
---------------------------------------------------
_G . bit . bnot ( x: integer ) -> [1]: integer
[function]
@param x integer
@return [1] integer

Returns the bitwise not of its argument.

---------------------------------------------------
_G . bit . band ( a: integer, b: integer, ...: integer ) -> [1]: integer
[function]
@param a integer
@param b integer
@param ... integer
@return [1] integer

Returns the bitwise and of its arguments.

---------------------------------------------------
_G . bit . bor ( a: integer, b: integer, ...: integer ) -> [1]: integer
[function]
@param a integer
@param b integer
@param ... integer
@return [1] integer

Returns the bitwise or of its arguments.

---------------------------------------------------
_G . bit . bxor ( a: integer, b: integer, ...: integer ) -> [1]: integer
[function]
@param a integer
@param b integer
@param ... integer
@return [1] integer

Returns the bitwise xor of its arguments.

---------------------------------------------------
_G . bit . lshift ( x: integer, disp: integer ) -> [1]: integer
[function]
@param x integer

The number to shift.

@param disp integer

The number of bits to shift.

@return [1] integer

Bitwise logical left-shift.

---------------------------------------------------
_G . bit . rshift ( x: integer, disp: integer ) -> [1]: integer
[function]
@param x integer

The number to shift.

@param disp integer

The number of bits to shift.

@return [1] integer

Bitwise logical right-shift.

---------------------------------------------------
_G . bit . arshift ( x: integer, disp: integer ) -> [1]: integer
[function]
@param x integer

The number to shift.

@param disp integer

The number of bits to shift.

@return [1] integer

Bitwise arithmetic right-shift.

---------------------------------------------------
_G . bit . rol ( x: integer, disp: integer ) -> [1]: integer
[function]
@param x integer

The number to rotate.

@param disp integer

The number of bits to rotate.

@return [1] integer

Bitwise left rotation.

---------------------------------------------------
_G . bit . ror ( x: integer, disp: integer ) -> [1]: integer
[function]
@param x integer

The number to rotate.

@param disp integer

The number of bits to rotate.

@return [1] integer

Bitwise right rotation.

---------------------------------------------------
_G . bit . tohex ( x: number, n: number? ) -> The: string
[function]
@param x number

The number to convert to hex.

@param n number?

The number of hex digits to generate. Positive numbers generate lowercase hex digits, negative numbers generate uppercase hex digits.

@return The string

hex string representation of the number.

Converts its first argument to a hex string. The number of hex digits is given by the absolute value of the optional second argument. Positive numbers between 1 and 8 generate lowercase hex digits. Negative numbers generate uppercase hex digits. Only the least-significant 4*|n| bits are used. The default is to generate 8 lowercase hex digits.

print(bit.tohex(1))              --> 00000001
print(bit.tohex(-1))             --> ffffffff
print(bit.tohex(0xffffffff))     --> ffffffff
print(bit.tohex(-1, -8))         --> FFFFFFFF
print(bit.tohex(0x21, 4))        --> 0021
print(bit.tohex(0x87654321, 4))  --> 4321
<<
<<
<<