This is an automatically generated listing of the new Lua map scripting API, generated for release-20160508 of OpenRA.
OpenRA allows custom maps and missions to be scripted using Lua 5.1. These scripts run in a sandbox that prevents access to unsafe functions (e.g. OS or file access), and limits the memory and CPU usage of the scripts.
You can access this interface by adding the LuaScript trait to the world actor in your map rules (note, you must replace the spaces in the snippet below with a single tab for each level of indentation):
Rules:
World:
LuaScript:
Scripts: myscript.lua
Map scripts can interact with the game engine in three ways:
* Global tables provide functions for interacting with the global world state, or performing general helper tasks.
They exist in the global namespace, and can be called directly using <table name>.<function name>
.
* Individual actors expose a collection of properties and commands that query information or modify their state.
* Some commands, marked as queued activity, are asynchronous. Activities are queued on the actor, and will run in sequence until the queue is empty or the Stop command is called. Actors that are not performing an activity are Idle (actor.IsIdle will return true). The properties and commands available on each actor depends on the traits that the actor specifies in its rule definitions.
* Individual players expose a collection of properties and commands that query information or modify their state.
The properties and commands available on each actor depends on the traits that the actor specifies in its rule definitions.
For a basic guide about map scripts see the Map Scripting
wiki page.
Actor | |
---|---|
int BuildTime(string type) | Returns the build time (in ticks) of the requested unit type. |
Actor Create(string type, bool addToWorld, LuaTable initTable) | Create a new actor. initTable specifies a list of key-value pairs that defines the initial parameters for the actor's traits. |
int CruiseAltitude(string type) | Returns the cruise altitude of the requested unit type (zero if it is ground-based). |
Beacon | |
---|---|
Beacon New(Player owner, WPos position, int duration = 750, bool showRadarPings = True, string palettePrefix = player) | Creates a new beacon that stays for the specified time at the specified WPos. Does not remove player set beacons, nor gets removed by placing them. |
Camera | |
---|---|
WPos Position { get; set; } | The center of the visible viewport. |
CPos | |
---|---|
CPos New(int x, int y) | Create a new CPos with the specified coordinates. |
CPos Zero { get; } | The cell coordinate origin. |
CVec | |
---|---|
CVec New(int x, int y) | Create a new CVec with the specified coordinates. |
CVec Zero { get; } | The cell zero-vector. |
DateTime | |
---|---|
int GameTime { get; } | Get the current game time (in ticks). |
bool IsHalloween { get; } | True on the 31st of October. |
int Minutes(int minutes) | Converts the number of minutes into game time (ticks). |
int Seconds(int seconds) | Converts the number of seconds into game time (ticks). |
Facing | |
---|---|
int East { get; } | |
int North { get; } | |
int NorthEast { get; } | |
int NorthWest { get; } | |
int South { get; } | |
int SouthEast { get; } | |
int SouthWest { get; } | |
int West { get; } |
HSLColor | |
---|---|
HSLColor Aqua { get; } | |
HSLColor Black { get; } | |
HSLColor Blue { get; } | |
HSLColor Brown { get; } | |
HSLColor Cyan { get; } | |
HSLColor DarkBlue { get; } | |
HSLColor DarkCyan { get; } | |
HSLColor DarkGray { get; } | |
HSLColor DarkGreen { get; } | |
HSLColor DarkOrange { get; } | |
HSLColor DarkRed { get; } | |
HSLColor FromHex(string value) | Create a new HSL color with the specified red/green/blue/[alpha] hex string (rrggbb[aa]). |
HSLColor FromRGB(int red, int green, int blue, int alpha = 255) | Create a new HSL color with the specified red/green/blue/[alpha] values. |
HSLColor Fuchsia { get; } | |
HSLColor Gold { get; } | |
HSLColor Gray { get; } | |
HSLColor Green { get; } | |
HSLColor LawnGreen { get; } | |
HSLColor LightBlue { get; } | |
HSLColor LightCyan { get; } | |
HSLColor LightGray { get; } | |
HSLColor LightGreen { get; } | |
HSLColor LightYellow { get; } | |
HSLColor Lime { get; } | |
HSLColor LimeGreen { get; } | |
HSLColor Magenta { get; } | |
HSLColor Maroon { get; } | |
HSLColor Navy { get; } | |
HSLColor New(int hue, int saturation, int luminosity) | Create a new HSL color with the specified hue/saturation/luminosity. |
HSLColor Olive { get; } | |
HSLColor Orange { get; } | |
HSLColor OrangeRed { get; } | |
HSLColor Purple { get; } | |
HSLColor Red { get; } | |
HSLColor Salmon { get; } | |
HSLColor SkyBlue { get; } | |
HSLColor Teal { get; } | |
HSLColor White { get; } | |
HSLColor Yellow { get; } |
Lighting | |
---|---|
Double Ambient { get; set; } | |
Double Blue { get; set; } | |
void Flash(string type = nil, int ticks = -1) | Controls the `FlashPaletteEffect` trait. |
Double Green { get; set; } | |
Double Red { get; set; } |
Map | |
---|---|
Actor[] ActorsInBox(WPos topLeft, WPos bottomRight, LuaFunction filter = nil) | Returns a table of all actors within the requested rectangle, filtered using the specified function. |
Actor[] ActorsInCircle(WPos location, WDist radius, LuaFunction filter = nil) | Returns a table of all actors within the requested region, filtered using the specified function. |
Actor[] ActorsWithTag(string tag) | Returns a table of all actors tagged with the given string. |
WPos BottomRight { get; } | Returns the location of the bottom-right corner of the map (assuming zero terrain height). |
WPos CenterOfCell(CPos cell) | Returns the center of a cell in world coordinates. |
CPos ClosestEdgeCell(CPos givenCell) | Returns the closest cell on the visible border of the map from the given cell. |
CPos ClosestMatchingEdgeCell(CPos givenCell, LuaFunction filter) | Returns the first cell on the visible border of the map from the given cell, matching the filter function called as function(CPos cell). |
string Difficulty { get; } | Returns the difficulty selected by the player before starting the mission. |
bool IsNamedActor(Actor actor) | Returns true if actor was originally specified in the map file. |
bool IsSinglePlayer { get; } | Returns true if there is only one human player. |
Actor NamedActor(string actorName) | Returns the actor that was specified with a given name in the map file (or nil, if the actor is dead or not found). |
Actor[] NamedActors { get; } | Returns a table of all the actors that were specified in the map file. |
CPos RandomCell() | Returns a random cell inside the visible region of the map. |
CPos RandomEdgeCell() | Returns a random cell on the visible border of the map. |
WPos TopLeft { get; } | Returns the location of the top-left corner of the map (assuming zero terrain height). |
Media | |
---|---|
void Debug(string text) | Displays a debug message to the player, if "Show Map Debug Messages" is checked in the settings. |
void DisplayMessage(string text, string prefix = Mission, Nullable`1 color = nil) | Display a text message to the player. |
void FloatingText(string text, WPos position, int duration = 30, Nullable`1 color = nil) | Display a text message at the specified location. |
void PlayMovieFullscreen(string movie, LuaFunction func = nil) | Play a VQA video fullscreen. File name has to include the file extension. |
bool PlayMovieInRadar(string movie, LuaFunction playComplete = nil) | Play a VQA video in the radar window. File name has to include the file extension. Returns true on success, if the movie wasn't found the function returns false and the callback is executed. |
void PlayMusic(string track = nil, LuaFunction func = nil) | Play track defined in music.yaml or map.yaml, or keep track empty for playing a random song. |
void PlaySound(string file) | Play a sound file |
void PlaySoundNotification(Player player, string notification) | Play a sound listed in notifications.yaml |
void PlaySpeechNotification(Player player, string notification) | Play an announcer voice listed in notifications.yaml |
void SetBackgroundMusic(string track = nil) | Play track defined in music.yaml or map.yaml as background music. If music is already playing use Media.StopMusic() to stop it and the background music will start automatically. Keep the track empty to disable background music. |
void StopMusic() | Stop the current song. |
Player | |
---|---|
Player GetPlayer(string name) | Returns the player with the specified internal name, or nil if a match is not found. |
Player[] GetPlayers(LuaFunction filter) | Returns a table of players filtered by the specified function. |
Reinforcements | |
---|---|
Actor[] Reinforce(Player owner, String[] actorTypes, CPos[] entryPath, int interval = 25, LuaFunction actionFunc = nil) | Send reinforcements consisting of multiple units. Supports ground-based, naval and air units. The first member of the entryPath array will be the units' spawnpoint, while the last one will be their destination. If actionFunc is given, it will be executed once a unit has reached its destination. actionFunc will be called as actionFunc(Actor actor) |
LuaTable ReinforceWithTransport(Player owner, string actorType, String[] cargoTypes, CPos[] entryPath, CPos[] exitPath = nil, LuaFunction actionFunc = nil, LuaFunction exitFunc = nil) | Send reinforcements in a transport. A transport can be a ground unit (APC etc.), ships and aircraft. The first member of the entryPath array will be the spawnpoint for the transport, while the last one will be its destination. The last member of the exitPath array is be the place where the transport will be removed from the game. When the transport has reached the destination, it will unload its cargo unless a custom actionFunc has been supplied. Afterwards, the transport will follow the exitPath and leave the map, unless a custom exitFunc has been supplied. actionFunc will be called as actionFunc(Actor transport, Actor[] cargo). exitFunc will be called as exitFunc(Actor transport). |
Trigger | |
---|---|
void AfterDelay(int delay, LuaFunction func) | Call a function after a specified delay. The callback function will be called as func(). |
void Clear(Actor a, string triggerName) | Removes the specified trigger from this actor. Note that the removal will only take effect at the end of a tick, so you must not add new triggers at the same time that you are calling this function. |
void ClearAll(Actor a) | Removes all triggers from this actor. Note that the removal will only take effect at the end of a tick, so you must not add new triggers at the same time that you are calling this function. |
void OnAddedToWorld(Actor a, LuaFunction func) | Call a function when this actor is added to the world. The callback function will be called as func(Actor self). |
void OnAllKilled(Actor[] actors, LuaFunction func) | Call a function when all of the actors in a group are killed. The callback function will be called as func(). |
void OnAllKilledOrCaptured(Actor[] actors, LuaFunction func) | Call a function when all of the actors in a group have been killed or captured. The callback function will be called as func(). |
void OnAllRemovedFromWorld(Actor[] actors, LuaFunction func) | Call a function when all of the actors in a group have been removed from the world. The callback function will be called as func(). |
void OnAnyKilled(Actor[] actors, LuaFunction func) | Call a function when one of the actors in a group is killed. The callback function will be called as func(Actor killed). |
void OnCapture(Actor a, LuaFunction func) | Call a function when this actor is captured. The callback function will be called as func(Actor self, Actor captor, Player oldOwner, Player newOwner). |
void OnDamaged(Actor a, LuaFunction func) | Call a function when the actor is damaged. The callback function will be called as func(Actor self, Actor attacker). |
void OnDiscovered(Actor a, LuaFunction func) | Call a function when this actor is discovered by an enemy or a player with a Neutral stance. The callback function will be called as func(Actor discovered, Player discoverer). |
int OnEnteredFootprint(CPos[] cells, LuaFunction func) | Call a function when a ground-based actor enters this cell footprint. Returns the trigger id for later removal using RemoveFootprintTrigger(int id). The callback function will be called as func(Actor a, int id). |
int OnEnteredProximityTrigger(WPos pos, WDist range, LuaFunction func) | Call a function when an actor enters this range. Returns the trigger id for later removal using RemoveProximityTrigger(int id). The callback function will be called as func(Actor a, int id). |
int OnExitedFootprint(CPos[] cells, LuaFunction func) | Call a function when a ground-based actor leaves this cell footprint. Returns the trigger id for later removal using RemoveFootprintTrigger(int id). The callback function will be called as func(Actor a, int id). |
int OnExitedProximityTrigger(WPos pos, WDist range, LuaFunction func) | Call a function when an actor leaves this range. Returns the trigger id for later removal using RemoveProximityTrigger(int id). The callback function will be called as func(Actor a, int id). |
void OnIdle(Actor a, LuaFunction func) | Call a function each tick that the actor is idle. The callback function will be called as func(Actor self). |
void OnInfiltrated(Actor a, LuaFunction func) | Call a function when this actor is infiltrated. The callback function will be called as func(Actor self, Actor infiltrator). |
void OnKilled(Actor a, LuaFunction func) | Call a function when the actor is killed. The callback function will be called as func(Actor self, Actor killer). |
void OnKilledOrCaptured(Actor a, LuaFunction func) | Call a function when this actor is killed or captured. The callback function will be called as func(). |
void OnObjectiveAdded(Player player, LuaFunction func) | Call a function when this player is assigned a new objective. The callback function will be called as func(Player player, int objectiveID). |
void OnObjectiveCompleted(Player player, LuaFunction func) | Call a function when this player completes an objective. The callback function will be called as func(Player player, int objectiveID). |
void OnObjectiveFailed(Player player, LuaFunction func) | Call a function when this player fails an objective. The callback function will be called as func(Player player, int objectiveID). |
void OnPassengerEntered(Actor a, LuaFunction func) | Call a function for each passenger when it enters a transport. The callback function will be called as func(Actor transport, Actor passenger). |
void OnPassengerExited(Actor a, LuaFunction func) | Call a function for each passenger when it exits a transport. The callback function will be called as func(Actor transport, Actor passenger). |
void OnPlayerDiscovered(Player discovered, LuaFunction func) | Call a function when this player is discovered by an enemy or neutral player. The callback function will be called as func(Player discovered, Player discoverer, Actor discoveredActor). |
void OnPlayerLost(Player player, LuaFunction func) | Call a function when this player fails any primary objective. The callback function will be called as func(Player player). |
void OnPlayerWon(Player player, LuaFunction func) | Call a function when this player completes all primary objectives. The callback function will be called as func(Player player). |
void OnProduction(Actor a, LuaFunction func) | Call a function when this actor produces another actor. The callback function will be called as func(Actor producer, Actor produced). |
void OnRemovedFromWorld(Actor a, LuaFunction func) | Call a function when this actor is removed from the world. The callback function will be called as func(Actor self). |
void RemoveFootprintTrigger(int id) | Removes a previously created footprint trigger. |
void RemoveProximityTrigger(int id) | Removes a previously created proximity trigger. |
UserInterface | |
---|---|
void SetMissionText(string text, Nullable`1 color = nil) | Displays a text message at the top center of the screen. |
Utils | |
---|---|
bool All(LuaValue[] collection, LuaFunction func) | Returns true if func returns true for all elements in a collection. |
bool Any(LuaValue[] collection, LuaFunction func) | Returns true if func returns true for any element in a collection. |
void Do(LuaValue[] collection, LuaFunction func) | Calls a function on every element in a collection. |
CPos[] ExpandFootprint(CPos[] footprint, bool allowDiagonal) | Expands the given footprint one step along the coordinate axes, and (if requested) diagonals. |
string FormatTime(int ticks, bool leadingMinuteZero = True) | Returns the ticks formatted to HH:MM:SS. |
LuaValue Random(LuaValue[] collection) | Returns a random value from a collection. |
int RandomInteger(int low, int high) | Returns a random integer x in the range low <= x < high. |
LuaTable Skip(LuaTable table, int numElements) | Skips over the first numElements members of a table and return the rest. |
LuaValue[] Take(int n, LuaValue[] source) | Returns the first n values from a collection. |
WDist | |
---|---|
WDist FromCells(int numCells) | Create a new WDist by cell distance. |
WDist New(int r) | Create a new WDist. |
WPos | |
---|---|
WPos New(int x, int y, int z) | Create a new WPos with the specified coordinates. |
WPos Zero { get; } | The world coordinate origin. |
WRange | |
---|---|
WDist FromCells(int numCells) | Create a new WRange by cell distance. DEPRECATED! Will be removed. |
WDist New(int r) | Create a new WRange. DEPRECATED! Will be removed. |
WVec | |
---|---|
WVec New(int x, int y, int z) | Create a new WVec with the specified coordinates. |
WVec Zero { get; } | The world zero-vector. |
Ability | |
---|---|
void Capture(Actor target) | Captures the target actor. |
void DisguiseAs(Actor target) |
Disguises as the target actor.
Requires Trait: Disguise |
void DisguiseAsType(string actorType, Player newOwner) |
Disguises as the target type with the specified owner.
Requires Trait: Disguise |
void Infiltrate(Actor target) |
Infiltrate the target actor.
Requires Trait: Infiltrates |
Combat | |
---|---|
void Attack(Actor targetActor, bool allowMove = True, bool forceAttack = False) |
Attack the target actor. The target actor needs to be visible.
Requires Traits: IMove, AttackBase |
void AttackMove(CPos cell, int closeEnough = 0)
Queued Activity |
Move to a cell, but stop and attack anything within range on the way. closeEnough defines an optional range (in cells) that will be considered close enough to complete the activity.
Requires Traits: IMove, AttackBase |
void Demolish(Actor target)
Queued Activity |
Demolish the target actor.
Requires Traits: C4Demolition, IMove |
void Guard(Actor targetActor)
Queued Activity |
Guard the target actor.
Requires Traits: IMove, Guard |
void Hunt()
Queued Activity |
Seek out and attack nearby targets.
Requires Traits: IMove, AttackBase |
void Patrol(CPos[] waypoints, bool loop = True, int wait = 0)
Queued Activity |
Patrol along a set of given waypoints. The action is repeated by default, and the actor will wait for `wait` ticks at each waypoint.
Requires Traits: IMove, AttackBase |
void PatrolUntil(CPos[] waypoints, LuaFunction func, int wait = 0)
Queued Activity |
Patrol along a set of given waypoints until a condition becomes true. The actor will wait for `wait` ticks at each waypoint.
Requires Traits: IMove, AttackBase |
General | |
---|---|
bool AcceptsUpgrade(string upgrade) |
Check whether this actor accepts a specific upgrade.
Requires Trait: UpgradeManager |
bool AddTag(string tag) | Add a tag to the actor. Returns true on success, false otherwise (for example the actor may already have the given tag). |
void CallFunc(LuaFunction func)
Queued Activity | Run an arbitrary Lua function. |
WPos CenterPosition { get; } | The actor position in world coordinates. |
void Deploy()
Queued Activity |
Queue a new transformation.
Requires Trait: Transforms |
void Destroy()
Queued Activity | Remove the actor from the game, without triggering any death notification. |
int Facing { get; } | The direction that the actor is facing. |
void GrantTimedUpgrade(string upgrade, int duration) |
Grant a limited-time upgrade to this actor.
Requires Trait: UpgradeManager |
void GrantUpgrade(string upgrade) |
Grant an upgrade to this actor.
Requires Trait: UpgradeManager |
bool HasProperty(string name) | Test whether an actor has a specific property. |
bool HasTag(string tag) | Specifies whether or not the actor has a particular tag. |
int Health { get; set; } |
Current health of the actor.
Requires Trait: Health |
bool IsDead { get; } | Specifies whether the actor is alive or dead. |
bool IsIdle { get; } | Specifies whether the actor is idle (not performing any activities). |
bool IsInWorld { get; set; } | Specifies whether the actor is in the world. |
bool IsTaggable { get; } | Specifies whether or not the actor supports 'tags'. |
void Kill() |
Kill the actor.
Requires Trait: Health |
CPos Location { get; } | The actor position in cell coordinates. |
int MaxHealth { get; } |
Maximum health of the actor.
Requires Trait: Health |
Player Owner { get; set; } | The player that owns the actor. |
bool RemoveTag(string tag) | Remove a tag from the actor. Returns true on success, false otherwise (tag was not present). |
void RevokeUpgrade(string upgrade) |
Revoke an upgrade that was previously granted using GrantUpgrade.
Requires Trait: UpgradeManager |
string Stance { get; set; } | Current actor stance. Returns nil if this actor doesn't support stances. |
void StartBuildingRepairs(Player repairer = nil) |
Start repairs on this building. `repairer` can be an allied player.
Requires Trait: RepairableBuilding |
void Stop() | Attempt to cancel any active activities. |
void StopBuildingRepairs(Player repairer = nil) |
Stop repairs on this building. `repairer` can be an allied player.
Requires Trait: RepairableBuilding |
void Teleport(CPos cell)
Queued Activity | Instantly moves the actor to the specified cell. |
string Type { get; } | The type of the actor (e.g. "e1"). |
void Wait(int ticks)
Queued Activity | Wait for a specified number of game ticks (25 ticks = 1 second). |
Movement | |
---|---|
void EnterTransport(Actor transport)
Queued Activity |
Move to and enter the transport.
Requires Trait: Mobile |
void FindResources()
Queued Activity |
Search for nearby resources and begin harvesting.
Requires Trait: Harvester |
bool IsMobile { get; } |
Whether the actor can move (false if immobilized).
Requires Trait: Mobile |
void Move(CPos cell)
Queued Activity |
Fly within the cell grid.
Requires Trait: Aircraft |
void Move(CPos cell, int closeEnough = 0)
Queued Activity |
Moves within the cell grid. closeEnough defines an optional range (in cells) that will be considered close enough to complete the activity.
Requires Trait: Mobile |
void MoveIntoWorld(CPos cell)
Queued Activity |
Moves from outside the world into the cell grid.
Requires Trait: Mobile |
void ReturnToBase(Actor airfield = nil)
Queued Activity |
Return to the base, which is either the airfield given, or an auto-selected one otherwise.
Requires Trait: Aircraft |
void Scatter()
Queued Activity |
Leave the current position in a random direction.
Requires Trait: Mobile |
void ScriptedMove(CPos cell)
Queued Activity |
Moves within the cell grid, ignoring lane biases.
Requires Trait: Mobile |
Power | |
---|---|
int Power { get; } |
Returns the power drained/provided by this actor.
Requires Trait: Power |
Production | |
---|---|
bool Build(String[] actorTypes, LuaFunction actionFunc = nil) |
Build the specified set of actors using a TD-style (per building) production queue. The function will return true if production could be started, false otherwise. If an actionFunc is given, it will be called as actionFunc(Actor[] actors) once production of all actors has been completed. The actors array is guaranteed to only contain alive actors.
Requires Traits: ScriptTriggers, ProductionQueue |
bool IsPrimaryBuilding { get; set; } |
Query or set the factory's primary building status.
Requires Trait: PrimaryBuilding |
bool IsProducing(string actorType) |
Check whether the factory's production queue that builds this type of actor is currently busy. Note: it does not check whether this particular type of actor is being produced.
Requires Traits: ScriptTriggers, ProductionQueue |
void Produce(string actorType, string factionVariant = nil)
Queued Activity |
Build a unit, ignoring the production queue. The activity will wait if the exit is blocked.
Requires Trait: Production |
CPos RallyPoint { get; set; } |
Query or set a factory's rally point.
Requires Trait: RallyPoint |
Support Powers | |
---|---|
void Chronoshift(LuaTable unitLocationPairs, int duration = 0, bool killCargo = False) |
Chronoshift a group of actors. A duration of 0 will teleport the actors permanently.
Requires Trait: ChronoshiftPower |
void SendAirstrike(WPos target, bool randomize = True, int facing = 0) |
Activate the actor's Airstrike Power.
Requires Trait: AirstrikePower |
Actor[] SendParatroopers(WPos target, bool randomize = True, int facing = 0) |
Activate the actor's Paratroopers Power. Returns the dropped units.
Requires Trait: ParatroopersPower |
Transports | |
---|---|
bool HasPassengers { get; } |
Specifies whether transport has any passengers.
Requires Trait: Cargo |
void LoadPassenger(Actor a) |
Teleport an existing actor inside this transport.
Requires Trait: Cargo |
void Paradrop(CPos cell)
Queued Activity |
Command transport to paradrop passengers near the target cell.
Requires Traits: ParaDrop, Cargo |
Actor UnloadPassenger() |
Remove the first actor from the transport. This actor is not added to the world.
Requires Trait: Cargo |
void UnloadPassengers()
Queued Activity |
Command transport to unload passengers.
Requires Trait: Cargo |
Diplomacy | |
---|---|
bool IsAlliedWith(Player targetPlayer) | Returns true if the player is allied with the other player. |
MissionObjectives | |
---|---|
int AddPrimaryObjective(string description)
Queued Activity | Add a primary mission objective for this player. The function returns the ID of the newly created objective, so that it can be referred to later. |
int AddSecondaryObjective(string description)
Queued Activity | Add a secondary mission objective for this player. The function returns the ID of the newly created objective, so that it can be referred to later. |
string GetObjectiveDescription(int id)
Queued Activity | Returns the description of an objective. |
string GetObjectiveType(int id)
Queued Activity | Returns the type of an objective. |
bool HasNoRequiredUnits()
Queued Activity | Returns true if this player has lost all units/actors that have the MustBeDestroyed trait (according to the short game option). |
bool IsObjectiveCompleted(int id)
Queued Activity | Returns true if the objective has been successfully completed, false otherwise. |
bool IsObjectiveFailed(int id)
Queued Activity | Returns true if the objective has been failed, false otherwise. |
void MarkCompletedObjective(int id)
Queued Activity | Mark an objective as completed. This needs the objective ID returned by AddObjective as argument. When this player has completed all primary objectives, (s)he has won the game. |
void MarkFailedObjective(int id)
Queued Activity | Mark an objective as failed. This needs the objective ID returned by AddObjective as argument. Secondary objectives do not have any influence whatsoever on the outcome of the game. |
Player | |
---|---|
HSLColor Color { get; } | The player's color. |
string Faction { get; } | The player's faction. |
Actor[] GetActorsByType(string type) | Returns all living actors of the specified type of this player. |
Actor[] GetGroundAttackers() | Returns an array of actors representing all ground attack units of this player. |
bool HasPrerequisites(String[] type) | Check if the player has these prerequisites available. |
string InternalName { get; } | The player's internal name. |
bool IsBot { get; } | Returns true if the player is a bot. |
bool IsLocalPlayer { get; } | Returns true if the player is the local player. |
bool IsNonCombatant { get; } | Returns true if the player is non combatant. |
string Name { get; } | The player's name. |
string Race { get; } | The player's race. (DEPRECATED! Use the `Faction` property.) |
int Spawn { get; } | The player's spawnpoint ID. |
int Team { get; } | The player's team ID. |
Power | |
---|---|
int PowerDrained { get; } |
Returns the power used by the player.
Requires Trait: PowerManager |
int PowerProvided { get; } |
Returns the total of the power the player has.
Requires Trait: PowerManager |
string PowerState { get; } |
Returns the player's power state ("Normal", "Low" or "Critical").
Requires Trait: PowerManager |
void TriggerPowerOutage(int ticks) |
Triggers low power for the chosen amount of ticks.
Requires Trait: PowerManager |
Production | |
---|---|
bool Build(String[] actorTypes, LuaFunction actionFunc = nil) |
Build the specified set of actors using classic (RA-style) production queues. The function will return true if production could be started, false otherwise. If an actionFunc is given, it will be called as actionFunc(Actor[] actors) once production of all actors has been completed. The actors array is guaranteed to only contain alive actors. Note: This function will fail to work when called during the first tick.
Requires Traits: ScriptTriggers, ClassicProductionQueue |
bool IsProducing(string actorType) |
Check whether the production queue that builds this type of actor is currently busy. Note: it does not check whether this particular type of actor is being produced.
Requires Traits: ScriptTriggers, ClassicProductionQueue |
Resources | |
---|---|
int Cash { get; set; } |
The amount of cash held by the player.
Requires Trait: PlayerResources |
int ResourceCapacity { get; } |
The maximum resource storage of the player.
Requires Trait: PlayerResources |
int Resources { get; set; } |
The amount of harvestable resources held by the player.
Requires Trait: PlayerResources |