BZ98R _api Wrapper
===================================================

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

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

Wooden Structures

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

A structure which can contain the floor

FLOOR = 9: integer

The floor in a bridge

STRUCTURE2 = 10: integer

Metal Structures

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

Wooden Structures

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

A structure which can contain the floor

[9] = "FLOOR": string

The floor in a bridge

[10] = "STRUCTURE2": string

Metal Structures

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

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

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

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

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

>>
---------------------------------------------------
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"

---------------------------------------------------
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
---------------------------------------------------
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"

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

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

---------------------------------------------------
LastGameKey
[string] [global]
----

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

<<
---------------------------------------------------
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.

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

Repeat the last audio message.

---------------------------------------------------
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.

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

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

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

Stops the given audio message.

---------------------------------------------------
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.

>>
---------------------------------------------------
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.

---------------------------------------------------
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.

>>
---------------------------------------------------
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

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

These function get and set a unit's target.

>>
---------------------------------------------------
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

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

These functions get and set position and orientation.

>>
---------------------------------------------------
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

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

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

>>
---------------------------------------------------
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).

---------------------------------------------------
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.

<<
---------------------------------------------------
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.

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

Sets team alliances back to default.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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).

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

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

>>
---------------------------------------------------
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.

---------------------------------------------------
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.

>>
---------------------------------------------------
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.

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

These functions get and set pilot counts for a team.

>>
---------------------------------------------------
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.

---------------------------------------------------
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.

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

Returns the team's pilot count.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

>>
---------------------------------------------------
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.

---------------------------------------------------
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.

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

Returns the team's scrap count.

---------------------------------------------------
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.

---------------------------------------------------
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.

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

Returns the team's maximum scrap count.

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

These function report various global time values.

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

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

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

Returns the simulation time step in seconds.

---------------------------------------------------
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

>>
---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

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

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

>>
---------------------------------------------------
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.

---------------------------------------------------
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.

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

Stops the cockpit timer.

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

Hides the cockpit timer.

---------------------------------------------------
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.

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

Starts a global earthquake effect.

---------------------------------------------------
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.

---------------------------------------------------
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
>>
---------------------------------------------------
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.

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

Returns the type of the named path.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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+]
----
>>
---------------------------------------------------
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.

>>
---------------------------------------------------
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.

---------------------------------------------------
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.

>>
---------------------------------------------------
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.

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

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


@note see _gameobject module.

>>
---------------------------------------------------
IsInfo ( h: Handle ) -> [1]: boolean
[function overload] [global]
----
@param h Handle
----
@return [1] boolean
----
<<
<<
---------------------------------------------------
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.

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

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

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

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

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

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

---------------------------------------------------
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
<<
---------------------------------------------------
Terrain
[section]
----

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

>>
---------------------------------------------------
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.

>>
---------------------------------------------------
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]
----
>>
---------------------------------------------------
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.

---------------------------------------------------
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+]
----
>>
---------------------------------------------------
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+]
----
>>
---------------------------------------------------
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

>>
---------------------------------------------------
x
[number]
----

The x-coordinate.

---------------------------------------------------
y
[number]
----

The y-coordinate.

---------------------------------------------------
z
[number]
----

The z-coordinate.

<<
---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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).

---------------------------------------------------
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).

---------------------------------------------------
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).

---------------------------------------------------
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.

---------------------------------------------------
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).

---------------------------------------------------
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.

---------------------------------------------------
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).

---------------------------------------------------
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

>>
---------------------------------------------------
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]
----
<<
---------------------------------------------------
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.

---------------------------------------------------
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).

---------------------------------------------------
BuildAxisRotationMatrix ( angle: number?, axis_x: number?, axis_y: number?, axis_z: number? ) -> [1]: Matrix
[function] [global]
----
@param angle number?
----
@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.

>>
---------------------------------------------------
BuildAxisRotationMatrix ( angle: number?, axis: Vector ) -> [1]: Matrix
[function overload] [global]
----
@param angle number?
----
@param axis Vector
----
@return [1] Matrix
----

The angle is in radians. If no value is given for the angle, the default value is zero. The axis must be unit-length (i.e. axis.x2 + axis.y2 + axis.z2 = 1.0 or the resulting matrix will be wrong.

<<
---------------------------------------------------
BuildPositionRotationMatrix ( pitch: number?, yaw: number?, roll: number?, posit_x: number?, posit_y: number?, posit_z: number? ) -> [1]: Matrix
[function] [global]
----
@param pitch number?
----
@param yaw number?
----
@param roll number?
----
@param posit_x number?
----
@param posit_y number?
----
@param posit_z number?
----
@return [1] Matrix
----

Build a matrix with the given pitch, yaw, and roll angles and position. The angles are in radians. If no value is given for a component, the default value is zero.

>>
---------------------------------------------------
BuildPositionRotationMatrix ( pitch: number?, yaw: number?, roll: number?, position: Vector ) -> [1]: Matrix
[function overload] [global]
----
@param pitch number?
----
@param yaw number?
----
@param roll number?
----
@param position Vector
----
@return [1] Matrix
----
<<
---------------------------------------------------
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.

---------------------------------------------------
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.

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

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

>>
---------------------------------------------------
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.

---------------------------------------------------
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.

<<
---------------------------------------------------
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.

>>
---------------------------------------------------
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.

>>
---------------------------------------------------
bit
[table] [global]
TYPE: table
SPECIAL: field
GLYPH: bi bi-table
----

Table of bitwise operation functions.

>>
---------------------------------------------------
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
---------------------------------------------------
bnot ( x: integer ) -> [1]: integer
[function]
----
@param x integer
----
@return [1] integer
----

Returns the bitwise not of its argument.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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.

---------------------------------------------------
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
<<
<<
<<

===================================================

_api -> table: _api

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API.

This API creates a full OOP wrapper and replacement the mission functions with an event based system for easier expansion.

This module is the core of the API and offers the following features:

  • Loads the following modules
    • _logger
    • _fix
    • _utility
    • _hook
    • _gameobject
    • _customsavetype
    • _version
  • Create events for all default game functions and custom events
    • Save (AddSaveLoad) [GAME]
    • Load (AddSaveLoad) [GAME]
    • PostLoad (AddSaveLoad) [CUSTOM]
    • Start (Add) [GAME]
    • GameKey (Add) [GAME]
    • Update (Add) [GAME]
    • MapObject (Add) [CUSTOM]
    • CreateObject (Add) [GAME]
    • AddObject (Add) [GAME]
    • DeleteObject (Add) [GAME]
    • CreatePlayer (Add) [GAME]
    • AddPlayer (Add) [GAME]
    • DeletePlayer (Add) [GAME]
    • Receive (Add) [GAME]
    • Command (Add) [GAME]
  • Advanced Save/Load serialization system
    • Custom Type Support (via _customsavetype)
    • Multi-reference handling
    • Reference loop handling
      • Child-parent loop reference resolution
>>
---------------------------------------------------
Events
[section]
----
>>
---------------------------------------------------
"Save" ( ) -> ...: any
[event]
----
@add AddSaveLoad
----
@call CallSave
----
@return ... any
----

Called when saving state to a save game file, allowing the script to preserve its state.

Any values returned by this function will be passed as parameters to Load when loading the save game file. Save supports nil, boolean, handle, integer, number, string, vector, and matrix data types. It does not support function, thread, or arbitrary userdata types.

The console window will print the saved values in human-readable format.

---------------------------------------------------
"Load" ( ...: any )
[event]
----
@add AddSaveLoad
----
@call CallLoad
----
@param ... any

loaded data

----

Called when loading state from a save game file, allowing the script to restore its state.

Data values returned from Save will be passed as parameters to Load in the same order they were returned. Load supports nil, boolean, handle, integer, number, string, vector, and matrix data types. It does not support function, thread, or arbitrary userdata types.

The console window will print the loaded values in human-readable format.

---------------------------------------------------
"PostLoad" ( )
[event]
----
@add AddSaveLoad
----
@call CallLoad
----

Called after loading state from a save game file, allowing the script to do any post-load adjustments to data.

This may be very useful to deal with ephemeral tables which might need to be loaded as hard-tables before converted to their weaktable storage in PostLoad.

---------------------------------------------------
"Start" ( )
[event]
----
@add Add
----
@call CallAllNoReturn
----

Called when the mission starts for the first time.

Use this function to perform any one-time script initialization.

---------------------------------------------------
"GameKey" ( key: string )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@param key string

zero or more modifiers (Ctrl, Shift, Alt) and a base key

----

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).

---------------------------------------------------
"Update" ( dtime: number, ttime: number )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@param dtime number

Delta Time

----
@param ttime number

Total Time

----

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.

---------------------------------------------------
"MapObject" ( object: GameObject )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@param object GameObject
----

Called for each map game object on initial map load.

Handle is the game object that was created.

---------------------------------------------------
"CreateObject" ( object: GameObject )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@param object GameObject
----

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.

---------------------------------------------------
"AddObject" ( object: GameObject )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@param object GameObject
----

Called when a game object gets added to the mission

Handle is the game object that was added

This function is normally called for "important" game objects, and excludes things like Scrap pieces.

---------------------------------------------------
"DeleteObject" ( object: GameObject )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@param object GameObject
----

Called before a game object is fully 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.

---------------------------------------------------
"CreatePlayer" ( id: integer, name: string, team: integer )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@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 session.

Players that join before the host launches trigger CreatePlayer just before the first Update.

Players that join joining after the host launches trigger CreatePlayer on entering the pre-game lobby.

This function gets called for the local player.

---------------------------------------------------
"AddPlayer" ( id: integer, name: string, team: integer )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@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 starts sending state updates.

This indicates that a player has finished loaded and started simulating.

This function is not called for the local player.

---------------------------------------------------
"DeletePlayer" ( id: integer, name: string, team: integer )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@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 session.

---------------------------------------------------
"Receive" ( from: integer, type: string, ...: any, priorResult: HookResult? ) -> [1]: boolean?
[event]
----
@add Add
----
@call CallAllPassReturn
----
@param from integer

network player id of the sender.

----
@param type string

an arbitrary one-character string indicating the script-defined message type.

----
@param ... any

values passed as parameters to Send will arrive as parameters to Receive in the same order they were sent. Receive supports nil, boolean, handle, integer, number, string, vector, and matrix data types. It does not support function, thread, or arbitrary userdata types.

----
@param priorResult HookResult?

prior event handler's result

----
@return [1] boolean?
----

Called when a script-defined message arrives.

This function should return true if it handled the message and false, nil, or none if it did not.

---------------------------------------------------
"Command" ( command: string, ...: any, priorResult: HookResult? ) -> [1]: boolean?
[event]
----
@add Add
----
@call CallAllPassReturn
----
@param command string
----
@param ... any

parameters

----
@param priorResult HookResult?

prior event handler's result

----
@return [1] boolean?
----

Called for any in-game chat command that was not handled by the system, allowing script-defined commands.

This function should return true if it handled the command and false, nil, or none if it did not.

LuaMission breaks the command into

Command is the string immediately following the '/'. For example, the command for "/foo" is "foo".

Arguments arrive as a string parameter to Command. For example "/foo 1 2 3" would receive "1 2 3".

The Lua string library provides several functions that can split the string into separate items.

You can use string.match with captures if you have a specific argument list: local foo, bar, baz = string.match(arguments, "(%g+) (%g+) (%g+)")

You can use string.gmatch, which returns an iterator, if you want to loop through arguments: for arg in string.gmatch(arguments, "%g+") do ... end

Check the Lua patterns tutorial and patterns manual for more details.

<<
---------------------------------------------------
Custom Types
[section]
----
>>
---------------------------------------------------
_api
[type]
----
>>
---------------------------------------------------
FixEvents ( )
[function]
----

Fix any base mission callbacks that are not using the new event system. This will wrap the existing functions in the hook system and replace them with the hook triggering wrappers. This is called automatically when the API is loaded but can be called again at the end of a script to ensure that all events are wrapped. If you are already purely using events then you do not need to call this function.

<<
<<
<<

===================================================

_camera -> table: _camera

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Camera.

Camera API wrapper. Wraps all stock camera functions with cleaner names and adds some additional functionality.

Dolly AimTarget
FollowPath AimObject
FollowPath AimFollowPath
FollowPath AimForward
FollowPath AimPath
FollowObjectAimObject
FollowObjectAimObject
>>
---------------------------------------------------
_camera
[type]
----
>>
---------------------------------------------------
State
[section]
----
>>
---------------------------------------------------
Start ( )
[function]
----

Starts the cinematic camera and disables normal input.

---------------------------------------------------
End ( )
[function]
----

Finishes the cinematic camera and enables normal input. Does nothing if camera is not active.

---------------------------------------------------
Active ( ) -> [1]: boolean
[function]
----
@return [1] boolean
----

Camera is currently active

---------------------------------------------------
Done ( ) -> [1]: boolean
[function]
----
@return [1] boolean
----

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

---------------------------------------------------
Canceled ( ) -> [1]: boolean
[function]
----
@return [1] boolean
----

Returns true if the player canceled the cinematic. Returns false otherwise. Cancelation becomes latched until UnCancel is called. Camera is latched as canceled in the engine itself after loading.

---------------------------------------------------
UnCancel ( )
[function]
----

Resets the camera cancelled flag. This is needed if the camera cancelation was used to switch to another camera type.

---------------------------------------------------
GetPosition ( ) -> pos: Vector, dir: Vector
[function]
----
@return pos Vector
----
@return dir Vector
----

@todo this function badly needs testing

<<
---------------------------------------------------
Sequence
[section]
----
>>
---------------------------------------------------
FollowPathAimObject ( path: string, height: number, speed: number, target: GameObject|Handle ) -> [1]: boolean
[function]
----
@param path string
----
@param height number

meters above the ground

----
@param speed number

speed in meters per second

----
@param target GameObject|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.

---------------------------------------------------
FollowPathAimFollowPath ( path: string, height: number, speed: number, target: string, target_height: number?, target_speed: number? ) -> [1]: boolean
[function]
----
@param path string
----
@param height number

meters above the ground

----
@param speed number

speed in meters per second

----
@param target string
----
@param target_height number?
----
@param target_speed number?

defaults to the same as speed

----
@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.

---------------------------------------------------
FollowPathAimForward ( path: string, height: number, speed: number ) -> [1]: boolean
[function]
----
@param path string
----
@param height number
----
@param speed number
----
@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. @todo consider changing to a direction vector

---------------------------------------------------
FollowPathAimPath ( path: string, height: number, speed: number, target: string ) -> [1]: boolean
[function]
----
@param path string
----
@param height number
----
@param speed number
----
@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 point. Returns true when the camera arrives at its destination. Returns false otherwise.

---------------------------------------------------
FollowObjectAimObject ( base: GameObject|Handle, right: number, up: number, forward: number, target: GameObject|Handle ) -> exists: boolean
[function overload]
FollowObjectAimObject ( base: GameObject|Handle, offset: Vector, target: GameObject|Handle ) -> exists: boolean
[function overload]
----
@param base GameObject|Handle
----
@param right number

Meters to the right of the base object.

----
@param up number

Meters above the base object.

----
@param forward number

Meters in front of the base object.

----
@param target GameObject|Handle
----
@param offset Vector
----
@return exists boolean

true if the base or handle game object does not exist. Returns false otherwise.

----

Offsets a cinematic camera from a base game object while looking at a target game object. Returns true if the base or handle game object does not exist. Returns false otherwise.

<<
<<
<<

===================================================

_cheatcode -> table: _cheatcode

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Cheat.

General cheat code handler.

Register custom cheat codes and hook the "Cheat" event to detect them.

require("_cheatcode").CreateCode("BZSKIP", "apcann.wav", 0, 0, 255);
local hook = require("_hook");
local camera = require("_camera");
hook.Add("Cheat", "Mission:Cheat", function (cheat)
    if cheat == "BZSKIP" then
        local machine_state = mission_data.mission_states.StateMachines.main_objectives;
        machine_state:SecondsHavePassed(); -- clear timer in case we were in one
        camera.End(); -- protected camera exit that won't crash
        machine_state:next(); -- move to the next state
    end
end);
>>
---------------------------------------------------
"Cheat" ( key: string )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@param key string
----

Cheat key combo event

