Singletons represent the types of object those have only single instance. Here are the usual Lua tables.
function env.info(string message, bool showMessageBox = false) function env.warning(string message, bool showMessageBox = false) function env.error(string message, bool showMessageBox = false)
add message to simulator log with caption "INFO", "WARNING" or "ERROR". Message box is optional.
message
showMessageBox
function env.setErrorMessageBoxEnabled(boolean on)
enables/disables appearance of message box each time lua error occurs.
on
Time function timer.getTime()
returns model time in seconds.
Time function timer.getAbsTime()
returns mission time in seconds.
Time function timer.getTime0()
returns mission start time
Time function FunctionToCall(any argument, Time time) ... return ... end
must return model time of next call or nil.
FunctionId = number
is a numeric identifier of scheduled FunctionToCall.
FunctionId function timer.scheduleFunction(FunctionToCall functionToCall, any functionArgument, Time time)
schedules function to call at desired model time.
functionToCall
functionArgument
time
function timer.setFunctionTime(FunctionId functionId, Time time)
re-schedules function to call at another model time.
functionToCall
time
function timer.removeFunction(FunctionId functionId)
removes the function from schedule.
functionId
land.SurfaceType = { LAND, SHALLOW_WATER, WATER, ROAD, RUNWAY }
enum contains identifiers of surface types.
boolean function land.isVisible(Vec3 from, Vec3 to)
returns true if there is LOS between point from and point to. Function verifies only obstruction due the terrain and don't takes in account objects (units, static and terrain objects).
Distance function land.getHeight(Vec2 point)
returns altitude MSL of the point.
point
Vec3 function land.getIP(Vec3 from, Vec3 direction, Distance maxDistance)
returns point where the ray intersects the terrain. If no intersection found the function will return nil.
from
direction
maxDistance
array of Vec3 function land.profile(Vec3 from, Vec3 to)
returns table of vectors those are form profile of the terrain between point from and point to.
Only x and z components of both vectors matters. The first Vec3 in the result table is equal to vector from, the last vector in the result table is equal to vector to.
enum land.SurfaceType function land.getSurfaceType(Vec2 point)
returns surface type at the given point.
point
Vec3 atmosphere.getWind(Vec3 point)
returns wind velocity at the given point. No turbulence.
point
Vec3 atmosphere.getWindWithTurbulence(Vec3 point)
returns wind velocity at the given point. With turbulence.
point
world.event = { S_EVENT_SHOT, S_EVENT_HIT, S_EVENT_TAKEOFF, S_EVENT_LAND, S_EVENT_CRASH, S_EVENT_EJECTION, S_EVENT_REFUELING, S_EVENT_DEAD, S_EVENT_PILOT_DEAD, S_EVENT_BASE_CAPTURED, S_EVENT_MISSION_START, -- currently can not be caught in script due to happens before script load S_EVENT_MISSION_END, S_EVENT_TOOK_CONTROL, S_EVENT_REFUELING_STOP, S_EVENT_BIRTH, S_EVENT_HUMAN_FAILURE, S_EVENT_ENGINE_STARTUP, S_EVENT_ENGINE_SHUTDOWN, S_EVENT_PLAYER_ENTER_UNIT, S_EVENT_PLAYER_LEAVE_UNIT, S_EVENT_PLAYER_COMMENT, S_EVENT_SHOOTING_START, S_EVENT_SHOOTING_END, S_EVENT_MARK_ADDED, S_EVENT_MARK_CHANGE, S_EVENT_MARK_REMOVED, S_EVENT_KILL, S_EVENT_SCORE, S_EVENT_UNIT_LOST, S_EVENT_LANDING_AFTER_EJECTION, S_EVENT_PARATROOPER_LENDING, S_EVENT_DISCARD_CHAIR_AFTER_EJECTION, S_EVENT_WEAPON_ADD, S_EVENT_TRIGGER_ZONE, S_EVENT_LANDING_QUALITY_MARK, S_EVENT_BDA, S_EVENT_AI_ABORT_MISSION, S_EVENT_DAYNIGHT, S_EVENT_FLIGHT_TIME, S_EVENT_PLAYER_SELF_KILL_PILOT, S_EVENT_PLAYER_CAPTURE_AIRFIELD, S_EVENT_EMERGENCY_LANDING, -- useful event to handle when a bot ditches, and "group dead" condition can't be met }
enum contains identifiers of simulator events.
world.BirthPlace = { wsBirthPlace_Air, wsBirthPlace_RunWay, wsBirthPlace_Park, wsBirthPlace_Heliport_Hot, wsBirthPlace_Heliport_Cold, }
enum contains identifiers of birth place.
Event = { id = enum world.event, time = Time, initiator = Unit, target = Unit, place = Unit, subPlace = enum world.BirthPlace, weapon = Weapon }
table represents a simulator event. Not all the parameters are valid for any event.
function EventHandler(Event event) ... end
is a handler of simulator event.
function world.addEventHandler(EventHandler handler)
adds event handler.
handler
function world.removeEventHandler(EventHandler handler)
removes event handler.
Note: event handling will be moved from ./Scripts/World/EventHandlers.lua to the code. Function world.addEventHandler will support argument passing.
handler
Unit function Unit world.getPlayer()
returns Unit player's aircraft.
function array of Airbase world.getAirbases()
returns list of airbases
world.VolumeType = { SEGMENT, BOX, SPHERE, PYRAMID }
enum contains types of volume to search.
Volume = { id = enum world.VolumeType, params = { ... } }
Table that contains information about the given volume.
id
params
VolumeSegment = { id = world.VolumeType.SEGMENT, params = { from = Vec3, to = Vec3 } }
Represents 3D-segment.
from
to
VolumeBox = { id = world.VolumeType.BOX, params = { min = Vec3, max = Vec3 } }
Represents 3D-box.
min
max
VolumeSphere = { id = world.VolumeType.SPHERE, params = { point = Vec3, radius = Distance } }
Represents sphere.
point
radius
VolumePyramid = { id = world.VolumeType.PYRAMID, params = { pos = Position3, length = Distance, halfAngleHor = Angle, halfAngleVer = Angle } }
Represents camera FOV or oriented pyramid.
pos
length
halfAngleHor
halfAngleVer
ObjectSearchHandler = function(Object object, any data) ... return boolean end
Function to be called for each found object. Returns true to continue search and false to stop it.
function array of Airbase world.searchObjects([array of enum Object.Category] or [Object.Category] objectCategory, Volume volume, ObjectSearchHandler handler, any data)
searches objects of the given categories in the given volume and calls handler function for each found object with data as 2nd argument.
objectCategory
volume
handler
data
coalition.side = { NEUTRAL, RED, BLUE }
enum contains side identifiers.
coalition.service = { ATC, AWACS, TANKER, FAC }
enum stores identifiers of coalition services.
enum coalition.side function coalition.getCountryCoalition(enum country.id country)
returns coalition of the given country.
country
Vec3 function coalition.getMainRefPoint(enum coalition.side coalition)
returns main reference point (bullseye).
coalition
RefPoint = { callsign = number, type = number, point = Vec3 }
table is a reference point (used by JTAC AI for example).
array of RefPoint function coalition.getRefPoints(enum coalition.side coalition)
returns coalition reference points.
coalition
function coalition.addRefPoint(enum coalition.side coalition, RefPoint refPoint)
adds reference point to the coalition's list.
coalition
refPoint
array of Unit function coalition.getServiceProviders(enum coalition.side coalition, enum country.service serviceId)
returns list of units which are the coalition service providers
coalition
array of Unit function coalition.getPlayers(enum coalition.side coalition)
coalition
returns list of units controlled by players (local and remote)
serviceId
array of Airbase function coalition.getAirbases(enum coalition.side coalition)
returns list of airbases owned by the coalition
coalition
array of Unit function coalition.getGroups(enum coalition.side coalition, enum Group.Category groupCategory or nil)
returns list of groups belong to the coalition. It returns all groups or groups of specified type.
coalition
groupCategory
array of StaticObject function coalition.getStaticObjects(enum coalition.side coalition)
returns list of static objects belong to the coalition.
coalition
Group function coalition.addGroup(enum country.id country, enum Group.Category groupCategory, table groupData)
country
groupCategory
groupData
Note:
Group function coalition.addStaticObject(enum country.id country, table staticObjectData)
country
staticObjectData
Note:
country.id = { RUSSIA, UKRAINE, USA, TURKEY, UK, FRANCE, GERMANY, CANADA, SPAIN, THE_NETHERLANDS, BELGIUM, NORWAY, DENMARK, ISRAEL, GEORGIA, INSURGENTS, ABKHAZIA, SOUTH_OSETIA, ITALY }
enum contains country identifiers.
trigger.smokeColor = { Green, Red, White, Orange, Blue }
enum contains identifiers of smoke color.
trigger.flareColor = { Green, Red, White, Yellow }
enum contains identifiers of signal flare color.
number function trigger.misc.getUserFlag(string userFlagName)
returns value of the user flag.
userFlagName
TriggerZone = { point = Vec3, radius = Distance }
is a trigger zone.
TriggerZone function trigger.misc.getZone(string triggerZoneName)
returns trigger zone.
triggerZoneName
function trigger.action.setUserFlag(string userFlagName, boolean or number userFlagValue)
sets new value of the user flag
userFlagName
userFlagValue
function trigger.action.outSound(string soundFile)
plays sound file to all players.
soundFile
function trigger.action.outSoundForCoalition(enum coalition.side coalition, string soundFile)
plays sound file to all players on a specific coalition.
coalition
soundFile
function trigger.action.outSoundForCountry(enum country.id country, string soundFile)
plays sound file to all players on a specific country.
country
soundFile
function trigger.action.outSoundForGroup(GroupId groupId, string soundFile)
plays sound file to players in a specific group.
groupId
soundFile
function trigger.action.outText(string text, Time delay)
output text to screen to all players.
text
delay
function trigger.action.outTextForCoalition(enum coalition.side coalition, string text, Time delay)
output text to screen to all players on a specific coalition.
coalition
text
delay
function trigger.action.outTextForCountry(enum country.id country, string text, Time delay)
output text to screen to all players on a specific country.
country
text
delay
function trigger.action.outTextForGroup(GroupId groupId, string text, Time delay)
output text to screen to all players in a specific unit group.
groupId
text
delay
function trigger.action.explosion(Vec3 point, number power)
creates an explosion.
point
power
function trigger.action.smoke(Vec3 point, enum trigger.smokeColor color)
creates a smoke marker.
point
color
function trigger.action.illuminationBomb(Vec3 point)
creates illumination bomb at the point.
point
trigger.action.signalFlare(Vec3 point, enum trigger.flareColor color, Azimuth azimuth)
launches signal flare from the point.
point
color
azimuth
function trigger.action.addOtherCommand(string name, string userFlagName, number userFlagValue = 1)
adds command to "F10. Other" menu of the Radio Command Panel. The command will set the flag userFlagName to userFlagValue.
Calls missionCommands.addCommand().
name
userFlagName
userFlagValue
function trigger.action.removeOtherCommand(string name)
removes menu item.
Calls missionCommands.removeItem().
function trigger.action.addOtherCommandForCoalition(enum coalition.id coalition, string name, string userFlagName, number userFlagValue = 1)
adds command to "F10. Other" menu of the Radio Command Panel for the coalition. The command will set the flag userFlagName to userFlagValue.
Calls missionCommands.addCommandForCoalition().
coalition
name
userFlagName
userFlagValue
function trigger.action.removeOtherCommandForCoalition(enum coalition.id coalition, string name)
removes the item for the coalition.
Calls missionCommands.removeItemForCoalition().
coalition
name
function trigger.action.addOtherCommandForGroup(GroupId groupId, string name, string userFlagName, number userFlagValue = 1)
adds command to "F10. Other" menu of the Radio Command Panel for the group. The command will set the flag userFlagName to userFlagValue.
Calls missionCommands.addCommandForGroup()
groupId
name
userFlagName
userFlagValue
function trigger.action.removeOtherCommandForGroup(GroupId groupId, string name)
removes the item for the group.
Calls missionCommands.removeItemForGroup()
groupId
name
function trigger.action.radioTransmission(string fileName, Vec3 point, enum radio.modulation modulation, boolean loop, number frequency, number power)
transmits audio file to broadcast.
fileName
point
modulation
loop
frequency
power
function trigger.action.setAITask(Group group, number taskIndex)
sets triggered task for the group.
group
taskIndex
function trigger.action.pushAITask(Group group, number taskIndex)
pushes triggered task for the group.
group
taskIndex
function trigger.action.activateGroup(Group group)
activates the group. Calls group:activate().
group
function trigger.action.deactivateGroup(Group group)
deactivates the group. Calls group:destroy().
group
function trigger.action.setGroupAIOn(Group group)
sets the controller of the group on. Calls group:getController():setOnOff(true).
group
function trigger.action.setGroupAIOff(Group group)
sets the controller of the group off. Calls group:getController():setOnOff(false).
group
function trigger.action.groupStopMoving(Group group)
orders the group to stop moving. Sets StopRoute command with value = true to the group controller.
group
function trigger.action.groupContinueMoving(Group group)
orders the group to continue moving. Sets StopRoute command with value = false to the group controller.
group
Vec3 coord.LLtoLO(GeoCoord latitude, GeoCoord longitude, Distance altitude = 0)
returns point converted from latitude/longitude to Vec3.
latitude, longitude
altitude
GeoCoord, GeoCoord, Distance function coord.LOtoLL(Vec3 point)
returns point converted to latitude/longitude/altitude from Vec3. Altitude is equals to point.y.
point
MGRS function coord.LLtoMGRS(GeoCoord latitude, GeoCoord longitude)
converts latitude/longitude to MGRS.
latitude, longitude
GeoCoord, GeoCoord function coord.MGRStoLL(MGRS mgrs)
converts point from MGRS to latitude/longitude
mgrs
Provides access to the mission commands available for players in "F10. Other" menu in the communication menu.
Path
contains menu item path.
Note: Path is the inner type. Do not construct variables of this type, use values returned from addCommand... and addSubMenu instead!
Time function CommandFunction(any argument) ... end
All
Path missionCommands.addCommand(string name, Path or nil path, CommandFunction сommandFunction, any argument)
adds the command for all
name
path
commandFunction
argument
Path missionCommands.addSubMenu(string name, Path or nil path)
adds the submenu for all
name
path
Path missionCommands.removeItem(Path or nil path)
removes the item for all
path
Coalition
Path missionCommands.addCommandForCoalition(enum coalition.side coalition, string name, Path or nil path, CommandFunction сommandFunction, any argument)
adds the command for the coalition
coalition
name
path
commandFunction
argument
Path missionCommands.addSubMenuForCoalition(enum coalition.side coalition, string name, Path or nil path)
adds the submenu the coalition
coalition
name
path
Path missionCommands.removeItemForCoalition(enum coalition.side coalition, Path or nil path)
removes the item for the coalition
coalition
path
Group
Path missionCommands.addCommandForGroup(GroupId groupId, string name, Path or nil path, CommandFunction сommandFunction, any argument)
adds the command for the group. Any type of groups available: airborne, ground, naval.
groupId
name
path
commandFunction
argument
Path missionCommands.addSubMenuForGroup(GroupId groupId, string name, Path or nil path)
adds submenu to menu for the coalition
groupId
name
path
Path missionCommands.removeItemForGroup(GroupId groupId, Path or nil path)
removes the item for the coalition
groupId
coalition
path
Contains constants used in Controller functions.
AI.Skill = { AVERAGE, GOOD, HIGH, EXCELLENT, PLAYER, CLIENT }
enum contains unit skill values.
AI = { Task = { ... }, Option = { ... } }
Task subtable contains constants used in tasks, Option subtable contains behavior option constants and their values.
AI.Task.WeaponExpend = { ONE, TWO, FOUR, QUARTER, HALF, ALL }
enum contains identifiers of weapon expend modes.
AI.Task.OrbitPattern = { CIRCLE, RACE_TRACK }
enum contains identifiers of orbit patterns.
AI.Task.Designation = { NO, AUTO, WP, IR_POINTER, LASER }
enum contains identifiers of target designation modes.
AI.Task.WaypointType = { TAKEOFF, TAKEOFF_PARKING, TURNING_POINT, LAND, }
enum contains identifiers of waypoint types.
AI.Task.TurnMethod = { FLY_OVER_POINT, FIN_POINT }
enum contains identifiers of turn methods
AI.Task.AltitudeType = { BARO, RADIO }
enum contains identifiers of altitude types
AI.Task.VehicleFormation = { OFF_ROAD, ON_ROAD, RANK, CONE, DIAMOND, VEE, ECHELON_LEFT, ECHELON_RIGHT }
enum contains identifiers of vehicle formations
AI.Option = { Air = { id = enum ???, val = map ???, enum ??? }, Ground = { id = enum ???, val = map ???, enum ??? }, Naval = { id = enum ???, val = map ???, enum ??? } }
table contains identifiers of behavior options (id) and their values (val) as enums for airborne, ground and naval units / groups.
id
val