trigger#
trigger provides programmatic equivalents of many Mission Editor trigger actions,
letting scripts set flags, display messages, draw on the F10 map, and more, without
needing a corresponding trigger defined in the Mission Editor.
Functions#
- trigger.action.outText(text, displayTime, clearView)#
Displays
texton screen for all players fordisplayTimeseconds.clearViewoptionally clears any previously displayed message first.- Parameters:
text (
string) – Message text to display.displayTime (
number) – How long to display the message, in seconds.clearView (
boolean) – Optional; clear any previously displayed message first.
- trigger.action.outTextForCoalition(coalitionId, text, displayTime, clearView)#
As
outText(), but only visible to players on the given coalition.- Parameters:
coalitionId (
number) – Coalition to display the message to.text (
string) – Message text to display.displayTime (
number) – How long to display the message, in seconds.clearView (
boolean) – Optional; clear any previously displayed message first.
- trigger.action.setUserFlag(flagName, value)#
Sets a mission flag, identified by name or number, to
value. Flags are used to coordinate state between triggers and scripts.- Parameters:
flagName – Flag name or number.
value – New flag value.
- trigger.action.getUserFlag(flagName)#
Returns the current value of a mission flag.
- Parameters:
flagName – Flag name or number.
- Returns:
Current flag value.
- trigger.action.markToAll(id, text, point, readOnly, message)#
Adds a mark panel visible to all players at the given point on the F10 map.
- Parameters:
id (
number) – Unique mark panel ID.text (
string) – Mark panel title text.point (
table) – A{x, y, z}point.readOnly (
boolean) – Optional; prevents players from editing the mark.message (
string) – Optional message body text.
- trigger.action.explosion(point, power)#
Creates an explosion effect of the given power at the specified point.
- Parameters:
point (
table) – A{x, y, z}point.power (
number) – Explosion power.
- trigger.action.smoke(point, smokeType)#
Creates a smoke effect of the given type at the specified point.
- Parameters:
point (
table) – A{x, y, z}point.smokeType (
number) – Smoke preset/type enumerator (see trigger.smokeColor).
- trigger.action.effectSmokeBig(point, presetId, density, name)#
Creates a large smoke and/or fire effect at
point.- Parameters:
point (
table) – A{x, y, z}point.presetId (
number) – Effect preset.1-4are small/medium/large/huge smoke and fire;5-8are small/medium/large/huge smoke only.density (
number) – Smoke density, from0to1.name (
string) – Unique name for the effect, used to stop it later witheffectSmokeStop().
Example:
local p = trigger.misc.getZone('whatever').point p.y = land.getHeight({x = p.x, y = p.z}) trigger.action.effectSmokeBig(p, 3, 0.75, 'fire1')
- trigger.action.effectSmokeStop(name)#
Stops a big smoke effect previously started with
effectSmokeBig().- Parameters:
name (
string) – Name passed toeffectSmokeBig().
- trigger.action.ctfColorTag(unitName, smokeColor, altitude)#
Creates a colored smoke plume behind the named aircraft, automatically toggling on/off based on altitude. Passing
0forsmokeColordisables the plume; calling again with a different color on the same unit changes its color.- Parameters:
unitName (
string) – Name of the unit to attach the smoke plume to.smokeColor (
number) –0disable,1Green,2Red,3White,4Orange,5Blue. (Offset by+1from trigger.smokeColor.)altitude (
number) – Optional altitude, in meters, above which the smoke is active.
- trigger.action.illuminationBomb(point, power)#
Creates an illumination flare at
pointthat burns for 300 seconds (5 minutes) while falling toward the ground.- Parameters:
point (
table) – A{x, y, z}point;yis the initial altitude.power (
number) – Illumination power, from1to1000000.
- trigger.action.signalFlare(point, flareColor, azimuth)#
Creates a signal flare at
point, launched in the direction ofazimuth.- Parameters:
point (
table) – A{x, y, z}point.flareColor (
number) – Flare color (see trigger.flareColor).azimuth (
number) – Direction, in radians, the flare is launched toward.
- trigger.action.radioTransmission(filename, point, modulation, loop, frequency, power, name)#
Broadcasts an audio file over a radio frequency, emanating from
point.- Parameters:
filename (
string) – Path to the sound file (relative to the mission’sl10nfolder), e.g.'l10n/DEFAULT/file.wav'.point (
table) – A{x, y, z}point the transmission emanates from.modulation (
number) –0for AM,1for FM.loop (
boolean) – Whether the transmission repeats continuously.frequency (
number) – Frequency, in Hz (9 digits, e.g.124000000for 124 MHz).power (
number) – Transmitter power, in Watts.name (
string) – Unique name for the transmission, used to stop it withstopRadioTransmission().
- trigger.action.stopRadioTransmission(name)#
Stops a radio transmission previously started with
radioTransmission().- Parameters:
name (
string) – Name passed toradioTransmission().
- trigger.action.setUnitInternalCargo(unitName, mass)#
Sets the internal cargo mass carried by the named unit, overriding any previous value. Only affects airplanes and helicopters.
- Parameters:
unitName (
string) – Name of the unit.mass (
number) – Cargo mass, in kilograms.
- trigger.action.outSound(soundfile)#
Plays a sound file to all players. The file must be included in the
.miz.- Parameters:
soundfile (
string) – Path to the sound file within the mission.
- trigger.action.outSoundForCoalition(coalitionId, soundfile)#
As
outSound(), but only audible to players on the given coalition.- Parameters:
coalitionId (
number) – Coalition to play the sound for.soundfile (
string) – Path to the sound file within the mission.
- trigger.action.outSoundForCountry(countryId, soundfile)#
As
outSound(), but only audible to players belonging to the given country.- Parameters:
countryId (
number) – Country to play the sound for.soundfile (
string) – Path to the sound file within the mission.
- trigger.action.outSoundForGroup(groupId, soundfile)#
As
outSound(), but only audible to players in the given group.- Parameters:
groupId (
number) – Group to play the sound for.soundfile (
string) – Path to the sound file within the mission.
- trigger.action.outSoundForUnit(unitId, soundfile)#
As
outSound(), but only audible to players controlling the given unit.- Parameters:
unitId (
number) – Unit to play the sound for.soundfile (
string) – Path to the sound file within the mission.
- trigger.action.outTextForCountry(countryId, text, displayTime, clearView)#
As
outText(), but only visible to players belonging to the given country.- Parameters:
countryId (
number) – Country to display the message to.text (
string) – Message text to display.displayTime (
number) – How long to display the message, in seconds.clearView (
boolean) – Optional; clear any previously displayed message first.
- trigger.action.outTextForGroup(groupId, text, displayTime, clearView)#
As
outText(), but only visible to players in the given group.- Parameters:
groupId (
number) – Group to display the message to.text (
string) – Message text to display.displayTime (
number) – How long to display the message, in seconds.clearView (
boolean) – Optional; clear any previously displayed message first.
- trigger.action.outTextForUnit(unitId, text, displayTime, clearView)#
As
outText(), but only visible to players controlling the given unit.- Parameters:
unitId (
number) – Unit to display the message to.text (
string) – Message text to display.displayTime (
number) – How long to display the message, in seconds.clearView (
boolean) – Optional; clear any previously displayed message first.
- trigger.action.markToCoalition(id, text, point, coalitionId, readOnly, message)#
As
markToAll(), but only visible to the given coalition.- Parameters:
id (
number) – Unique mark panel ID.text (
string) – Mark panel title text.point (
table) – A{x, y, z}point.coalitionId (
number) – Coalition the mark is visible to.readOnly (
boolean) – Optional; prevents players from editing the mark.message (
string) – Optional message body text.
- trigger.action.markToGroup(id, text, point, groupId, readOnly, message)#
As
markToAll(), but only visible to the given group.- Parameters:
id (
number) – Unique mark panel ID.text (
string) – Mark panel title text.point (
table) – A{x, y, z}point.groupId (
number) – Group the mark is visible to.readOnly (
boolean) – Optional; prevents players from editing the mark.message (
string) – Optional message body text.
- trigger.action.removeMark(id)#
Removes a mark panel or F10 map shape (see the Markup drawing functions below) with the given ID.
- Parameters:
id (
number) – The unique ID passed when the mark/shape was created.
Markup drawing (F10 map)#
The following functions draw persistent shapes and text on the F10 map, distinct
from the simpler mark panels created via markToAll() and friends. All
share a common id numbering space with mark panels (IDs must be unique across
both), and are removed with removeMark().
Coalition IDs used by these functions: -1 all, 0 neutral, 1 red,
2 blue. Colors are {r, g, b, a} tables with components from 0 to 1.
lineType accepts the values in the
line type enumerator below.
- trigger.action.lineToAll(coalition, id, startPoint, endPoint, color, lineType, readOnly, message)#
Draws a line between two points on the F10 map.
- Parameters:
coalition (
number) – Coalition the shape is visible to.id (
number) – Unique shape ID.startPoint (
table) – A{x, y, z}point.endPoint (
table) – A{x, y, z}point.color (
table) – Outline color,{r, g, b, a}.lineType (
number) – Line style (see lineType).readOnly (
boolean) – Optional; whether clients may edit/remove the shape.message (
string) – Optional message shown when the shape is added.
- trigger.action.circleToAll(coalition, id, center, radius, color, fillColor, lineType, readOnly, message)#
Draws a circle on the F10 map.
- Parameters:
coalition (
number) – Coalition the shape is visible to.id (
number) – Unique shape ID.center (
table) – A{x, y, z}point.radius (
number) – Circle radius, in meters.color (
table) – Outline color,{r, g, b, a}.fillColor (
table) – Fill color,{r, g, b, a}.lineType (
number) – Line style (see lineType).readOnly (
boolean) – Optional; whether clients may edit/remove the shape.message (
string) – Optional message shown when the shape is added.
- trigger.action.rectToAll(coalition, id, startPoint, endPoint, color, fillColor, lineType, readOnly, message)#
Draws a rectangle between opposite corners
startPointandendPointon the F10 map.- Parameters:
coalition (
number) – Coalition the shape is visible to.id (
number) – Unique shape ID.startPoint (
table) – A{x, y, z}point (one corner).endPoint (
table) – A{x, y, z}point (opposite corner).color (
table) – Outline color,{r, g, b, a}.fillColor (
table) – Fill color,{r, g, b, a}.lineType (
number) – Line style (see lineType).readOnly (
boolean) – Optional; whether clients may edit/remove the shape.message (
string) – Optional message shown when the shape is added.
- trigger.action.quadToAll(coalition, id, point1, point2, point3, point4, color, fillColor, lineType, readOnly, message)#
Draws an arbitrary quadrilateral defined by four points on the F10 map.
- Parameters:
coalition (
number) – Coalition the shape is visible to.id (
number) – Unique shape ID.point1 (
table) – A{x, y, z}point.point2 (
table) – A{x, y, z}point.point3 (
table) – A{x, y, z}point.point4 (
table) – A{x, y, z}point.color (
table) – Outline color,{r, g, b, a}.fillColor (
table) – Fill color,{r, g, b, a}.lineType (
number) – Line style (see lineType).readOnly (
boolean) – Optional; whether clients may edit/remove the shape.message (
string) – Optional message shown when the shape is added.
- trigger.action.arrowToAll(coalition, id, startPoint, endPoint, color, fillColor, lineType, readOnly, message)#
Draws an arrow from
startPointtoendPointon the F10 map, pointing atstartPoint.- Parameters:
coalition (
number) – Coalition the shape is visible to.id (
number) – Unique shape ID.startPoint (
table) – A{x, y, z}point (the arrowhead).endPoint (
table) – A{x, y, z}point (the tail).color (
table) – Outline color,{r, g, b, a}.fillColor (
table) – Fill color,{r, g, b, a}.lineType (
number) – Line style (see lineType).readOnly (
boolean) – Optional; whether clients may edit/remove the shape.message (
string) – Optional message shown when the shape is added.
- trigger.action.textToAll(coalition, id, point, color, fillColor, fontSize, readOnly, text)#
Draws text on the F10 map at
point, scaling with the map zoom level.- Parameters:
coalition (
number) – Coalition the text is visible to.id (
number) – Unique shape ID.point (
table) – A{x, y, z}point.color (
table) – Text color,{r, g, b, a}.fillColor (
table) – Background rectangle color,{r, g, b, a}.fontSize (
number) – Font size.readOnly (
boolean) – Optional; whether clients may edit/remove the shape.text (
string) – The text to display.
- trigger.action.markupToAll(shapeId, coalition, id, point1, ..., color, fillColor, lineType, readOnly, message)#
A generic version of the shape functions above, selecting the shape via
shapeId(1line,2circle,3rect,4arrow,5text,6quad,7freeform).7(freeform) additionally accepts 3 or more points to build an arbitrary polygon that the dedicated shape functions cannot create.- Parameters:
shapeId (
number) – Shape type; see description.coalition (
number) – Coalition the shape is visible to.id (
number) – Unique shape ID.point1 (
table) – First{x, y, z}point; further points follow positionally depending onshapeId.color (
table) – Outline color,{r, g, b, a}.fillColor (
table) – Fill color,{r, g, b, a}.lineType (
number) – Line style (see lineType).readOnly (
boolean) – Optional; whether clients may edit/remove the shape.message (
string) – Optional message shown when the shape is added.
Example:
-- A 6-point freeform shape with a light grey fill and teal outline. trigger.action.markupToAll(7, -1, 1, trigger.misc.getZone('point1').point, trigger.misc.getZone('point2').point, trigger.misc.getZone('point3').point, trigger.misc.getZone('point4').point, trigger.misc.getZone('point5').point, trigger.misc.getZone('point6').point, {0, .6, .6, 1}, {0.8, 0.8, 0.8, .3}, 4)
- trigger.action.setMarkupColor(id, color)#
Updates the outline color of an existing markup shape.
- Parameters:
id (
number) – Shape ID.color (
table) – New outline color,{r, g, b, a}.
- trigger.action.setMarkupColorFill(id, fillColor)#
Updates the fill color of an existing markup shape.
- Parameters:
id (
number) – Shape ID.fillColor (
table) – New fill color,{r, g, b, a}.
- trigger.action.setMarkupFontSize(id, fontSize)#
Updates the font size of an existing text markup. Has no effect if the shape has no text.
- Parameters:
id (
number) – Shape ID.fontSize (
number) – New font size.
- trigger.action.setMarkupPositionStart(id, point)#
Moves the first point of an existing markup shape.
- Parameters:
id (
number) – Shape ID.point (
table) – New{x, y, z}position for the shape’s first point.
- trigger.action.setMarkupPositionEnd(id, point)#
Moves the last point of an existing markup shape.
- Parameters:
id (
number) – Shape ID.point (
table) – New{x, y, z}position for the shape’s last point.
- trigger.action.setMarkupRadius(id, radius)#
Updates the radius of an existing circle markup. Has no effect on non-circle shapes.
- Parameters:
id (
number) – Shape ID.radius (
number) – New radius, in meters.
- trigger.action.setMarkupText(id, text)#
Updates the text of an existing text markup. Has no effect if the shape has no text.
- Parameters:
id (
number) – Shape ID.text (
string) – New text.
Zones#
- trigger.misc.getZone(zoneName)#
Returns the trigger zone table for the named Mission Editor trigger zone.
- Parameters:
zoneName (
string) – Name of the trigger zone.- Returns:
A
{point, radius}zone descriptor table.- Return type:
table
Note
If the zone is a quad zone (drawn with 4 arbitrary points rather than a circle), no positional information is returned.
Example:
local zone = trigger.misc.getZone('shortBusStop') trigger.action.outText('The radius of the bus stop zone is: ' .. zone.radius, 20)
Enumerators#
trigger.smokeColor identifies the smoke color used by smoke():
Value |
Meaning |
|---|---|
|
Green ( |
|
Red ( |
|
White ( |
|
Orange ( |
|
Blue ( |
trigger.flareColor identifies the flare color used by signalFlare():
Value |
Meaning |
|---|---|
|
Green ( |
|
Red ( |
|
White ( |
|
Yellow ( |
lineType (used by the markup drawing functions above) accepts one of the
following numeric values:
Value |
Meaning |
|---|---|
|
No line |
|
Solid |
|
Dashed |
|
Dotted |
|
Dot dash |
|
Long dash |
|
Two dash |
Footnotes#
triggerfunctions are grouped under thetrigger.actionsub-table; there is no top-leveltrigger.foo()– all actions are namespaced.Many of these functions correspond directly to actions available in the Mission Editor’s trigger action list, making it straightforward to move logic between the editor and scripts.