---------------------------------------------------
CheatCodeStateMachineIter : StateMachineIter
[type] [local use]
----
>>
---------------------------------------------------
code
[string]
----
---------------------------------------------------
index
[number]
----
---------------------------------------------------
sound
[string] [nil]
----
---------------------------------------------------
r
[integer]
----
---------------------------------------------------
g
[integer]
----
---------------------------------------------------
b
[integer]
----
---------------------------------------------------
once
[boolean] [nil]
----
<<
---------------------------------------------------
_cheatcode
[type]
----
>>
---------------------------------------------------
CreateCode ( name: string, sound: string?, r: integer, g: integer, b: integer, once: boolean? ) -> [1]: _cheatcode
[function]
----
@param name string

The name of the cheat code, must be all uppercase letters

----
@param sound string?

Optional sound to play when the cheat is activated

----
@param r integer

Color flash red component (0-255)

----
@param g integer

Color flash green component (0-255)

----
@param b integer

Color flash blue component (0-255)

----
@param once boolean?

If true, the cheat can only be used once

----
@return [1] _cheatcode
----

Create a new cheat code.

<<
<<

===================================================

_cheat_bzrave

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Cheat.

BZRAVE cheat

Ctrl+Shift + BZRAVE

Replace all weapons with GTechno

require("_cheat_bzrave");
>>
---------------------------------------------------
Cheat_BZRAVE_effect_state : StateMachineIter
[type] [local use]
----
>>
---------------------------------------------------
rave_index
[number]
----
<<
<<

===================================================

_color -> table: _color

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Color.

Collection of color enumerations and functions.

>>
---------------------------------------------------
_color
[type]
----
>>
---------------------------------------------------
ColorLabel : EColorLabel
[enum EColorLabel]
----

Convert human readable color names to BZ98R color labels.

---------------------------------------------------
ColorValues
[table<string, ColorValue>]
----

Convert BZ98R color labels to RGB color codes. This probably isn't useful but it's here.

>>
BLACK = 0x000000FF: integer
DKGREY = 0x4C4C4CFF: integer
GREY = 0x999999FF: integer
WHITE = 0xFFFFFFFF: integer
BLUE = 0x007FFFFF: integer
DKBLUE = 0x004C99FF: integer
GREEN = 0x00FF00FF: integer
DKGREEN = 0x009900FF: integer
YELLOW = 0xFFFF00FF: integer
DKYELLOW = 0x999900FF: integer
RED = 0xFF0000FF: integer
DKRED = 0x990000FF: integer
CYAN = 0x00FFFFFF: integer
[version 2.2.315+]
DKCYAN = 0x009999FF: integer
[version 2.2.315+]
MAGENTA = 0xFF00FFFF: integer
[version 2.2.315+]
DKMAGENTA = 0x990099FF: integer
[version 2.2.315+]
<<
---------------------------------------------------
RAVE_COLOR
[integer[]]
----

RAVE GUN! color cycle. Each color is represented as a hexadecimal number: 0xRRGGBBFF.

>>
[1] = 0xFF0000FF: integer
[2] = 0xFF3300FF: integer
[3] = 0xFF6600FF: integer
[4] = 0xFF9900FF: integer
[5] = 0xFFCC00FF: integer
[6] = 0xFFFF00FF: integer
[7] = 0xCCFF00FF: integer
[8] = 0x99FF00FF: integer
[9] = 0x66FF00FF: integer
[10] = 0x33FF00FF: integer
[11] = 0x00FF00FF: integer
[12] = 0x00FF33FF: integer
[13] = 0x00FF66FF: integer
[14] = 0x00FF99FF: integer
[15] = 0x00FFCCFF: integer
[16] = 0x00FFFFFF: integer
[17] = 0x00CCFFFF: integer
[18] = 0x0099FFFF: integer
[19] = 0x0066FFFF: integer
[20] = 0x0033FFFF: integer
[21] = 0x0000FFFF: integer
[22] = 0x3300FFFF: integer
[23] = 0x6600FFFF: integer
[24] = 0x9900FFFF: integer
[25] = 0xCC00FFFF: integer
[26] = 0xFF00FFFF: integer
[27] = 0xFF00CCFF: integer
[28] = 0xFF0099FF: integer
[29] = 0xFF0066FF: integer
[30] = 0xFF0033FF: integer
<<
---------------------------------------------------
SplitColorValue ( color: ColorValue ) -> red: integer, green: integer, blue: integer, alpha: integer
[function]
----
@param color ColorValue

The RGBA color value (0xRRGGBBAA)

----
@return red integer

The red component (0-255)

----
@return green integer

The green component (0-255)

----
@return blue integer

The blue component (0-255)

----
@return alpha integer

The alpha component (0-255)

----
---------------------------------------------------
MergeColorValue ( r: integer, g: integer, b: integer, a: integer ) -> color: ColorValue
[function]
----
@param r integer

The red component (0-255)

----
@param g integer

The green component (0-255)

----
@param b integer

The blue component (0-255)

----
@param a integer

The alpha component (0-255)

----
@return color ColorValue

The merged color value (0xRRGGBBAA)

----
---------------------------------------------------
GetClosestColorCode ( color: ColorValue|integer ) -> color: ColorLabel
[function]
----
@param color ColorValue|integer

The RGBA color value (0xRRGGBBAA)

----
@return color ColorLabel

The closest game color code

----

Convert RGBA color to the closest game color code. This function takes an RGBA color and finds the closest game color code.

---------------------------------------------------
AnsiColorEscapeMap
[table<ColorLabel, string>]
----

Ansi color codes for terminal output sorted by game color codes.

>>
RESET = "\27[0m": string
_ = "\27[0m": string
BLACK = "\27[30m": string
DKGREY = "\27[90m": string
GREY = "\27[37m": string
WHITE = "\27[97m": string
BLUE = "\27[94m": string
DKBLUE = "\27[34m": string
GREEN = "\27[92m": string
DKGREEN = "\27[32m": string
YELLOW = "\27[93m": string
DKYELLOW = "\27[33m": string
RED = "\27[91m": string
DKRED = "\27[31m": string
CYAN = "\27[96m": string
DKCYAN = "\27[36m": string
MAGENTA = "\27[95m": string
DKMAGENTA = "\27[35m": string
<<
---------------------------------------------------
RGBAtoAnsi256 ( color: ColorValue ) -> pallet_index: integer
[function]
----
@param color ColorValue

The RGBA color value (0xRRGGBBAA)

----
@return pallet_index integer

The ANSI 256 color code (0-255)

----

Convert RGBA color to ANSI 256 color escape code. This function takes an RGBA color and converts it to an ANSI 256 color code. It uses a color cube and grayscale range to find the closest match.

---------------------------------------------------
RGBAtoAnsi256Escape ( color: ColorValue|integer ) -> escape: string
[function]
----
@param color ColorValue|integer

The RGBA color value (0xRRGGBBAA)

----
@return escape string

The ANSI 256 color escape code

----

Convert RGBA color to ANSI 256 color escape code. This function takes an RGBA color and converts it to an ANSI 256 color escape code.

---------------------------------------------------
RGBAtoAnsi24Escape ( color: ColorValue|integer ) -> escape: string
[function]
----
@param color ColorValue|integer

The RGBA color value (0xRRGGBBAA)

----
@return escape string

The ANSI 24-bit color escape code

----

Convert RGBA color to ANSI 24-bit color escape code. This function takes an RGBA color and converts it to an ANSI 24-bit color escape code.

<<
---------------------------------------------------
EColorLabel
[enum]
----

Convert human readable color names to BZ98R color labels.

>>
Black = "BLACK": string
DarkGrey = "DKGREY": string
Grey = "GREY": string
White = "WHITE": string
Blue = "BLUE": string
DarkBlue = "DKBLUE": string
Green = "GREEN": string
DarkGreen = "DKGREEN": string
Yellow = "YELLOW": string
DarkYellow = "DKYELLOW": string
Red = "RED": string
DarkRed = "DKRED": string
Cyan = "CYAN": string
[version 2.2.315+]
DarkCyan = "DKCYAN": string
[version 2.2.315+]
Magenta = "MAGENTA": string
[version 2.2.315+]
DarkMagenta = "DKMAGENTA": string
[version 2.2.315+]
BLACK = "BLACK": string
DKGREY = "DKGREY": string
GREY = "GREY": string
WHITE = "WHITE": string
BLUE = "BLUE": string
DKBLUE = "DKBLUE": string
GREEN = "GREEN": string
DKGREEN = "DKGREEN": string
YELLOW = "YELLOW": string
DKYELLOW = "DKYELLOW": string
RED = "RED": string
DKRED = "DKRED": string
CYAN = "CYAN": string
[version 2.2.315+]
DKCYAN = "DKCYAN": string
[version 2.2.315+]
MAGENTA = "MAGENTA": string
[version 2.2.315+]
DKMAGENTA = "DKMAGENTA": string
[version 2.2.315+]
["Dark Grey"] = "DKGREY": string
["Dark Blue"] = "DKBLUE": string
["Dark Green"] = "DKGREEN": string
["Dark Yellow"] = "DKYELLOW": string
["Dark Red"] = "DKRED": string
["Dark Cyan"] = "DKCYAN": string
[version 2.2.315+]
["Dark Magenta"] = "DKMAGENTA": string
[version 2.2.315+]
<<
---------------------------------------------------
ColorValue : integer
[alias]
----
<<

===================================================

_config

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Configuration.

Constants used to configure the API's system. Note that reading any non-table value other than "locked" will lock the config table.

@usage local config = require("_config");

if not config.locked then config.hook_priority.DeleteObject.GameObject = -99999; end


===================================================

_customsavetype -> table: _customsavetype

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API CustomSaveType.

Crude custom type to make data not save/load exploiting the custom type system.

local customsavetype = require("_customsavetype");

customsavetype.Register(ObjectDef);
>>
---------------------------------------------------
CustomSavableType
[type]
---- ----

Custom Savable Type definition. This allows for complex structures to be saved and loaded and preserve their function metatable assignment. If a custom type is registered, it will be used instead of the default serialization methods.

>>
---------------------------------------------------
__type
[string]
----

The type name of the custom savable type.

---------------------------------------------------
__nosave
[boolean] [nil]
----

If true, the type will not be saved or loaded, a nil will be saved instead.

---------------------------------------------------
__noref
[boolean] [nil]
----

If true, the type will not undergo checks for shared or looped references when saving.

---------------------------------------------------
__base:CustomSavableType? (inner_type)
[UNK_CustomSavableType] [UNK_CustomSavableType?] [nil]
TYPE: UNK_CustomSavableType
TYPE: UNK_CustomSavableType?
TYPE: nil
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----

The base type to inherit from, if any.

---------------------------------------------------
Save ( self: CustomSavableType ) -> ...: any
[UNK_fun(self: CustomSavableType):...unknown] [function]
----
@param self CustomSavableType
----
@return ... any
----

Called when saving an instance of this type. Return value is saved.

---------------------------------------------------
Load ( ...: any )
[UNK_fun(...?any)] [function]
----
@param ... any
----

Called when loading an instance of this type. Data is the value returned from Save.

---------------------------------------------------
TypeSave ( ) -> ...: any
[UNK_fun():...unknown] [function]
----
@return ... any
----

Called on the type itself before any other data is saved.

---------------------------------------------------
TypeLoad ( ...: any )
[UNK_fun(...?any)] [function]
----
@param ... any
----

Called on the type itself, before any other data is loaded.

<<
---------------------------------------------------
_customsavetype
[type]
----
>>
---------------------------------------------------
CustomSavableTypes
[table<string, CustomSavableType>]
----
---------------------------------------------------
NoSave ( data: table? ) -> [1]: table
[function]
----
@param data table?

Table to augment with unsaved data. If nil, a new table is created.

----
@return [1] table
----

Creates a new table or augments the passed in table marking it as unsaved.

---------------------------------------------------
Register ( obj: CustomSavableType )
[function]
----
@param obj CustomSavableType
----

Register a custom savable type.

---------------------------------------------------
Implements ( obj: CustomSavableType, name: string ) -> [1]: boolean
[function]
----
@param obj CustomSavableType
----
@param name string
----
@return [1] boolean
----

Does this custom savable type implement the given type?

---------------------------------------------------
Extract ( obj: CustomSavableType, name: string ) -> [1]: any?
[function]
----
@param obj CustomSavableType
----
@param name string
----
@return [1] any?
----

Extract the custom savable type if implemented

<<
<<

===================================================

_deque

Authors:
  • Pierre 'catwell' Chapuis
----

BZ98R LUA Extended API dequeue library.

https://github.com/catwell/cw-lua/blob/master/deque/deque.lua

Deque implementation by Pierre 'catwell' Chapuis

Copyright (C) by Pierre Chapuis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

>>
---------------------------------------------------
[type]
----
>>
---------------------------------------------------
Other
[section]
----
>>
---------------------------------------------------
head
[integer]
----

The index of the first element.

---------------------------------------------------
tail
[integer]
----

The index of the last element.

---------------------------------------------------
[integer]:any (inner_type)
[UNK_any]
TYPE: UNK_any
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----

The elements stored in the deque.

---------------------------------------------------
__type
[string]
----
<<
---------------------------------------------------
Deque - Core
[section]
----
>>
---------------------------------------------------
Save ( self: StateSetRunner, self: any ) -> [1]: table
[function] [internal use]
----
@param self StateSetRunner

instance

----
@param self any
----
@return [1] table
----

Save event function.

---------------------------------------------------
Load ( contents: table ) -> Deque: Deque
[function] [internal use]
----
@param contents table
----
@return Deque Deque
----

Load event function.

<<
<<
<<

===================================================

_fix

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Lua Bug Fixer.

Contains fixes for bugs in the game's lua implementation and other polyfils.

  • Polyfill: table.unpack for Lua 5.1 compatibility
  • Fix/Polyfill: Remap SettLabel to SetLabel for BZ1.5
  • Fix: Works around the possible stuck iterator in ObjectiveObjects
  • Fix/Polyfill: TeamSlot missing "PORTAL" = 90
  • Fix: Tugs not respecting DropOff command due to invalid deploy state
  • Fix/Polyfill: Fix for broken Formation order function
  • Fix: Powerups not using thrusters when falling if on an AI team
>>
---------------------------------------------------
GameObject_FixFallingPowerup : GameObject
[type] [local use]
----
>>
---------------------------------------------------
PowerupFixes_team
[integer]
----
---------------------------------------------------
PowerupFixes_wrecker
[boolean] [nil]
----
<<
<<

===================================================

_gameobject -> table: _gameobject

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API GameObject.

GameObject wrapper functions.

>>
---------------------------------------------------
GameObject : CustomSavableType
[type]
----

GameObject An object containing all functions and data related to a game object.

>>
---------------------------------------------------
Other
[section]
----
>>
---------------------------------------------------
id:Handle (inner_type)
[UNK_Handle]
TYPE: UNK_Handle
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----

Handle used by BZ98R

---------------------------------------------------
addonData
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

Extended data saved into the object

---------------------------------------------------
cache_memo
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

Unsaved data used for housekeeping that is regenerated at load

---------------------------------------------------
__index ( dtable: any, key: any ) -> [1]: unknown?
[function]
----
@param dtable any
----
@param key any
----
@return [1] unknown?
----
---------------------------------------------------
__newindex ( dtable: any, key: any, value: any )
[function]
----
@param dtable any
----
@param key any
----
@param value any
----
---------------------------------------------------
__type
[string]
----
---------------------------------------------------
__noref
[boolean]
----
---------------------------------------------------
__tostring ( self: GameObject ) -> [1]: string
[function]
----
@param self GameObject

GameObject An object containing all functions and data related to a game object.

----
@return [1] string
----
<<
---------------------------------------------------
Core
[section]
----
>>
---------------------------------------------------
GetHandle ( self: GameObject ) -> [1]: Handle
[function]
----
@param self GameObject

GameObject instance

----
@return [1] Handle
----

Get Handle used by BZ98R.

---------------------------------------------------
GetSeqNo ( self: GameObject ) -> SeqNo: integer
[function]
----
@param self GameObject

GameObject instance

----
@return SeqNo integer
----

Get the SeqNo of the GameObject. Note that the SeqNo is rather useless.

---------------------------------------------------
Save ( self: GameObject ) -> ...: any
[function] [internal use]
----
@param self GameObject

GameObject instance

----
@return ... any
----

Save event function.

---------------------------------------------------
Load ( id: any ) -> [1]: GameObject?
[function] [internal use]
----
@param id any

Handle

----
@return [1] GameObject?
----

Load event function.

---------------------------------------------------
TypeSave ( self: GameObject ) -> ...: any
[function] [internal use]
----
@param self GameObject

GameObject An object containing all functions and data related to a game object.

----
@return ... any
----

TypeSave event function.

---------------------------------------------------
TypeLoad ( data: any )
[function] [internal use]
----
@param data any

Object data

----

TypeLoad event function.

<<
---------------------------------------------------
Object Creation / Destruction
[section]
----
>>
---------------------------------------------------
RemoveObject ( self: GameObject )
[function]
----
@param self GameObject

GameObject instance

---- ---- ----

Remove GameObject from world.

<<
---------------------------------------------------
Info Display
[section]
----
>>
---------------------------------------------------
IsInfo ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

Returns true if the game object inspected by the info display matches the current game object.

<<
---------------------------------------------------
Condition Checks
[section]
----
>>
---------------------------------------------------
IsOdf ( self: GameObject, odf: string )
[function]
----
@param self GameObject

GameObject instance

----
@param odf string

ODF filename

----

Is the GameObject this odf?

enemy1:IsOdf("svturr")
---------------------------------------------------
GetOdf ( self: GameObject ) -> [1]: string
[function]
----
@param self GameObject

GameObject instance

----
@return [1] string
----

Get odf of GameObject

---------------------------------------------------
GetBase ( self: GameObject ) -> character: string?
[function]
----
@param self GameObject

GameObject instance

----
@return character string?

identifier for race

----

Get base of GameObject

---------------------------------------------------
GetLabel ( self: GameObject ) -> Label: string?
[function]
----
@param self GameObject

GameObject instance

----
@return Label string?

name string

----

Get label of GameObject

---------------------------------------------------
SetLabel ( self: GameObject, label: string )
[function]
----
@param self GameObject

GameObject instance

----
@param label string

Label

----

Is the GameObject this odf?

enemy1:SetLabel("special_object_7")
---------------------------------------------------
GetClassSig ( self: GameObject ) -> ClassSig: string?
[function]
----
@param self GameObject

GameObject instance

----
@return ClassSig string?

string

----

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

---------------------------------------------------
GetClassLabel ( self: GameObject ) -> Class: string?
[function]
----
@param self GameObject

GameObject instance

----
@return Class string?

label string

----

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

---------------------------------------------------
GetClassId ( self: GameObject ) -> ClassId: integer?
[function]
----
@param self GameObject

GameObject instance

----
@return ClassId integer?

number

----

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.

---------------------------------------------------
GetNation ( self: GameObject ) -> character: string
[function]
----
@param self GameObject

GameObject instance

----
@return character string

identifier for race

----

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".

---------------------------------------------------
IsValid ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

Does the GameObject exist in the world? Returns true if the game object exists. Returns false otherwise.

---------------------------------------------------
IsAlive ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

Is the GameObject alive and is still pilot controlled? Returns true if the game object exists and (if the object is a vehicle) controlled. Returns false otherwise.

---------------------------------------------------
IsAliveAndPilot ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

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

---------------------------------------------------
IsCraft ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

Returns true if it's a Craft.

---------------------------------------------------
IsBuilding ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

Returns true if it's a Building. Does not include guntowers.

---------------------------------------------------
IsPerson ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

Returns true if it's a person.

---------------------------------------------------
IsDamaged ( self: GameObject, threshold: number? ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@param threshold number?

float

----
@return [1] boolean
----

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

---------------------------------------------------
IsRecycledByTeam ( self: GameObject, team: TeamNum ) -> [1]: boolean
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----
@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.

>>
---------------------------------------------------
GetTeamNum ( self: GameObject ) -> Team: integer
[function]
----
@param self GameObject

GameObject instance

----
@return Team integer

number

----

Returns the game object's team number.

---------------------------------------------------
SetTeamNum ( self: GameObject, team: TeamNum )
[function]
----
@param self GameObject

GameObject instance

----
@param team TeamNum

new team number

----

Sets the game object's team number.

---------------------------------------------------
GetPerceivedTeam ( self: GameObject ) -> Team: integer
[function]
----
@param self GameObject

GameObject instance

----
@return Team integer

number

----

Get perceived team number of the GameObject.

---------------------------------------------------
SetPerceivedTeam ( self: GameObject, team: TeamNum )
[function]
----
@param self GameObject

GameObject instance

----
@param team TeamNum

new team number

----

Set perceived team number of the GameObject.

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

These function get and set a unit's target.

>>
---------------------------------------------------
SetAsUserTarget ( self: GameObject )
[function]
----
@param self GameObject
----

Set this as the local player's target.

---------------------------------------------------
SetTarget ( self: GameObject, target: GameObject|Handle|nil )
[function]
----
@param self GameObject
----
@param target GameObject|Handle|nil
----

Set the game object's target.

---------------------------------------------------
SetAsTarget ( self: GameObject, self: any, targeter: GameObject|Handle )
[function]
----
@param self GameObject
----
@param self any
----
@param targeter GameObject|Handle
----

Set this object as another object's target.

---------------------------------------------------
GetTarget ( self: GameObject ) -> [1]: GameObject?
[function]
----
@param self GameObject
----
@return [1] GameObject?
----

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.

>>
---------------------------------------------------
SetOwner ( self: GameObject, owner: GameObject? )
[function]
----
@param self GameObject
----
@param owner GameObject?
----

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

---------------------------------------------------
GetOwner ( self: GameObject ) -> [1]: GameObject?
[function]
----
@param self GameObject
----
@return [1] GameObject?
----

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

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

These functions get and set vehicle pilot class.

>>
---------------------------------------------------
SetPilotClass ( self: GameObject, odf: string? )
[function]
----
@param self GameObject
----
@param odf 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.

---------------------------------------------------
GetPilotClass ( self: GameObject ) -> [1]: string?
[function]
----
@param self GameObject
----
@return [1] string?
----

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

<<
---------------------------------------------------
Position & Velocity
[section]
----
>>
---------------------------------------------------
GetPosition ( self: GameObject ) -> [1]: Vector?
[function]
----
@param self GameObject

GameObject instance

----
@return [1] Vector?
----

Get object's position vector.

---------------------------------------------------
GetFront ( self: GameObject ) -> [1]: Vector?
[function]
----
@param self GameObject

GameObject instance

----
@return [1] Vector?
----

Get front vector.

---------------------------------------------------
SetPosition ( self: GameObject, position: Matrix|Vector|string, point: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param position Matrix|Vector|string

Vector position, Matrix position, or path name

----
@param point integer?

Index of the path point in the path (optional)

----

Set the position of the GameObject.

---------------------------------------------------
GetTransform ( self: GameObject ) -> [1]: Matrix?
[function]
----
@param self GameObject

GameObject instance

----
@return [1] Matrix?
----

Get object's tranform matrix.

---------------------------------------------------
SetTransform ( self: GameObject, transform: Matrix )
[function]
----
@param self GameObject

GameObject instance

----
@param transform Matrix

transform matrix

----

Set the tranform matrix of the GameObject.

---------------------------------------------------
GetVelocity ( self: GameObject ) -> Vector: Vector
[function]
----
@param self GameObject

GameObject instance

----
@return Vector Vector

(0,0,0) if the handle is invalid or isn't movable.

----

Get object's velocity vector.

---------------------------------------------------
SetVelocity ( self: GameObject, velocity: Vector )
[function]
----
@param self GameObject

GameObject instance

----
@param velocity Vector

Vector velocity

----

Set the velocity of the GameObject.

---------------------------------------------------
GetOmega ( self: GameObject ) -> Vector: Vector
[function]
----
@param self GameObject

GameObject instance

----
@return Vector Vector

(0,0,0) if the handle is invalid or isn't movable.

----

Get object's omega.

---------------------------------------------------
SetOmega ( self: GameObject, omega: any )
[function]
----
@param self GameObject

GameObject instance

----
@param omega any
----

Set the omega of the GameObject.

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

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

>>
---------------------------------------------------
GetWhoShotMe ( self: GameObject ) -> [1]: GameObject?
[function]
----
@param self GameObject
----
@return [1] GameObject?
----

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

---------------------------------------------------
GetLastEnemyShot ( self: GameObject ) -> float: number
[function]
----
@param self GameObject
----
@return float number
----

Returns the last time an enemy shot the game object.

---------------------------------------------------
GetLastFriendShot ( self: GameObject ) -> float: number
[function]
----
@param self GameObject
----
@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.

>>
---------------------------------------------------
IsAlly ( self: GameObject, target: GameObject|Handle ) -> Ally: boolean
[function]
----
@param self GameObject

GameObject instance

----
@param target GameObject|Handle

Target GameObject

----
@return Ally boolean

Do we consider this an ally?

----

Order GameObject to Attack target GameObject.

<<
---------------------------------------------------
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.

>>
---------------------------------------------------
SetObjectiveOn ( self: GameObject )
[function]
----
@param self GameObject

GameObject instance

----

Sets the game object as an objective to all teams.

---------------------------------------------------
SetObjectiveOff ( self: GameObject )
[function]
----
@param self GameObject

GameObject instance

----

Sets the game object back to normal.

---------------------------------------------------
IsObjectiveOn ( self: GameObject ) -> true: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return true boolean

if the game object is an objective

----

If the game object an objective?

---------------------------------------------------
GetObjectiveName ( self: GameObject ) -> Name: string
[function]
----
@param self GameObject

GameObject instance

----
@return Name string

of the objective/object

----

Sets the game object's visible name.

---------------------------------------------------
SetObjectiveName ( self: GameObject, name: string )
[function]
----
@param self GameObject

GameObject instance

----
@param name string

Name of the objective

----

Sets the game object's visible name.

---------------------------------------------------
SetName ( self: GameObject, name: string )
[function]
----
@param self GameObject

GameObject instance

----
@param name string

Name of the objective

----

Sets the game object's visible name. (Technicly a unique function, but effectively an alias for SetObjectiveName) See: GameObject.SetObjectiveName

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

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

>>
---------------------------------------------------
GetDistance ( self: GameObject, target: GameObject|Handle|Matrix|Vector|string, point: integer? ) -> [1]: number
[function]
----
@param self GameObject
----
@param target GameObject|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.

---------------------------------------------------
IsWithin ( self: GameObject, target: GameObject|Handle, dist: number ) -> [1]: boolean
[function]
----
@param self GameObject
----
@param target GameObject|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)

---------------------------------------------------
IsTouching ( self: GameObject, target: GameObject|Handle, tolerance: number? ) -> [1]: boolean
[function] [version 2.1+]
----
@param self GameObject
----
@param target GameObject|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.

>>
---------------------------------------------------
GetNearestObject ( self: GameObject ) -> [1]: GameObject?
[function]
----
@param self GameObject
----
@return [1] GameObject?
----

Returns the game object closest to self.

---------------------------------------------------
GetNearestVehicle ( self: GameObject ) -> [1]: GameObject?
[function]
----
@param self GameObject
----
@return [1] GameObject?
----

Returns the craft closest to self.

---------------------------------------------------
GetNearestBuilding ( self: GameObject ) -> [1]: GameObject?
[function]
----
@param self GameObject
----
@return [1] GameObject?
----

Returns the building closest to self.

---------------------------------------------------
GetNearestEnemy ( self: GameObject ) -> [1]: GameObject?
[function]
----
@param self GameObject
----
@return [1] GameObject?
----

Returns the enemy closest to self.

---------------------------------------------------
GetNearestFriend ( self: GameObject ) -> [1]: GameObject?
[function]
----
@param self GameObject
----
@return [1] GameObject?
----

Returns the friend closest to self.

---------------------------------------------------
GetNearestUnitOnTeam ( self: GameObject ) -> object: GameObject?
[function]
----
@param self GameObject
----
@return object GameObject?

closest friend, or nil if none exists.

----

Returns the friend closest to self. Returns nil if none exists.

---------------------------------------------------
CountUnitsNearObject ( self: GameObject, dist: number, team: TeamNum, odfname: string ) -> [1]: integer
[function]
----
@param self GameObject
----
@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.

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

These functions look up game objects in team slots.

>>
---------------------------------------------------
SetTeamSlot ( self: GameObject, slot: TeamSlotInteger ) -> old_object: GameObject?
[function] [version 2.2.315+]
----
@param self GameObject

GameObject instance

----
@param slot TeamSlotInteger

Slot number, see TeamSlot

----
@return old_object GameObject?

The new game object formerly in the slot, or nil if the slot was empty

----

Set the game object in the specified team slot. This could have major sideffects so be careful with it.

Sets the game object in the specified team slot. See: ~ScriptUtils.TeamSlot~

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

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

>>
---------------------------------------------------
IsDeployed ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

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

---------------------------------------------------
Deploy ( self: GameObject )
[function]
----
@param self GameObject

GameObject instance

----

Tells the game object to deploy. @function Deploy

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

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

>>
---------------------------------------------------
IsSelected ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@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.

>>
---------------------------------------------------
IsCritical ( self: GameObject ) -> [1]: boolean
[function] [version 2.0+]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

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

---------------------------------------------------
SetCritical ( self: GameObject, critical: boolean? )
[function] [version 2.0+]
----
@param self GameObject

GameObject instance

----
@param critical boolean?

defaults to true

----

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.

>>
---------------------------------------------------
SetWeaponMask ( self: GameObject, mask: integer )
[function]
----
@param self GameObject

GameObject instance

----
@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

---------------------------------------------------
GiveWeapon ( self: GameObject, weaponname: string?, slot: integer? ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@param weaponname string?
----
@param slot integer?
----
@return [1] 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.

---------------------------------------------------
GetWeaponClass ( self: GameObject, slot: integer ) -> [1]: string?
[function]
----
@param self GameObject

GameObject instance

----
@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.

---------------------------------------------------
FireAt ( self: GameObject, target: GameObject|Handle )
[function]
----
@param self GameObject

GameObject instance

----
@param target GameObject|Handle
----

Tells the game object to fire at the given target.

---------------------------------------------------
Damage ( self: GameObject, amount: number )
[function]
----
@param self GameObject

GameObject instance

----
@param amount number

damage amount

----

Applies damage to the game object.

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

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

>>
---------------------------------------------------
CanCommand ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject
----
@return [1] boolean
----

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

---------------------------------------------------
CanBuild ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject
----
@return [1] boolean
----

Returns true if the game object is a producer that can build at the moment. Returns false otherwise. The concept here is that the builder either A: Does not need to deploy or B: Does need to deploy but is deployed.

---------------------------------------------------
IsBusy ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject
----
@return [1] boolean
----

Returns true if the game object is a producer and currently busy. Returns false otherwise. An undeployed builder that needs to deploy will always indicate false. A deployed (if needed) producer with a buildClass set is considered busy. The buildClass may be cleared after the CreateObject call.

---------------------------------------------------
IsAtEndOfPath ( self: GameObject, path: string ) -> [1]: boolean
[function] [version 2.1+]
----
@param self GameObject
----
@param path string
----
@return [1] boolean
----

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

---------------------------------------------------
GetCurrentCommand ( self: GameObject ) -> [1]: AiCommand
[function]
----
@param self GameObject
----
@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.

---------------------------------------------------
GetCurrentWho ( self: GameObject ) -> [1]: GameObject?
[function]
----
@param self GameObject
----
@return [1] GameObject?
----

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

---------------------------------------------------
GetIndependence ( self: GameObject ) -> [1]: integer
[function]
----
@param self GameObject
----
@return [1] integer
----

Gets the independence of a unit.

---------------------------------------------------
SetIndependence ( self: GameObject, independence: integer )
[function]
----
@param self GameObject
----
@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.

---------------------------------------------------
SetCommand ( self: GameObject, command: integer, priority: integer?, who: GameObject|Handle|nil, where: Matrix|Vector|string|nil, when: number?, param: string? )
[function]
----
@param self GameObject
----
@param command integer
----
@param priority integer?
----
@param who GameObject|Handle|nil
----
@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.

---------------------------------------------------
Attack ( self: GameObject, target: GameObject|Handle, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param target GameObject|Handle

Target GameObject

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Attack target GameObject.

---------------------------------------------------
Goto ( self: GameObject, target: GameObject|Handle|Matrix|Vector|string, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param target GameObject|Handle|Matrix|Vector|string

Target Path name

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Goto target Vector, Matrix, GameObject, or Path. @function GameObject:Goto

---------------------------------------------------
Mine ( self: GameObject, target: Matrix|Vector|string, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param target Matrix|Vector|string

Target Vector, Matrix, or Path name

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Mine target Path.

---------------------------------------------------
Follow ( self: GameObject, target: GameObject|Handle, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param target GameObject|Handle

Target GameObject instance

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Follow target GameObject.

---------------------------------------------------
IsFollowing ( self: GameObject, target: GameObject|Handle ) -> following: boolean
[function]
----
@param self GameObject

GameObject instance

----
@param target GameObject|Handle

Target GameObject instance

----
@return following boolean

true if following, false otherwise

----

Is the GameObject following the target GameObject?

---------------------------------------------------
Defend ( self: GameObject, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Defend area.

---------------------------------------------------
Defend2 ( self: GameObject, target: GameObject|Handle, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param target GameObject|Handle

Target GameObject instance

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Defend2 target GameObject.

---------------------------------------------------
Stop ( self: GameObject, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Stop.

---------------------------------------------------
Patrol ( self: GameObject, target: string, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param target string

Target Path name

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Patrol target path.

---------------------------------------------------
Retreat ( self: GameObject, target: GameObject|Handle|string, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param target GameObject|Handle|string

Target GameObject or Path name

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Retreat.

---------------------------------------------------
GetIn ( self: GameObject, target: GameObject|Handle, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param target GameObject|Handle

Target GameObject

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to GetIn target GameObject.

---------------------------------------------------
Pickup ( self: GameObject, target: GameObject|Handle, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param target GameObject|Handle

Target GameObject

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Pickup target GameObject.

---------------------------------------------------
Dropoff ( self: GameObject, target: Matrix|Vector|string, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param target Matrix|Vector|string

Target vector, matrix, or path name

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Pickup target path name.

---------------------------------------------------
Build ( self: GameObject, odf: string, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param odf string

Object Definition

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Build target config. Oddly this function does not include a location for the action, might want to use the far more powerful orders system.

---------------------------------------------------
BuildAt ( self: GameObject, odf: string, target: GameObject|Handle|Matrix|Vector|string, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param odf string

Object Definition

----
@param target GameObject|Handle|Matrix|Vector|string

Target GameObject instance, vector, matrix, or path name

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to BuildAt target GameObject.

---------------------------------------------------
Formation ( self: GameObject, target: GameObject|Handle, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param target GameObject|Handle

Target GameObject instance

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Formation follow target GameObject.

---------------------------------------------------
Hunt ( self: GameObject, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Hunt area.

---------------------------------------------------
Recycle ( self: GameObject, priority: integer? )
[function]
----
@param self GameObject

GameObject instance

----
@param priority integer?

Order priority, >0 removes user control

----

Order GameObject to Recycle.

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

These functions query Tug and Cargo.

>>
---------------------------------------------------
HasCargo ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

Returns true if the GameObject is a tug carrying cargo.

---------------------------------------------------
GetCargo ( self: GameObject ) -> GameObject: GameObject?
[function]
----
@param self GameObject

GameObject instance

----
@return GameObject GameObject?

of the GameObject carried by the GameObject, or nil

----

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

---------------------------------------------------
GetTug ( self: GameObject ) -> GameObject: GameObject?
[function]
----
@param self GameObject

GameObject instance

----
@return GameObject GameObject?

of the tug carrying the GameObject, or nil

----

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

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

These functions control the pilot of a vehicle.

>>
---------------------------------------------------
EjectPilot ( self: GameObject )
[function]
----
@param self GameObject
----

Commands the vehicle's pilot to eject.

---------------------------------------------------
HopOut ( self: GameObject )
[function]
----
@param self GameObject
----

Commands the vehicle's pilot to hop out.

---------------------------------------------------
KillPilot ( self: GameObject )
[function]
----
@param self GameObject
----

Kills the vehicle's pilot as if sniped.

---------------------------------------------------
RemovePilot ( self: GameObject )
[function]
----
@param self GameObject
----

Removes the vehicle's pilot cleanly.

---------------------------------------------------
HoppedOutOf ( self: GameObject ) -> GameObject: GameObject?
[function]
----
@param self GameObject

GameObject instance

----
@return GameObject GameObject?

of the vehicle that the pilot most recently hopped out of, or nil

----

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

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

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

>>
---------------------------------------------------
GetHealth ( self: GameObject ) -> ratio: number
[function]
----
@param self GameObject

GameObject instance

----
@return ratio number

health ratio

----

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

if friend1:GetHealth() < 0.5 then
    friend1:Retreat("retreat_path");
end
---------------------------------------------------
GetCurHealth ( self: GameObject ) -> current: number
[function]
----
@param self GameObject

GameObject instance

----
@return current number

current health or nil

----

Returns the current health value of the game object.

---------------------------------------------------
GetMaxHealth ( self: GameObject ) -> max: number
[function]
----
@param self GameObject

GameObject instance

----
@return max number

max health or nil

----

Returns the maximum health value of the game object.

---------------------------------------------------
SetCurHealth ( self: GameObject, health: number )
[function]
----
@param self GameObject

GameObject instance

----
@param health number

health amount

----

Sets the current health of the game object.

---------------------------------------------------
SetMaxHealth ( self: GameObject, health: number )
[function]
----
@param self GameObject

GameObject instance

----
@param health number

health amount

----

Sets the max health of the GameObject to the NewHealth value.

---------------------------------------------------
AddHealth ( self: GameObject, health: number )
[function]
----
@param self GameObject

GameObject instance

----
@param health number

health amount

----

Adds the health to the GameObject.

---------------------------------------------------
GiveMaxHealth ( self: GameObject )
[function]
----
@param self GameObject

GameObject instance

----

GiveMaxHealth

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

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

>>
---------------------------------------------------
GetAmmo ( self: GameObject ) -> ratio: number
[function]
----
@param self GameObject

GameObject instance

----
@return ratio number

ammo ratio

----

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

---------------------------------------------------
GetCurAmmo ( self: GameObject ) -> current: number
[function]
----
@param self GameObject

GameObject instance

----
@return current number

current ammo or nil

----

Returns the current ammo value of the game object.

---------------------------------------------------
GetMaxAmmo ( self: GameObject ) -> max: number
[function]
----
@param self GameObject

GameObject instance

----
@return max number

max ammo or nil

----

Returns the maximum ammo value of the game object.

---------------------------------------------------
SetCurAmmo ( self: GameObject, ammo: any )
[function]
----
@param self GameObject

GameObject instance

----
@param ammo any

ammo amount

----

Sets the current ammo of the game object.

---------------------------------------------------
SetMaxAmmo ( self: GameObject, ammo: any )
[function]
----
@param self GameObject

GameObject instance

----
@param ammo any

ammo amount

----

Sets the maximum ammo of the game object.

---------------------------------------------------
AddAmmo ( self: GameObject, ammo: any )
[function]
----
@param self GameObject

GameObject instance

----
@param ammo any

ammo amount

----

Adds to the current ammo of the game object.

---------------------------------------------------
GiveMaxAmmo ( self: GameObject )
[function]
----
@param self GameObject

GameObject instance

----

Sets the unit's current ammo to maximum.

<<
---------------------------------------------------
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.

>>
---------------------------------------------------
SetLocal ( self: GameObject )
[function]
----
@param self GameObject

GameObject instance

----

Sets the game object as local to the machine the script is running on, transferring ownership from its original owner if it was remote. Important safety tip: only call this on one machine at a time!

---------------------------------------------------
IsLocal ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

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

---------------------------------------------------
IsRemote ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

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

---------------------------------------------------
IsInitialized ( self: GameObject ) -> [1]: boolean
[function]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

Returns true if the game object is initialized, meaning it has been created and is either local or remote.

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

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

>>
---------------------------------------------------
PortalOut ( self: GameObject )
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----

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

---------------------------------------------------
PortalIn ( self: GameObject )
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----

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

---------------------------------------------------
DeactivatePortal ( self: GameObject )
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----
---------------------------------------------------
ActivatePortal ( self: GameObject )
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----

Activates the specified Portal, starting the visual effect.

---------------------------------------------------
PortalDirectionIsIn ( self: GameObject ) -> [1]: boolean
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

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

---------------------------------------------------
PortalIsActive ( self: GameObject ) -> [1]: boolean
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

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

---------------------------------------------------
BuildObjectAtPortal ( self: GameObject, odfname: string, teamnum: TeamNum ) -> [1]: GameObject?
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----
@param odfname string
----
@param teamnum TeamNum
----
@return [1] GameObject?
----

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.

>>
---------------------------------------------------
Cloak ( self: GameObject )
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----

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

---------------------------------------------------
Decloak ( self: GameObject )
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----

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

---------------------------------------------------
SetCloaked ( self: GameObject )
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----

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

---------------------------------------------------
SetDecloaked ( self: GameObject )
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----

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

---------------------------------------------------
IsCloaked ( self: GameObject ) -> [1]: boolean
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----
@return [1] boolean
----

Returns true if the unit is cloaked. Returns false otherwise

<<
---------------------------------------------------
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.

>>
---------------------------------------------------
Hide ( self: GameObject )
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----

Hides a game object.

---------------------------------------------------
UnHide ( self: GameObject )
[function] [version 2.1+]
----
@param self GameObject

GameObject instance

----

Un-hides a game object.

<<
<<
---------------------------------------------------
_gameobject
[type]
----
>>
---------------------------------------------------
Other
[section]
----
>>
---------------------------------------------------
isgameobject ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object an instance of GameObject?

---------------------------------------------------
extractgameobject ( object: any ) -> [1]: GameObject?
[function]
----
@param object any

Object in question

----
@return [1] GameObject?
----

Extract the GameObject from this object that implements GameObject.

<<
---------------------------------------------------
Core
[section]
----
>>
---------------------------------------------------
FromHandle ( handle: Handle ) -> [1]: GameObject?
[function]
----
@param handle Handle

Handle from BZ98R

----
@return [1] GameObject?
----

Create new GameObject Intance.

---------------------------------------------------
FromSeqNo ( seqNo: integer ) -> [1]: GameObject?
[function]
----
@param seqNo integer

Sequence number of the object

----
@return [1] GameObject?
----

Create a new GameObject instance. This works via a lookup table so it can fail easily.

<<
---------------------------------------------------
Object Creation / Destruction
[section]
----
>>
---------------------------------------------------
BuildObject ( odf: string, team: TeamNum, pos: GameObject|Handle|Matrix|Vector|string, point: integer? ) -> object: GameObject?
[function]
----
@param odf string

Object Definition File (without ".odf")

----
@param team TeamNum

Team number for the object, 0 to 15

----
@param pos GameObject|Handle|Matrix|Vector|string

Vector, Matrix, GameObject, or pathpoint by name

----
@param point integer?

index

----
@return object GameObject?

Newly built GameObject

---- ----

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

---------------------------------------------------
GetGameObject ( key: string ) -> object: GameObject?
[function]
----
@param key string

Label

----
@return object GameObject?

GameObject with Label or nil if none found

----

Get GameObject by Label.

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

These function get and set a unit's target.

>>
---------------------------------------------------
GetUserTarget ( ) -> [1]: GameObject?
[function]
----
@return [1] GameObject?
----

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

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

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

>>
---------------------------------------------------
GetNearestObject ( object: GameObject|Handle ) -> object: GameObject?
[function overload]
GetNearestObject ( position: Vector ) -> object: GameObject?
[function overload]
GetNearestObject ( transform: Matrix ) -> object: GameObject?
[function overload]
GetNearestObject ( name: string, point: integer? ) -> object: GameObject?
[function overload]
----
@param object GameObject|Handle

The reference game object.

----
@param position Vector

The position vector.

----
@param transform Matrix

The transform matrix.

----
@param name string

The path name.

----
@param point integer?

The point on the path (optional).

----
@return object GameObject?
----

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

---------------------------------------------------
GetNearestVehicle ( object: GameObject|Handle ) -> object: GameObject?
[function overload]
GetNearestVehicle ( position: Vector ) -> object: GameObject?
[function overload]
GetNearestVehicle ( transform: Matrix ) -> object: GameObject?
[function overload]
GetNearestVehicle ( name: string, point: integer? ) -> object: GameObject?
[function overload]
----
@param object GameObject|Handle

The reference game object.

----
@param position Vector

The position vector.

----
@param transform Matrix

The transform matrix.

----
@param name string

The path name.

----
@param point integer?

The point on the path (optional).

----
@return object GameObject?
----

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

---------------------------------------------------
GetNearestBuilding ( object: GameObject|Handle ) -> object: GameObject?
[function overload]
GetNearestBuilding ( position: Vector ) -> object: GameObject?
[function overload]
GetNearestBuilding ( transform: Matrix ) -> object: GameObject?
[function overload]
GetNearestBuilding ( name: string, point: integer? ) -> object: GameObject?
[function overload]
----
@param object GameObject|Handle

The reference game object.

----
@param position Vector

The position vector.

----
@param transform Matrix

The transform matrix.

----
@param name string

The path name.

----
@param point integer?

The point on the path (optional).

----
@return object GameObject?
----

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

---------------------------------------------------
GetNearestEnemy ( object: GameObject|Handle ) -> object: GameObject?
[function overload]
GetNearestEnemy ( position: Vector ) -> object: GameObject?
[function overload]
GetNearestEnemy ( transform: Matrix ) -> object: GameObject?
[function overload]
GetNearestEnemy ( name: string, point: integer? ) -> object: GameObject?
[function overload]
----
@param object GameObject|Handle

The reference game object.

----
@param position Vector

The position vector.

----
@param transform Matrix

The transform matrix.

----
@param name string

The path name.

----
@param point integer?

The point on the path (optional).

----
@return object GameObject?
----

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

---------------------------------------------------
GetNearestFriend ( object: GameObject|Handle ) -> object: GameObject?
[function overload]
GetNearestFriend ( position: Vector ) -> object: GameObject?
[function overload]
GetNearestFriend ( transform: Matrix ) -> object: GameObject?
[function overload]
GetNearestFriend ( name: string, point: integer? ) -> object: GameObject?
[function overload]
----
@param object GameObject|Handle

The reference game object.

----
@param position Vector

The position vector.

----
@param transform Matrix

The transform matrix.

----
@param name string

The path name.

----
@param point integer?

The point on the path (optional).

----
@return object GameObject?
----

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

---------------------------------------------------
GetNearestUnitOnTeam ( object: GameObject|Handle ) -> object: GameObject?
[function overload] [version 2.0+]
GetNearestUnitOnTeam ( position: Vector ) -> object: GameObject?
[function overload] [version 2.1+]
GetNearestUnitOnTeam ( transform: Matrix ) -> object: GameObject?
[function overload] [version 2.1+]
GetNearestUnitOnTeam ( name: string, point: integer? ) -> object: GameObject?
[function overload] [version 2.1+]
----
@param object GameObject|Handle

The reference game object.

----
@param position Vector

The position vector.

----
@param transform Matrix

The transform matrix.

----
@param name string

The path name.

----
@param point integer?

The point on the path (optional).

----
@return object GameObject?

closest friend, or nil if none exists.

----

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

<<
---------------------------------------------------
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.

>>
---------------------------------------------------
ObjectsInRange ( dist: number, target: GameObject|Handle|Matrix|Vector|string, point: integer? ) -> iterator: fun(): GameObject
[function]
----
@param dist number
----
@param target GameObject|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(): GameObject

Iterator of GameObject values

----

Enumerates game objects within the given distance a target.

---------------------------------------------------
AllObjects ( ) -> iterator: fun():GameObject
[function]
----
@return iterator fun():GameObject

Iterator of GameObject values

----

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.

---------------------------------------------------
AllCraft ( ) -> iterator: fun():GameObject
[function]
----
@return iterator fun():GameObject

Iterator of GameObject values

----

Enumerates all craft.

---------------------------------------------------
SelectedObjects ( ) -> iterator: fun():GameObject
[function]
----
@return iterator fun():GameObject

Iterator of GameObject values

----

Enumerates all game objects currently selected by the local player.

---------------------------------------------------
ObjectiveObjects ( ) -> iterator: fun():GameObject
[function]
----
@return iterator fun():GameObject

Iterator of GameObject values

----

Enumerates all game objects marked as objectives.

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

These functions look up game objects in team slots.

>>
---------------------------------------------------
GetTeamSlot ( slot: TeamSlotInteger, team: TeamNum? ) -> object: GameObject?
[function]
----
@param slot TeamSlotInteger

Slot number, see TeamSlot

----
@param team TeamNum?

Team number, 0 to 15

----
@return object GameObject?

GameObject in the slot or nil if none found

----

Get the game object in the specified team slot.

See: ~ScriptUtils.TeamSlot~

---------------------------------------------------
GetPlayer ( team: TeamNum? ) -> player: GameObject?
[function]
----
@param team TeamNum?

Team number of player

----
@return player GameObject?

GameObject of player or nil

----

Get Player GameObject of team. @todo depricate functions like this and move them to a team manager, because of the issue noted on scriptutils for GetTeamSlot.

---------------------------------------------------
GetRecycler ( team: TeamNum? ) -> recycler: GameObject?
[function]
----
@param team TeamNum?

Team number of player

----
@return recycler GameObject?

GameObject of recycler or nil

----

Get Recycler GameObject of team.

---------------------------------------------------
GetFactory ( team: TeamNum? ) -> factory: GameObject?
[function]
----
@param team TeamNum?

Team number of player

----
@return factory GameObject?

GameObject of factory or nil

----

Get Factory GameObject of team.

---------------------------------------------------
GetArmory ( team: TeamNum? ) -> armory: GameObject?
[function]
----
@param team TeamNum?

Team number of player

----
@return armory GameObject?

of armory or nil

----

Get Armory GameObject of team.

---------------------------------------------------
GetConstructor ( team: TeamNum? ) -> constructor: GameObject?
[function]
----
@param team TeamNum?

Team number of player

----
@return constructor GameObject?

of constructor or nil

----

Get Factory GameObject of team.

<<
<<
<<

===================================================

_hook -> table: _hook

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Hook.

Event hook for event observer pattern.

local hook = require("_hook");

hook.Add("InitialSetup", "Custom_InitialSetup", function(turn)
    
end);

hook.Add("Update", "Custom_Update", function(turn)
    
end);

hook.AddSaveLoad("Custom_SaveLoad",
function()
    return MissionData;
end,
function(savedData)
    MissionData = savedData;
end);

-- 10% of the time players will just respawn instead of eject, this overrides all other event hooks
hook.Add("PlayerEjected", function(DeadObject)
    if object:IsPlayer() and GetRandomFloat(10) > 9 then
        return hook.AbortResult(EjectKillRetCodes.DoRespawnSafest);
    end
end, 9999)
>>
---------------------------------------------------
HookHandler
[type]
----
>>
---------------------------------------------------
identifier
[string]
----

Identifier for this hook observer.

---------------------------------------------------
priority
[number]
----

Higher numbers are higher priority.

---------------------------------------------------
func ( )
[function]
----

Function to be executed when the event is triggered.

<<
---------------------------------------------------
HookResult
[type]
----
>>
---------------------------------------------------
Abort
[boolean]
----

Flag to abort the hook chain.

---------------------------------------------------
Return:any[] (inner_type)
[UNK_any[]]
----

Return values passed from hook function.

---------------------------------------------------
__type
[string]
----

Type of the object, used for type checking. "HookResult"

<<
---------------------------------------------------
_hook
[type]
----
>>
---------------------------------------------------
GetTable ( ) -> [1]: table<string, HookHandler[]>
[function]
----
@return [1] table<string, HookHandler[]>
----

Table of all hooks.

---------------------------------------------------
isresult ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object an instance of HookResult?

---------------------------------------------------
AbortResult ( ...: any ) -> [1]: HookResult
[function]
----
@param ... any

Return values passed from hook function

----
@return [1] HookResult
----

Create an Abort HookResult @function _hook.AbortResult

---------------------------------------------------
WrapResult ( ...: any ) -> [1]: HookResult?
[function]
----
@param ... any

Return values passed from hook function

----
@return [1] HookResult?
----

Create an basic HookResult

This wraps a return value similarly to _hook.AbortResult and can be used optionally to wrap return values. This is primarily used internally to wrap the prior return value to be passed as the next Parameter in _hook.CallAllPassReturn based event triggers as event handler return values are auto-unwrapped by the event handler if wrapping is detected but process fine if unwrapped. @function _hook.WrapResult See:

---------------------------------------------------
Add ( event: string, identifier: string, func: function, priority: number? )
[function]
----
@param event string

Event to be hooked

----
@param identifier string

Identifier for this hook observer

----
@param func function

Function to be executed

----
@param priority number?

Higher numbers are higher priority

----

Add a hook to listen to the specified event. @function _hook.Add

---------------------------------------------------
Remove ( event: string, identifier: string )
[function]
----
@param event string

Event to be hooked

----
@param identifier string

Identifier for this hook observer

----

Removes the hook with the given identifier. @function _hook.Remove

---------------------------------------------------
AddSaveLoad ( identifier: string, save: function?, load: function?, postload: function? )
[function]
----
@param identifier string

Identifier for this hook observer

----
@param save function?

Function to be executed for Save

----
@param load function?

Function to be executed for Load

----
@param postload function?

Function to be executed after all Load hooks are called

----

Add a hook to listen to the Save and Load event. @function _hook.AddSaveLoad

---------------------------------------------------
RemoveSaveLoad ( identifier: string )
[function]
----
@param identifier string

Identifier for this hook observer

----

Removes the Save and Load hooks with the given identifier. @function _hook.RemoveSaveLoad

---------------------------------------------------
CallSave ( ) -> [1]: table?
[function]
----
@return [1] table?
----

Calls hooks associated with Save. @function _hook.CallSave

---------------------------------------------------
CallLoad ( SaveData: any )
[function]
----
@param SaveData any
----

Calls hooks associated with Load. @function _hook.CallLoad

---------------------------------------------------
CallAllNoReturn ( event: string, ...: any ) -> Return: boolean?
[function]
----
@param event string

Event to be hooked

----
@param ... any

Parameters passed to every hooked function

----
@return Return boolean?

true if stopped early, else nil

----

Calls hooks associated with the hook name ignoring any return values. @todo Consider redoing the return value as nothing uses it right now. @function _hook.CallAllNoReturn

---------------------------------------------------
CallAllPassReturn ( event: string, ...: any ) -> ...: any
[function]
----
@param event string

Event to be hooked

----
@param ... any

Parameters passed to every hooked function

----
@return ... any

nil if no hooks are called, a HookResult if the chain is aborted, or the return values from the last hook function.

----

Calls hooks associated with the hook name passing each return to the next. Hooked functions may return multiple values. The return value is always passed to the next hook wrapped in an EventResult. If the value is generated by one of the hook library's event functions it will be parsed and passed along without wrapping. This allows for the hook chain to be broken early through the use of the AbortResult function. The best action here is to nil check and test your last Parameter with hook.isresult before processing it. @function _hook.CallAllPassReturn

---------------------------------------------------
HasHooks ( event: string ) -> [1]: boolean
[function]
----
@param event string

Event to be hooked

----
@return [1] boolean
----

Does this event have any hooks? For simple event calls this is not needed, but it's useful before loops triggering many instances of the same event. @function _hook.HasHooks

<<
---------------------------------------------------
event_name : string
[alias]
----
---------------------------------------------------
event_hook_identifier : string
[alias]
----
<<

===================================================

_logger -> table: _logger

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Debug.

System for handling debugging and logging.

>>
---------------------------------------------------
DebugSettings
[type]
----
>>
---------------------------------------------------
level:LogLevel (inner_type)
[UNK_LogLevel]
TYPE: UNK_LogLevel
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----

Log Levels

---------------------------------------------------
format:LogFormat (inner_type)
[UNK_LogFormat]
TYPE: UNK_LogFormat
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----

Log Format

---------------------------------------------------
intercept_print:InterceptPrint (inner_type)
[UNK_InterceptPrint]
TYPE: UNK_InterceptPrint
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----

Print Intercept Mode

---------------------------------------------------
strip_colors
[boolean]
----
---------------------------------------------------
suppress
[string[]]
----

Patterns to suppress in log messages

<<
---------------------------------------------------
_logger
[type]
----
>>
---------------------------------------------------
InterceptPrint : InterceptPrint
[enum InterceptPrint]
----
---------------------------------------------------
LogLevel : LogLevel
[enum LogLevel]
----
---------------------------------------------------
LogFormat : LogFormat
[enum LogFormat]
----
---------------------------------------------------
settings:DebugSettings (inner_type)
[UNK_DebugSettings]
TYPE: UNK_DebugSettings
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----

@todo make this readonly (at least through this window)

---------------------------------------------------
print ( level: LogLevel|integer, context: string?, ...: any )
[function]
----
@param level LogLevel|integer
----
@param context string?
----
@param ... any
----

Print log line Ignores wrapping setting for normal print. Will strip colors if not supported.

>>
---------------------------------------------------
print ( odf: ParameterDB, section: string?, key: string, default: integer?, boolVal: integer?, enumTable: table<string, integer> ) -> [1]: LogLevel, [2]: boolean
[function overload]
----
@param odf ParameterDB

ODF file name

----
@param section string?

Section name

----
@param key string

Key name

----
@param default integer?

Default value if the key is not found or is a boolean false

----
@param boolVal integer?

Value to return if the key is found and is a boolean true

----
@param enumTable table<string, integer>

Lookup table to convert enum value, a failed lookup will be considered a failure

----
@return [1] LogLevel
----
@return [2] boolean
----
<<
<<
---------------------------------------------------
InterceptPrint
[enum]
----

Print Intercept Mode

>>
NONE = 0: integer
WRAPPED = 1: integer
LOGGER = 2: integer
<<
---------------------------------------------------
LogLevel
[enum]
----

Log Levels

>>
NONE = 0: integer

No logging

ERROR = 1: integer

Error messages, used for critical issues

WARN = 2: integer

Warning messages, used for non-critical issues

PRINT = 3: integer

Normal print messages, used most often in intercept

DEBUG = 4: integer

Debug messages

TRACE = 5: integer

Trace messages

<<
---------------------------------------------------
LogFormat
[enum]
----

Log Format

>>
RAW = 0: integer

Raw format

WRAPPED = 1: integer

Wrapped format

<<
<<

===================================================

_navmanager -> table: _navmanager

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API NavManager.

Manage navs

local navmanager = require("_navmanager");

navmanager.SetCompactionStrategy(navmanager.CompactionStrategy.ImportantFirstChronologicalToGap);
>>
---------------------------------------------------
"NavManager:NavSwap" ( old: GameObject, new: GameObject )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@param old GameObject

GameObject instance

----
@param new GameObject

GameObject instance

----

Nav GameObjects swapped. The old nav will be deleted after this event is called. This event allows for scripts to replace their nav references or copy over custom data.

---------------------------------------------------
GameObject_NavManager : GameObject
[type]
----

Adds custom data to GameObject for this module.

>>
---------------------------------------------------
NavManager
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

A table containing custom data for this module.

<<
---------------------------------------------------
_navmanager
[type]
----
>>
---------------------------------------------------
BuildImportantNav ( odf: string?, team: integer, location: GameObject|Handle|Matrix|Vector|string, point: integer? ) -> nav: GameObject?
[function]
----
@param odf string?

ODF of the nav to build, if nil uses the default nav ODF

----
@param team integer

Team number of the nav to build

----
@param location GameObject|Handle|Matrix|Vector|string

Position vector, Transform matrix, or Object.

----
@param point integer?

path point index, defaults to 0.

----
@return nav GameObject?

The nav object that was built

----

Build an important nav and add it to the collection. Important navs will push non-important navs out of the way in the list.

---------------------------------------------------
CompactionStrategy
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

What to do when empty slots exist and excess navs exist @table _navmanager.CompactionStrategy

---------------------------------------------------
SetCompactionStrategy ( strategy: integer|string )
[function]
----
@param strategy integer|string

The strategy to use. See @{_navmanager.CompactionStrategy} for options.

----

Set the compaction strategy for navs. @function _navmanager.SetCompactionStrategy

---------------------------------------------------
GetCompactionStrategy ( ) -> The: integer
[function]
----
@return The integer

current compaction strategy. See @{_navmanager.CompactionStrategy} for options.

----

Get the current compaction strategy for navs.

---------------------------------------------------
AllNavGameObjects ( team: integer, include_overflow: boolean? ) -> Iterator: fun():integer, GameObject?
[function]
----
@param team integer

Team number to enumerate

----
@param include_overflow boolean?

If true "Overflow Navs" will be included in the enumeration after the initial 10.

----
@return Iterator fun():integer, GameObject?

function yielding index and nav object

----

Enumerates all navs for a team. At least 10 indexes will be iterated, even if there are no navs in those slots. Navs not in the nav list, known internally as "Overflow Navs", will be returned with indexes above 10.

for i, nav in navmanager.AllNavGameObjects(1, true) do
    print("Nav " .. i .. ": " .. tostring(nav));
end
local active_navs = utility.IteratorToArray(navmanager.AllNavGameObjects(1));
<<
<<

===================================================

_objective

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Objective Manager.

Note that this module cannot manage manually created objectives.

>>
---------------------------------------------------
ObjectiveManager
[type]
----
>>
---------------------------------------------------
UpdateObjective ( name: string, color: EColorLabel?, duration: number?, text: string?, position: number?, persistant: boolean? )
[function]
----
@param name string

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

----
@param color EColorLabel?

Default to "WHITE".

----
@param duration number?

defaults to 8 seconds

----
@param text string?
[version 2.0+]

Override text from the target objective file.

----
@param position number?

Sort position of the objective. Defaults to the next available ID.

----
@param persistant boolean?

If true, the objective will not be removed when the objectives are cleared. Defaults to false.

----

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

---------------------------------------------------
ClearObjectives ( )
[function]
----

Clear all objectives except for persistant ones.

---------------------------------------------------
AddObjective ( name: string, color: EColorLabel?, duration: number?, text: string?, position: number?, persistant: boolean? )
[function]
----
@param name string

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

----
@param color EColorLabel?

Default to "WHITE".

----
@param duration number?

defaults to 8 seconds

----
@param text string?
[version 2.0+]

Override text from the target objective file.

----
@param position number?

Sort position of the objective. Defaults to the next available ID.

----
@param persistant boolean?

If true, the objective will not be removed when the objectives are cleared. Defaults to false.

----

Adds an objective message with the given name and properties.

---------------------------------------------------
RemoveObjective ( name: string )
[function]
----
@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.

---------------------------------------------------
SetObjectivePosition ( name: string, position: number )
[function]
----
@param name string

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

----
@param position number

Sort position of the objective.

----

Set the objective position of the given name. If no objective exists with that name, it does nothing.

---------------------------------------------------
GetObjectivePosition ( name: string ) -> position: number?
[function]
----
@param name string

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

----
@return position number?

Sort position of the objective.

----

Get the objective position of the given name. If no objective exists with that name, it does nothing.

---------------------------------------------------
ReplaceObjective ( oldname: string, name: string, color: EColorLabel?, duration: number?, text: string?, position: number?, persistant: boolean? )
[function]
----
@param oldname string

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

----
@param name string

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

----
@param color EColorLabel?

Default to "WHITE".

----
@param duration number?

defaults to 8 seconds

----
@param text string?
[version 2.0+]

Override text from the target objective file.

----
@param position number?

Sort position of the objective. Defaults to the removed objective's position or next available ID.

----
@param persistant boolean?

If true, the objective will not be removed when the objectives are cleared. Defaults to false.

----

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

<<
<<

===================================================

_optional -> table: _optional

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Optional loader.

Load a lua module optionally.

local optional = require("_optional");
local missingSuccess, missingMod = optional("_missing");
missingMod = missingSuccess and missingMod or nil;

local missing2Success, missingMod2 = require("_optional")("_missing2");
missingMod2 = missing2Success and missingMod2 or nil;
>>
---------------------------------------------------
_optional
[type]
----
<<

===================================================

_paramdb -> table: _paramdb

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API ODF Handler.

Tracks objects by class and odf.

>>
---------------------------------------------------
ParameterDBCacheItem
[type]
----
>>
---------------------------------------------------
db:ParameterDB (inner_type)
[UNK_ParameterDB]
TYPE: UNK_ParameterDB
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----

ODF ParameterDB

---------------------------------------------------
timestamp
[number]
----

Time of last access

<<
---------------------------------------------------
_paramdb
[type]
----
>>
---------------------------------------------------
IsGameObject ( odf: string ) -> is_gameobject: boolean
[function]
----
@param odf string

ODF file name

----
@return is_gameobject boolean
----
---------------------------------------------------
GetClassLabel ( odf: string ) -> classlabel: ClassLabel?, success: boolean
[function]
----
@param odf string

ODF file name

----
@return classlabel ClassLabel?
----
@return success boolean
----
---------------------------------------------------
GetClassSig ( odf: string ) -> classlabel: ClassSig?, success: boolean
[function]
----
@param odf string

ODF file name

----
@return classlabel ClassSig?
----
@return success boolean
----
---------------------------------------------------
GetScrapCost ( odf: string ) -> scrap: integer, success: boolean
[function]
----
@param odf string

ODF file name

----
@return scrap integer

cost

----
@return success boolean
----
---------------------------------------------------
GetPilotCost ( odf: string ) -> pilot: integer, success: boolean
[function]
----
@param odf string

ODF file name

----
@return pilot integer

cost

----
@return success boolean
----
---------------------------------------------------
GetBuildTime ( odf: string ) -> time: number, success: boolean
[function]
----
@param odf string

ODF file name

----
@return time number
----
@return success boolean
----

@todo This might not need to exist since it doesn't have special class code

---------------------------------------------------
GetValueString ( odf: string, section: string?, key: string, default: string? ) -> value: string, success: boolean
[function]
----
@param odf string

ODF file name

----
@param section string?

Section name

----
@param key string

Key name

----
@param default string?

Default value if the key is not found

----
@return value string
----
@return success boolean
----

Get a general string without handling of class defaults.

---------------------------------------------------
GetValueInt ( odf: string, section: string?, key: string, default: integer? ) -> value: integer, success: boolean
[function]
----
@param odf string

ODF file name

----
@param section string?

Section name

----
@param key string

Key name

----
@param default integer?

Default value if the key is not found

----
@return value integer
----
@return success boolean
----

Get a general integer without handling of class defaults.

---------------------------------------------------
GetValueFloat ( odf: string, section: string?, key: string, default: number? ) -> value: number, success: boolean
[function]
----
@param odf string

ODF file name

----
@param section string?

Section name

----
@param key string

Key name

----
@param default number?

Default value if the key is not found

----
@return value number
----
@return success boolean
----

Get a general float without handling of class defaults.

---------------------------------------------------
GetValueBool ( odf: string, section: string?, key: string, default: boolean? ) -> value: boolean, success: boolean
[function]
----
@param odf string

ODF file name

----
@param section string?

Section name

----
@param key string

Key name

----
@param default boolean?

Default value if the key is not found

----
@return value boolean
----
@return success boolean
----

Get a general boolean without handling of class defaults.

---------------------------------------------------
GetValueIntegerEnum ( odf: string, section: string?, key: string, default: integer?, boolVal: integer?, enumTable: table<string, integer> ) -> [1]: integer, [2]: boolean
[function]
----
@param odf string

ODF file name

----
@param section string?

Section name

----
@param key string

Key name

----
@param default integer?

Default value if the key is not found or is a boolean false

----
@param boolVal integer?

Value to return if the key is found and is a boolean true

----
@param enumTable table<string, integer>

Lookup table to convert enum value, a failed lookup will be considered a failure

----
@return [1] integer
----
@return [2] boolean
----
<<
<<

===================================================

_paths -> table: _paths

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Paths.

>>
---------------------------------------------------
Other
[section]
----
>>
---------------------------------------------------
_paths
[type]
----
>>
---------------------------------------------------
Other
[section]
----
>>
---------------------------------------------------
isPathWithString ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object a table?

<<
---------------------------------------------------
Paths - Iterator Operations
[section]
----
>>
---------------------------------------------------
IteratePath ( path: string ) -> [1]: fun():integer, Vector
[function]
----
@param path string

Path name

----
@return [1] fun():integer, Vector
----

Iterate the vectors along the path. Return LUA style 1 based indexes for the path points.

<<
<<
<<
---------------------------------------------------
Paths - Core
[section]
----
>>
---------------------------------------------------
PathWithIndex : { [1]: string, [2]: integer }
[alias]
----
<<
<<

===================================================

_patrol -> table: _patrol

Authors:
  • John "Nielk1" Klein
  • Janne Trollebø
----

BZ98R LUA Extended API Patrol Engine.

Patrol Engine

>>
---------------------------------------------------
GameObject_patrol : GameObject
[type]
----
>>
---------------------------------------------------
_patrol
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----
<<
---------------------------------------------------
PatrolEngine : CustomSavableType
[type]
----
>>
---------------------------------------------------
path_map
[table<string, table>]
----
---------------------------------------------------
patrol_units
[table<GameObject_patrol, boolean>]
----
---------------------------------------------------
locations
[table<string>]
----
---------------------------------------------------
forcedAlert
[boolean]
----
<<
---------------------------------------------------
_patrol
[type]
----
>>
---------------------------------------------------
new ( ) -> [1]: PatrolEngine
[function]
----
@return [1] PatrolEngine
----

Creates a new PatrolEngine instance.

<<
<<

===================================================

_producer -> table: _producer

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Producer.

Queues the building of objects by producers.

>>
---------------------------------------------------
Other
[section]
----
>>
---------------------------------------------------
"Producer:BuildComplete" ( object: GameObject, producer: GameObject, data: any? )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@param object GameObject

The object that was built.

----
@param producer GameObject

The producer that built the object.

----
@param data any?

The event data to be fired with the creation event.

----

Called when a producer as completed building an object.

---------------------------------------------------
_producer
[type]
----
>>
---------------------------------------------------
QueueJob ( odf: string, team: TeamNum, location: GameObject|Handle|Matrix|PathWithIndex|Vector|string|nil, builder: TeamSlotInteger?, data: any? )
[function]
----
@param odf string

Object to build.

----
@param team TeamNum

Team number to build the object.

----
@param location GameObject|Handle|Matrix|PathWithIndex|Vector|string|nil

Location to build the object if from an armory or constructor.

----
@param builder TeamSlotInteger?

The producer that will build the object.

----
@param data any?

Event data to be fired with the creation event.

----
<<
<<
---------------------------------------------------
Producer - Data
[section]
----
>>
---------------------------------------------------
ProducerQueue
[type]
----

A table mapping teams (0–15) to ProductionQueue lists. This should be scanned every update if any producers are not busy to look for work for said producer. Consider this a priority queue, even though right now it's just a normal queue. Note that price is not a good reason to skip something, instead it should inject a block event into that build queue unless it's deemed impossible to get that much scrap.

---------------------------------------------------
ProductionQueue
[type]
----
>>
---------------------------------------------------
odf
[string]
----

The ODF of the object to be built.

---------------------------------------------------
location
[UNK_Vector] [UNK_string|Vector|{ [1]: string, [2]: integer }|nil] [UNK_{ [1]: string, [2]: integer }] [string] [nil]
----

The location where the object should be built, or "0 0 0" if not specified.

---------------------------------------------------
builder
[integer] [nil]
----

The producer that will build the object.

---------------------------------------------------
data:any (inner_type)
[UNK_any]
TYPE: UNK_any
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----

The event data to be fired with the creation event.

<<
<<
---------------------------------------------------
Producer - Core
[section]
----
>>
---------------------------------------------------
GameObject_producer : GameObject
[type]
----
>>
---------------------------------------------------
_producer:ProducerData? (inner_type)
[UNK_ProducerData] [UNK_ProducerData?] [nil]
TYPE: UNK_ProducerData
TYPE: UNK_ProducerData?
TYPE: nil
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----
<<
---------------------------------------------------
ProducerData
[type]
----
>>
---------------------------------------------------
post_build_check:GameObject? (inner_type)
[UNK_GameObject] [UNK_GameObject?] [nil]
TYPE: UNK_GameObject
TYPE: UNK_GameObject?
TYPE: nil
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----

GameObject An object containing all functions and data related to a game object.

<<
<<
<<

===================================================

_requirefix

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Require Fix.

Repairs lua loader to look in mod paths for DLL or LUA modules with names longer than 15 characters.

require("_requirefix").addmod("12345").addmod("67890");
require("_requirefix").addmod("12345");
require("_requirefix").addmod("67890");

===================================================

_statemachine -> table: _statemachine

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API StateMachineIter.

State Machine and State Machine Iterator for serial event sequences across game turns.

local statemachine = require("_statemachine");

statemachine.Create("TestMachine",
{
    ["state_a"] = function(state)
        print("test " .. state.test1);
        state:switch("state_b");
    end,
    ["state_b"] = statemachine.SleepSeconds(10,"state_c"),
    ["state_c"] = function(state)
        print("test " .. state.test2);
        state:switch("state_d");
    end,
    ["state_d"] = statemachine.SleepSeconds(15,"state_e"),
    ["state_e"] = function(state)
        print("test " .. state.test3);
        state:switch("state_f");
    end
});

-- ordered state machine that supports state:next()
statemachine.Create("OrderedTestMachine",
{
    -- named state function
    { "state_a", function(state)
        print("test " .. state.test1);
        state:switch("state_b");
    end },

    -- named magic state function (SleepSeconds)
    -- note nil next_state means next state by index
    { "state_b", statemachine.SleepSeconds(10) },

    -- named state function with automatic name
    { nil, function(state)
        print("test " .. state.test2);
        state:switch("state_d");
    end },

    -- named state function with automatic name
    { function(state)
        print("test " .. state.test2);
        state:switch("state_d");
    end },

    -- magic state function (SleepSeconds)
    statemachine.SleepSeconds(15,"nonexistent_state"),

    -- stsate function with automatic name
    function(state)
        print("test " .. state.test3);
        state:next();
    end
});

hook.Add("InitialSetup", "Custom_InitialSetup", function(turn)
    MissionData.TestSMI1 = statemachine.Start("TestMachine","state_a",{test1='d',test2="e",test3="f"});
    MissionData.TestSMI2 = statemachine.Start("OrderedTestMachine","state_a",{test1='d',test2="e",test3="f"});
end);

hook.Add("Update", "Custom_Update", function(turn)
    MissionData.TestSMI1:run();
    MissionData.TestSMI2:run();
end);
>>
---------------------------------------------------
StateMachineIter : CustomSavableType
[type]
----

An object containing all functions and data related to an StateMachineIter.

>>
---------------------------------------------------
Other
[section]
----
>>
---------------------------------------------------
state_key
[UNK_string|integer|nil] [integer] [string] [nil]
----

Current state, string name or integer index if state machine is ordered

---------------------------------------------------
template
[string]
----

StateMachineIter template name

---------------------------------------------------
index_to_name
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

StateMachineIter index to name mapping, only if the StateMachineIter is ordered

---------------------------------------------------
target_call
[integer] [nil]
----

Timer's value, nil for not set

---------------------------------------------------
target_time
[number] [nil]
----

Target time if sleeping, nil if not set

---------------------------------------------------
set_wait_time
[number] [nil]
----

Time to wait before running next state, kept to allow altering target_time if set_wait_time changes

---------------------------------------------------
addonData
[table] [nil]
TYPE: nil
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

Table of values embeded in the StateMachineIter

---------------------------------------------------
__index ( table: any, key: any ) -> [1]: unknown?
[function]
----
@param table any
----
@param key any
----
@return [1] unknown?
----

GameObject.__index = GameObject; -- failed table lookups on the instances should fallback to the class table, to get methods

---------------------------------------------------
__newindex ( table: any, key: any, value: any )
[function]
----
@param table any
----
@param key any
----
@param value any
----
---------------------------------------------------
__type
[string]
----
---------------------------------------------------
run ( self: StateMachineIter, ...: any ) -> status: StateMachineIterWrappedResult|boolean, ...: any
[function]
----
@param self StateMachineIter

FuncArrayIter instance

----
@param ... any

Arguments to pass to the state function

----
@return status StateMachineIterWrappedResult|boolean

True if the state function was called, false if the state function was not found, a wrapper instance if the state function was called and returned a wrapper

----
@return ... any

The return value of the state function, if it was called. If the result was wrapped it's unwraped and returned here

----

Run StateMachineIter.

---------------------------------------------------
next ( self: StateMachineIter )
[function]
----
@param self StateMachineIter

StateMachineIter instance

----

Next StateMachineIter State. This only works if the StateMachineIter is ordered.

---------------------------------------------------
switch ( self: StateMachineIter, key: integer|string|nil )
[function]
----
@param self StateMachineIter

StateMachineIter instance

----
@param key integer|string|nil

State to switch to (will also accept state index if the StateMachineIter is ordered)

----

Switch StateMachineIter State.

---------------------------------------------------
SecondsHavePassed ( self: StateMachineIter, seconds: number?, lap: boolean?, first: boolean? ) -> timeup: boolean
[function]
----
@param self StateMachineIter

StateMachineIter instance

----
@param seconds number?

How many seconds to wait

----
@param lap boolean?

If true the timer will still return true when the time has passed, but will "lap" instead of "stop" and keep counting.

----
@param first boolean?

If true the timer returns true when it starts, requires lap to be true.

----
@return timeup boolean

True if the time is up

----

Check if a set period of time has passed. This first time this is called the target time is latched in until true is returned. Ensure you call state:SecondsHavePassed() or state:SecondsHavePassed(nil) to clear the timer if it did not return true and you need to move on.

<<
---------------------------------------------------
StateMachineIter - Core
[section]
----
>>
---------------------------------------------------
Save ( self: StateMachineIter ) -> [1]: string, [2]: target_call, [3]: target_time, [4]: set_wait_time, [5]: state_key, [6]: table
[function] [internal use]
----
@param self StateMachineIter

instance

----
@return [1] string
----
@return [2] target_call
----
@return [3] target_time
----
@return [4] set_wait_time
----
@return [5] state_key
----
@return [6] table
----

Save event function.

@param self StateMachineIter instance @return template string StateMachineIter template name @return target_call integer? Timer's value, nil for not set @return target_time number? TargetTurn's value, nil for not set @return set_wait_time number? Time to wait before running next state, kept to allow altering target_time if set_wait_time changes @return state_key string|integer|nil Current state, string name or integer index if state machine is ordered @return addonData table Addon data, if any

---------------------------------------------------
Load ( template: string, target_call: integer?, target_time: number?, set_wait_time: number?, state_key: integer|string|nil, addonData: table ) -> [1]: table
[function] [internal use]
----
@param template string

StateMachineIter template name

----
@param target_call integer?

Timer's value, nil for not set

----
@param target_time number?

TargetTurn's value, nil for not set

----
@param set_wait_time number?

Time to wait before running next state, kept to allow altering target_time if set_wait_time changes

----
@param state_key integer|string|nil

Current state, string name or integer index if state machine is ordered

----
@param addonData table

Addon data, if any

----
@return [1] table
----

Load event function.

@param template string StateMachineIter template name @param target_call integer? Timer's value, nil for not set @param target_time number? TargetTurn's value, nil for not set @param set_wait_time number? Time to wait before running next state, kept to allow altering target_time if set_wait_time changes @param state_key string|integer|nil Current state, string name or integer index if state machine is ordered @param addonData table Addon data, if any

---------------------------------------------------
TypeLoad ( )
[function] [internal use]
----

TypeLoad event function.

<<
<<
---------------------------------------------------
StateMachineIterWrappedResult
[type]
----
>>
---------------------------------------------------
Abort
[boolean]
----

If true the machine should be considered aborted, allowing for cleanup

---------------------------------------------------
Fast
[boolean]
----

If true the machine will attempt to run the next state immediately

<<
---------------------------------------------------
StateMachineNamedState
[type]
----

Simple construct for a state function with a name

>>
---------------------------------------------------
[1]
[UNK_string|nil] [string] [nil]
----

name

---------------------------------------------------
[2] ( )
[UNK_fun(self: StateMachineIter, ...any):any] [function]
----

State function

<<
---------------------------------------------------
StateMachineNamedStateTruncated
[type]
----

A truncated version without the name, name is constructed at runtime from index

>>
---------------------------------------------------
[1] ( )
[UNK_fun(self: StateMachineIter, ...any):any] [function]
----

State function

<<
---------------------------------------------------
StateMachineStateOrderedSet
[type]
----

A simple ordered set of states

>>
---------------------------------------------------
[integer] ( )
[UNK_StateMachineNamedState] [UNK_StateMachineNamedStateTruncated] [UNK_fun(self: StateMachineIter, ...any):any] [function]
----

State function

<<
---------------------------------------------------
StateMachineStateUnorderedSet
[type]
----

A simple name-only set of states

>>
---------------------------------------------------
[string] ( )
[UNK_fun(self: StateMachineIter, ...any):any] [function]
----

State function

<<
---------------------------------------------------
_statemachine
[type]
----
>>
---------------------------------------------------
game_time
[number]
----

Game time in seconds, used for state machine timing

---------------------------------------------------
Machines
[table<string, StateMachineIter>]
----

Table of StateMachineIter instances, key is the template name and value is the StateMachineIter instance

---------------------------------------------------
MachineFlags
[table<string, { is_ordered: boolean, index_to_name: table, name_to_index: table }>]
----

Table of flags for each StateMachineIter template, key is the template name and value is the flags table

---------------------------------------------------
AbortResult ( ...: any ) -> [1]: StateMachineIterWrappedResult
[function]
----
@param ... any

Return values passed from hook function

---- ----

Create an Abort HookResult

---------------------------------------------------
FastResult ( ???: unknown ) -> [1]: table
[function]
----
@param  unknown
----
@return [1] table
----
---------------------------------------------------
isstatemachineiterwrappedresult ( object: any ) -> [1]: boolean
[function]
----
@param object any
----
@return [1] boolean
----
---------------------------------------------------
isstatemachineiter ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object an instance of StateMachineIter?

--------------------------------------------------- ----
@param name string

Name of the StateMachineIter Template (string)

----
@param ... StateMachineFunction|StateMachineNamedState|StateMachineNamedStateTruncated|StateMachineStateOrderedSet

State descriptor and/or state descriptor collections, can be a table of named state functions or an array of state descriptors.

----

Creates an StateMachineIter Template with the given indentifier. State descriptors are tables with the first element being the state name and the second element being the state function. If the second element is nil, the first element is considered the state function and the state name is generated automatically. If the state descriptor is instead a function it is treated as a nil state and the state name is generated automatically. The first paramater of the state function is the StateMachineIter itself where the current state may be accessed via self.state_key.

---------------------------------------------------
Start ( name: string, state_key: integer|string|nil, init: table? ) -> [1]: StateMachineIter
[function]
----
@param name string

Name of the StateMachineIter Template

----
@param state_key integer|string|nil

Initial state, if nil the first state will be used if the StateMachineIter is ordered, can be an integer is the StateMachineIter is ordered

----
@param init table?

Initial data

----
@return [1] StateMachineIter
----

Starts an StateMachineIter based on the StateMachineIter Template with the given indentifier.

---------------------------------------------------
SleepCalls ( calls: integer, next_state: string, early_exit: StateMachineEarlyExitFunction? ) -> [1]: StateMachineFunction
[function]
----
@param calls integer

How many calls to wait

----
@param next_state string

Next state when timer hits zero

----
@param early_exit StateMachineEarlyExitFunction?

Function to check if the state should be exited early, return false, true, or next state name

----
@return [1] StateMachineFunction
----

Wait a set period of time on this state.

---------------------------------------------------
SleepSeconds ( seconds: number, next_state: integer|string|nil, early_exit: StateMachineEarlyExitFunction? ) -> [1]: StateMachineFunction
[function]
----
@param seconds number

How many seconds to wait

----
@param next_state integer|string|nil

Next state when timer hits zero, nil is auto-next for an ordered machine

----
@param early_exit StateMachineEarlyExitFunction?

Function to check if the state should be exited early, return false, true, or next state name

----
@return [1] StateMachineFunction
----

Wait a set period of time on this state.

<<
---------------------------------------------------
StateMachineFunction : fun(self:StateMachineIter,
[alias]
----
---------------------------------------------------
StateMachineEarlyExitFunction : fun(self:StateMachineIter,
[alias]
----

Early exit function for state machine iterators, if a string or integer is returned it is the next state

<<

===================================================

_stateset -> table: _stateset

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API StateSetRunner.

Simplistic system to run multiple functions or "states" in a single call. The main use case of this is to hold multiple toggelable objectives. If you want to do something more complex, use the hook module instead. Like most similar constructs State Set Runners have internal data storage and can be saved and loaded.

local stateset = require("_stateset");

stateset.Create("TestSet")
    :Add("state_a", function(runner, a, b)
        print("test " .. runner.test1 .. " " .. tostring(a) .. " " .. tostring(b));
    end)
    :Add("state_a", function(runner, a, b)
        print("test " .. runner.test2 .. " " .. tostring(a) .. " " .. tostring(b));
    end, true);

hook.Add("InitialSetup", "Custom_InitialSetup", function(turn)
    MissionData.TestSet = statemachine.Start("TestSet",{test1='d',test2="e");
    MissionData.TestSet:on("state_a"); -- state true
    MissionData.TestSet:on("state_b"); -- state 1
    MissionData.TestSet:on("state_b"); -- state 2
    MissionData.TestSet:off("state_b"); -- state 1, still on as this is a permit based state
end);

hook.Add("Update", "Custom_Update", function(turn)
    MissionData.TestSMI:run(1, 2);
end);
>>
---------------------------------------------------
StateSet
[type]
----
>>
---------------------------------------------------
template
[string]
----

Name of the StateSet template

---------------------------------------------------
__index:StateSet (inner_type)
[UNK_StateSet]
TYPE: UNK_StateSet
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----
---------------------------------------------------
Add ( self: StateSet, name: string, state: StateSetFunction, permitBased: boolean? ) -> self: StateSet
[function]
----
@param self StateSet

StateSet instance

----
@param name string

Name of the state

----
@param state StateSetFunction

Function to be called when the state is active, should return true if the state did something.

----
@param permitBased boolean?

If true, the state is permit based

----
@return self StateSet

For function chaining

----

Add a state to the StateSet. If the state is basic either active or inactive based on last on/off call. If the state is permit based it is active if the on count is greater than 0.

<<
---------------------------------------------------
StateSetRunner : CustomSavableType
[type]
----

An object containing all functions and data related to an StateSetRunner.

>>
---------------------------------------------------
Other
[section]
----
>>
---------------------------------------------------
template
[string]
----

Name of the StateSet template the runner is using

---------------------------------------------------
active_states
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

Table of active states, key is the state name and value is the state activation flag or permit count

---------------------------------------------------
addonData
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

Custom context data stored in the StateSetRunner

---------------------------------------------------
__index ( table: any, key: any ) -> [1]: unknown?
[function]
----
@param table any
----
@param key any
----
@return [1] unknown?
----
---------------------------------------------------
__newindex ( table: any, key: any, value: any )
[function]
----
@param table any
----
@param key any
----
@param value any
----
---------------------------------------------------
__type
[string]
----
---------------------------------------------------
run ( self: StateSetRunner, ...: any ) -> True: boolean
[function]
----
@param self StateSetRunner

StateSetRunner instance

----
@param ... any

Arguments to pass to the state function

----
@return True boolean

if at least one state was found and executed and returned true

----

Run StateSetRunner.

---------------------------------------------------
on ( self: StateSetRunner, name: string ) -> StateSetRunner: StateSetRunner
[function]
----
@param self StateSetRunner

StateSetRunner instance

----
@param name string

Name of the state

----
@return StateSetRunner StateSetRunner

For function chaining

----

Set state on.

---------------------------------------------------
off ( self: StateSetRunner, name: string, force: boolean? ) -> StateSetRunner: StateSetRunner
[function]
----
@param self StateSetRunner

StateSetRunner instance

----
@param name string

Name of the state

----
@param force boolean?

If true, the state is set off regardless of the current permits

----
@return StateSetRunner StateSetRunner

For function chaining

----

Set state off.

<<
---------------------------------------------------
StateSetRunner - Core
[section]
----
>>
---------------------------------------------------
Save ( self: StateSetRunner ) -> [1]: string, [2]: table, [3]: table
[function] [internal use]
----
@param self StateSetRunner

instance

----
@return [1] string
----
@return [2] table
----
@return [3] table
----

Save event function.

@param self StateSetRunner instance @return ...

---------------------------------------------------
Load ( template: any, active_states: any, addonData: any ) -> [1]: table
[function] [internal use]
----
@param template any
----
@param active_states any
----
@param addonData any
----
@return [1] table
----

Load event function.

@param template @param active_states @param addonData

<<
<<
---------------------------------------------------
StateSetRunnerWithMachines : StateSetRunner
[type]
----
>>
---------------------------------------------------
Other
[section]
----
>>
---------------------------------------------------
template
[string]
----

Name of the StateSet template the runner is using

---------------------------------------------------
active_states
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

Table of active states, key is the state name and value is the state activation flag or permit count

---------------------------------------------------
addonData
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

Custom context data stored in the StateSetRunner

---------------------------------------------------
__index ( table: any, key: any ) -> [1]: unknown?
[function]
----
@param table any
----
@param key any
----
@return [1] unknown?
----
---------------------------------------------------
__newindex ( table: any, key: any, value: any )
[function]
----
@param table any
----
@param key any
----
@param value any
----
---------------------------------------------------
__type
[string]
----
---------------------------------------------------
machines
[table<string, StateMachineIter>] [table<string, StateMachineIter>?>] [nil]
----

Optional table of StateMachineIter instances used by this StateSetRunner

---------------------------------------------------
run ( self: StateSetRunner, ???: any ) -> True: boolean
[function]
----
@param self StateSetRunner

StateSetRunner instance

----
@param  any
----
@return True boolean

if at least one state was found and executed and returned true

----

Run StateSetRunner.

---------------------------------------------------
on ( self: StateSetRunner, name: string ) -> StateSetRunner: StateSetRunner
[function]
----
@param self StateSetRunner

StateSetRunner instance

----
@param name string

Name of the state

----
@return StateSetRunner StateSetRunner

For function chaining

----

Set state on.

---------------------------------------------------
off ( self: StateSetRunner, name: string, force: boolean? ) -> StateSetRunner: StateSetRunner
[function]
----
@param self StateSetRunner

StateSetRunner instance

----
@param name string

Name of the state

----
@param force boolean?

If true, the state is set off regardless of the current permits

----
@return StateSetRunner StateSetRunner

For function chaining

----

Set state off.

<<
---------------------------------------------------
StateSetRunner - Core
[section]
----
>>
---------------------------------------------------
Save ( self: StateSetRunner ) -> [1]: string, [2]: table, [3]: table
[function] [internal use]
----
@param self StateSetRunner

An object containing all functions and data related to an StateSetRunner.

----
@return [1] string
----
@return [2] table
----
@return [3] table
----

Save event function.

@param self StateSetRunner instance @return ...

---------------------------------------------------
Load ( template: any, active_states: any, addonData: any ) -> [1]: table
[function] [internal use]
----
@param template any
----
@param active_states any
----
@param addonData any
----
@return [1] table
----

Load event function.

@param template @param active_states @param addonData

<<
<<
---------------------------------------------------
_stateset
[type]
----
>>
---------------------------------------------------
Sets
[table<string, StateSet>]
----

Table of StateSet instances, key is the template name and value is the StateSet instance

---------------------------------------------------
WrapStateMachine ( name: string, state_key: integer|string|nil, init: table? ) -> [1]: StateSetFunction
[function]
----
@param name string

Name of the StateMachineIter Template

----
@param state_key integer|string|nil

Initial state, if nil the first state will be used if the StateMachineIter is ordered, can be an integer is the StateMachineIter is ordered

----
@param init table?

Initial data

----
@return [1] StateSetFunction
----

Wrap a state machine definition so it can be used in a StateSet. The StateMachineIter's instance is stored in the machines table of the StateSetRunner instance, key is the state name.

---------------------------------------------------
isstatesetrunner ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object an instance of StateSetRunner?

---------------------------------------------------
Create ( name: string ) -> StateSet: StateSet
[function]
----
@param name string

Name of the StateSetRunner Template

----
@return StateSet StateSet

for calling Add and AddPermit, can not be saved.

----

Creates an StateSetRunner Template with the given indentifier.

---------------------------------------------------
Start ( name: string, init: table? ) -> [1]: table
[function]
----
@param name string

Name of the StateSetRunner Template

----
@param init table?

Initial data

----
@return [1] table
----

Starts an StateSetRunner based on the StateSetRunner Template with the given indentifier.

<<
---------------------------------------------------
StateSetFunction : fun(self:StateSetRunner, name:string, ...:any)
[alias]
----
<<

===================================================

_table_show

Authors:
  • Julio Manuel Fernandez-Diaz
----

BZ98R LUA Extended API table to string. Converts table to string representation.

January 12, 2007 (For Lua 5.1)

Modified slightly by RiciLake to avoid the unnecessary table traversal in tablecount().

Modified slightly by John "Nielk1" Klein for Lua Language Server.

Convert table to string representation.

Heavily based on "Saving tables with cycles", PIL2, p. 113.

Formats tables with cycles recursively to any depth. The output is returned as a string. References to other tables are shown as values. Self references are indicated.

The string returned is "Lua code", which can be procesed (in the case in which indent is composed by spaces or "--").

Userdata and function keys and values are shown as strings, which logically are exactly not equivalent to the original code.

print(table.show(t, "t"))   -- a typical use

===================================================

_tracker -> table: _tracker

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Tracker.

Tracks objects by class and odf.

local tracker = require("_tracker");

-- if no filters are set all objects will be tracked
tracker.setFilterTeam(1, true);
tracker.setFilterClass("TANK", true);
>>
---------------------------------------------------
_tracker
[type]
----
>>
---------------------------------------------------
countByClassSig ( sig: string, team: integer? ) -> [1]: integer|unknown
[function]
----
@param sig string

ClassSig name to count.

----
@param team integer?

Team number to count for.

----
@return [1] integer|unknown
----

Count object by ClassSig @todo add protections

---------------------------------------------------
countByClassName ( classname: string, team: integer? ) -> [1]: integer|unknown
[function]
----
@param classname string

ClassName name to count.

----
@param team integer?

Team number to count for.

----
@return [1] integer|unknown
----

Count object by ClassName @todo add protections

---------------------------------------------------
countByOdf ( odf: string, team: integer? ) -> [1]: integer|unknown
[function]
----
@param odf string

Odf name to count.

----
@param team integer?

Team number to count for.

----
@return [1] integer|unknown
----

Count object by class @todo add protections

---------------------------------------------------
setFilterTeam ( team: integer, enabled: boolean? )
[function]
----
@param team integer

Team number to track.

----
@param enabled boolean?

Enable or disable tracking for the team. Defaults to true.

----

Enable tracking for a team. Note that items that no longer fit the filter will remain in the tracker. Note that on the next update if needed an AllObjects scan will be performed to update the tracker for new filtered items.

---------------------------------------------------
setFilterClass ( class: ClassLabel|ClassSig, enabled: boolean? )
[function]
----
@param class ClassLabel|ClassSig

Class name to track.

----
@param enabled boolean?

Enable or disable tracking for the class. Defaults to true.

----

Enable tracking for a class. Note that items that no longer fit the filter will remain in the tracker. Note that on the next update if needed an AllObjects scan will be performed to update the tracker for new filtered items. Note that the odf and class filters are independent, so if you set a class filter to true and an odf filter to false, the class will be tracked but the odf will not.

---------------------------------------------------
setFilterOdf ( odf: string, enabled: boolean? )
[function]
----
@param odf string

Odf name to track.

----
@param enabled boolean?

Enable or disable tracking for the odf. Defaults to true.

----

Enable tracking for an odf. Note that items that no longer fit the filter will remain in the tracker. Note that on the next update if needed an AllObjects scan will be performed to update the tracker for new filtered items. Note that the odf and class filters are independent, so if you set a class filter to true and an odf filter to false, the class will be tracked but the odf will not.

<<
<<

===================================================

_utility -> table: _utility

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Utility.

>>
---------------------------------------------------
Other
[section]
----
>>
---------------------------------------------------
WeightedItem
[type]
----
>>
---------------------------------------------------
item:any (inner_type)
[UNK_any]
TYPE: UNK_any
SPECIAL: inner_type
GLYPH: bi bi-question-circle
----

The item to be chosen.

---------------------------------------------------
chance
[number]
----

The weight of the item.

<<
---------------------------------------------------
_utility
[type]
----
>>
---------------------------------------------------
Enumerations
[section]
----
>>
---------------------------------------------------
TeamSlotString : TeamSlotString
[enum TeamSlotString]
----
---------------------------------------------------
TeamSlotInteger : TeamSlotIntegerEnum
[enum TeamSlotIntegerEnum]
----
---------------------------------------------------
ClassLabel : ClassLabel
[enum ClassLabel]
----
---------------------------------------------------
ClassSig : ClassSig
[enum ClassSig]
----
---------------------------------------------------
TeamSlotRanges
[table<ClassLabel|ClassSig, { [1]: integer, [2]: integer }>]
----

TeamSlotRanges

---------------------------------------------------
GetClassLabel ( input: ClassLabel|ClassSig|string ) -> classLabel: ClassLabel?
[function]
----
@param input ClassLabel|ClassSig|string

The class label or class signature.

----
@return classLabel ClassLabel?

The class label.

----

Get the ClassLabel string for any ClassSig or ClassLabel.

---------------------------------------------------
GetClassSig ( input: ClassLabel|ClassSig|string|nil ) -> classSig: ClassSig?
[function]
----
@param input ClassLabel|ClassSig|string|nil

The class label or class signature.

----
@return classSig ClassSig?

The class signature.

----

Get the ClassSig string for any ClassLabel or ClassSig.

<<
---------------------------------------------------
Type Check Functions
[section]
----
>>
---------------------------------------------------
isfunction ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object a function?

---------------------------------------------------
istable ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object a table?

---------------------------------------------------
isstring ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object a string?

---------------------------------------------------
isboolean ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object a boolean?

---------------------------------------------------
isnumber ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object a number?

---------------------------------------------------
isinteger ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object an integer?

---------------------------------------------------
isHandle ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object a Handle?

---------------------------------------------------
isVector ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object a Vector?

---------------------------------------------------
isMatrix ( object: any ) -> [1]: boolean
[function]
----
@param object any

Object in question

----
@return [1] boolean
----

Is this object a Matrix?

<<
---------------------------------------------------
Utility - Table Operations
[section]
----
>>
---------------------------------------------------
shallowCopy ( original: any ) -> [1]: table
[function]
----
@param original any
----
@return [1] table
----
<<
---------------------------------------------------
Utility - Array Operations
[section]
----
>>
---------------------------------------------------
ChooseOne ( ...: any ) -> item: any
[function]
----
@param ... any

The items to choose from.

----
@return item any

The chosen item.

----

Chooses a random item from a list of items.

---------------------------------------------------
ChooseOneWeighted ( ...: WeightedItem ) -> item: WeightedItem|any
[function]
----
@param ... WeightedItem

The items to choose from.

----
@return item WeightedItem|any

The chosen item.

----

Chooses a random item from a list of weighted items.

<<
---------------------------------------------------
Utility - Iterator Operations
[section]
----
>>
---------------------------------------------------
IteratorToArray ( iterator: fun():any|fun():any, any ) -> result: table
[function]
----
@param iterator fun():any|fun():any, any

The iterator to convert

----
@return result table

The resulting array or table

----

Convert an iterator to an array or table. If the iterator returns only values, returns an array. If the iterator returns key-value pairs, returns a table.

<<
<<
<<
---------------------------------------------------
Enumerations
[section]
----
>>
---------------------------------------------------
TeamSlotString
[enum]
----

TeamSlotStrings

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

TeamSlotIntegers

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

ClassLabels

>>
["PROD"] = "producer": string
["HOVR"] = "hover": string
["WEPN"] = "weapon": string
["GOBJ"] = "gameobject": string
["ORDN"] = "ordnance": string
["APC\0"] = "apc": string
["APC"] = "apc": string

compatability

["ARMR"] = "armory": string
["CNST"] = "constructionrig": string
["FACT"] = "factory": string
["PLNT"] = "powerplant": string
["RCYC"] = "recycler": string
["SCAV"] = "scavenger": string
["SDRP"] = "dropoff": string
["SDEP"] = "supplydepot": string
["TUG\0"] = "tug": string
["TUG"] = "tug": string

compatability

["TTNK"] = "turrettank": string
["ARTI"] = "artifact": string
["BARR"] = "barracks": string
["BLDG"] = "i76building": string
["COMM"] = "commtower": string
["CRFT"] = "craft": string
["WRCK"] = "daywrecker": string
["GEIZ"] = "geyser": string
["MLYR"] = "minelayer": string
["PERS"] = "person": string
["PWUP"] = "powerup": string
["CPOD"] = "camerapod": string
["AMMO"] = "ammopack": string
["RKIT"] = "repairkit": string
["RDEP"] = "repairdepot": string
["SAV\0"] = "sav": string
["SAV"] = "sav": string

compatability

["SFLD"] = "scrapfield": string
["SILO"] = "scrapsilo": string
["SHLD"] = "shieldtower": string
["SPWN"] = "spawnpnt": string
["TORP"] = "torpedo": string
["WING"] = "wingman": string
["HWTZ"] = "howitzer": string
["TURR"] = "turret": string
["WALK"] = "walker": string
["SCRP"] = "scrap": string
["PORT"] = "portal": string
["producer"] = "producer": string
["hover"] = "hover": string
["weapon"] = "weapon": string
["gameobject"] = "gameobject": string
["ordnance"] = "ordnance": string
["apc"] = "apc": string
["armory"] = "armory": string
["constructionrig"] = "constructionrig": string
["factory"] = "factory": string
["powerplant"] = "powerplant": string
["recycler"] = "recycler": string
["scavenger"] = "scavenger": string
["dropoff"] = "dropoff": string
["supplydepot"] = "supplydepot": string
["tug"] = "tug": string
["turrettank"] = "turrettank": string
["artifact"] = "artifact": string
["barracks"] = "barracks": string
["i76building"] = "i76building": string
["commtower"] = "commtower": string
["craft"] = "craft": string
["daywrecker"] = "daywrecker": string
["geyser"] = "geyser": string
["minelayer"] = "minelayer": string
["person"] = "person": string
["powerup"] = "powerup": string
["camerapod"] = "camerapod": string
["ammopack"] = "ammopack": string
["repairkit"] = "repairkit": string
["repairdepot"] = "repairdepot": string
["sav"] = "sav": string
["scrapfield"] = "scrapfield": string
["scrapsilo"] = "scrapsilo": string
["shieldtower"] = "shieldtower": string
["spawnpnt"] = "spawnpnt": string
["torpedo"] = "torpedo": string
["wingman"] = "wingman": string
["howitzer"] = "howitzer": string
["turret"] = "turret": string
["walker"] = "walker": string
["scrap"] = "scrap": string
["portal"] = "portal": string
<<
---------------------------------------------------
ClassSig
[enum]
----

ClassSigs

>>
["producer"] = "PROD": string
["hover"] = "HOVR": string
["weapon"] = "WEPN": string
["gameobject"] = "GOBJ": string
["ordnance"] = "ORDN": string
["apc"] = "APC\0": string
["armory"] = "ARMR": string
["constructionrig"] = "CNST": string
["factory"] = "FACT": string
["powerplant"] = "PLNT": string
["recycler"] = "RCYC": string
["scavenger"] = "SCAV": string
["dropoff"] = "SDRP": string
["supplydepot"] = "SDEP": string
["tug"] = "TUG\0": string
["turrettank"] = "TTNK": string
["artifact"] = "ARTI": string
["barracks"] = "BARR": string
["i76building"] = "BLDG": string
["commtower"] = "COMM": string
["craft"] = "CRFT": string
["daywrecker"] = "WRCK": string
["geyser"] = "GEIZ": string
["minelayer"] = "MLYR": string
["person"] = "PERS": string
["powerup"] = "PWUP": string
["camerapod"] = "CPOD": string
["ammopack"] = "AMMO": string
["repairkit"] = "RKIT": string
["repairdepot"] = "RDEP": string
["sav"] = "SAV\0": string
["scrapfield"] = "SFLD": string
["scrapsilo"] = "SILO": string
["shieldtower"] = "SHLD": string
["spawnpnt"] = "SPWN": string
["torpedo"] = "TORP": string
["wingman"] = "WING": string
["howitzer"] = "HWTZ": string
["turret"] = "TURR": string
["walker"] = "WALK": string
["scrap"] = "SCRP": string
["portal"] = "PORT": string
["PROD"] = "PROD": string
["HOVR"] = "HOVR": string
["WEPN"] = "WEPN": string
["GOBJ"] = "GOBJ": string
["ORDN"] = "ORDN": string
["APC"] = "APC\0": string
["APC\0"] = "APC\0": string
["ARMR"] = "ARMR": string
["CNST"] = "CNST": string
["FACT"] = "FACT": string
["PLNT"] = "PLNT": string
["RCYC"] = "RCYC": string
["SCAV"] = "SCAV": string
["SDRP"] = "SDRP": string
["SDEP"] = "SDEP": string
["TUG"] = "TUG\0": string
["TUG\0"] = "TUG\0": string
["TTNK"] = "TTNK": string
["ARTI"] = "ARTI": string
["BARR"] = "BARR": string
["BLDG"] = "BLDG": string
["COMM"] = "COMM": string
["CRFT"] = "CRFT": string
["WRCK"] = "WRCK": string
["GEIZ"] = "GEIZ": string
["MLYR"] = "MLYR": string
["PERS"] = "PERS": string
["PWUP"] = "PWUP": string
["CPOD"] = "CPOD": string
["AMMO"] = "AMMO": string
["RKIT"] = "RKIT": string
["RDEP"] = "RDEP": string
["SAV"] = "SAV\0": string
["SAV\0"] = "SAV\0": string
["SFLD"] = "SFLD": string
["SILO"] = "SILO": string
["SHLD"] = "SHLD": string
["SPWN"] = "SPWN": string
["TORP"] = "TORP": string
["WING"] = "WING": string
["HWTZ"] = "HWTZ": string
["TURR"] = "TURR": string
["WALK"] = "WALK": string
["SCRP"] = "SCRP": string
["PORT"] = "PORT": string
PRODUCER = 'PROD': string
HOVER = 'HOVR': string
POWERUP_WEAPON = 'WEPN': string
GAMEOBJECT = 'GOBJ': string
ORDNANCE = 'ORDN': string
ARMORY = 'ARMR': string
CONSTRUCTIONRIG = 'CNST': string
FACTORY = 'FACT': string
POWERPLANT = 'PLNT': string
RECYCLER = 'RCYC': string
SCAVENGER = 'SCAV': string
SCRAPDROPOFF = 'SDRP': string
SUPPLYDEPOT = 'SDEP': string
TURRETTANK = 'TTNK': string
ARTIFACT = 'ARTI': string
BARRACKS = 'BARR': string
BUILDING = 'BLDG': string
COMMTOWER = 'COMM': string
CRAFT = 'CRFT': string
DAYWRECKER = 'WRCK': string
GEIZER = 'GEIZ': string
MINELAYER = 'MLYR': string
PERSON = 'PERS': string
POWERUP = 'PWUP': string
POWERUP_CAMERA = 'CPOD': string
POWERUP_RELOAD = 'AMMO': string
POWERUP_REPAIR = 'RKIT': string
REPAIRDEPOT = 'RDEP': string
SCRAPFIELD = 'SFLD': string
SCRAPSILO = 'SILO': string
SHIELDTOWER = 'SHLD': string
SPAWNBUOY = 'SPWN': string
TORPEDO = 'TORP': string
WINGMAN = 'WING': string
HOWITZER = 'HWTZ': string
TURRET = 'TURR': string
WALKER = 'WALK': string
SCRAP = 'SCRP': string
PORTAL = 'PORT': string
<<
---------------------------------------------------
TeamSlotRange : { [1]: TeamSlotInteger, [2]: TeamSlotInteger }
[alias]
----

TeamSlotRange

<<
<<

===================================================

_version -> table: _version

Authors:
  • John "Nielk1" Klein
----

BZ98R LUA Extended API Version Utility.

>>
---------------------------------------------------
_version
[type]
----
>>
---------------------------------------------------
game
[string]
----

The game version, e.g. "2.2.315"

---------------------------------------------------
lua
[string]
----

The Lua version, e.g. "Lua 5.1"

---------------------------------------------------
api
[string]
----

The version of this LUA Extended API, e.g. "0.1.1"

---------------------------------------------------
bzcp
[string] [nil]
----

The BZCP version, if available, e.g. "0.3"

---------------------------------------------------
shim
[integer] [nil]
----

The BZCP shim version, if available, e.g. 1

---------------------------------------------------
All ( ) -> Iterator: fun(key: string, label: string, version: string|integer)
[function]
----
@return Iterator fun(key: string, label: string, version: string|integer)

function iterating over all versions for easy output

----

Iterate all versions in a simple format. This function returns an iterator that yields key, label, and version for each version token.

local version = require("_version");
print("Versions:")
for _,l,v in version.All() do
    if v then
        print("  " .. l .. ": " .. tostring(v));
    else
        print("  " .. l .. ": ????");
    end
end
---------------------------------------------------
Compare ( version1: string, version2: string ) -> comparison: -1|0|1
[function]
----
@param version1 string

The first version string

----
@param version2 string

The second version string

----
@return comparison -1|0|1

depending on the comparison result

----

Compare two version strings. This function compares two version strings in the format d, d.d, d.d.d, d.d.d.d, d.d.d.da, and d.d.d.dad where d is a digit and a is an alphanumeric character. It returns -1 if version1 is less than version2, 1 if version1 is greater than version2, and 0 if they are equal.

<<
<<

===================================================

_waves -> table: _waves

Authors:
  • John "Nielk1" Klein
  • Janne Trollebø
----

BZ98R LUA Extended API Wave Spawner.

Wave Spawner

>>
---------------------------------------------------
"WaveSpawner:Spawned" ( name: string, units: GameObject[], leader: GameObject )
[event]
----
@add Add
----
@call CallAllNoReturn
----
@param name string

The name of the wave spawner.

----
@param units GameObject[]

The gameobjects that were spawned.

----
@param leader GameObject

The leader gameobject.

----

Called when a wave spawner has spawned a wave.

---------------------------------------------------
WaveSpawner : StateMachineIter
[type]
----
>>
---------------------------------------------------
name
[string]
----

The name of the wave spawner. "WaveSpawner:Spawned" event fired

---------------------------------------------------
frequency
[number]
----

The frequency of waves.

---------------------------------------------------
variance
[number]
----

The variance of wave frequency.

---------------------------------------------------
wait_time
[number]
----

The time to wait before the next wave.

---------------------------------------------------
factions
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

OLD: A list of factions from which a random will be selected.

---------------------------------------------------
locations
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

OLD: A list of locations where waves can spawn, considered if the name is not the same as a faction name, or it is the same as a selected faction.

---------------------------------------------------
wave_types
[table]
TYPE: table
SPECIAL: inner_type
GLYPH: bi bi-table
----

OLD: Array of weighted formation tables

---------------------------------------------------
waves_left
[number]
----

The number of waves left to spawn.

---------------------------------------------------
__index ( tbl: any, key: any ) -> [1]: unknown?
[function]
----
@param tbl any
----
@param key any
----
@return [1] unknown?
----
---------------------------------------------------
__newindex ( tbl: any, key: any, value: any )
[function]
----
@param tbl any
----
@param key any
----
@param value any
----
---------------------------------------------------
__type
[string]
----
---------------------------------------------------
IsAlive ( self: WaveSpawner ) -> [1]: boolean
[function]
----
@param self WaveSpawner
----
@return [1] boolean
----

Checks if the WaveSpawner is alive. (Has waves left to spawn)

---------------------------------------------------
Save ( self: WaveSpawner, self: any ) -> StateMachineIter: table
[function] [internal use]
----
@param self WaveSpawner
----
@param self any
----
@return StateMachineIter table
----

Saves the WaveSpawner state.

---------------------------------------------------
Load ( machine: StateMachineIter ) -> [1]: WaveSpawner
[function] [internal use]
----
@param machine StateMachineIter
----
@return [1] WaveSpawner
----

Loads the WaveSpawner state.

<<
---------------------------------------------------
_waves
[type]
----
>>
---------------------------------------------------
SpawnInFormation ( formation: string[], location: PathWithIndex|Vector|string, dir: Vector?, units: string[], team: TeamNum, seperation: integer? ) -> units: GameObject[], leader: GameObject?
[function]
----
@param formation string[]

Array of strings, each string is a row, numbers are unit indices in 'units'

----
@param location PathWithIndex|Vector|string

Center position of the formation

----
@param dir Vector?

Direction the formation faces (forward)

----
@param units string[]

List of unit ODFs, indexed by number in formation

----
@param team TeamNum

Team to assign units to

----
@param seperation integer?

Distance between units (optional, default 10)

----
@return units GameObject[]
----
@return leader GameObject?
----

Spawns units in a specified formation at a location, facing a direction.

---------------------------------------------------
new ( name: string, factions: table, locations: table, wave_frequency: number, waves_left: number, variance: number, wave_types: table ) -> [1]: WaveSpawner
[function]
----
@param name string
----
@param factions table
----
@param locations table
----
@param wave_frequency number
----
@param waves_left number
----
@param variance number
----
@param wave_types table
----
@return [1] WaveSpawner
----

Creates a new WaveSpawner instance.

<<
<<