Banner Image

Module Utils

This module contains derived utilities taken from the MIST framework, as well as a lot of added helpers from the MOOSE community.

Authors:

  • Grimes : Design & Programming of the MIST framework.

Contributions:

  • FlightControl : Rework to OO framework.
  • And many more

Global(s)

Global BIGSMOKEPRESET

Global CALLSIGN

Global DCSMAP

Global FIFO

Global FLARECOLOR

Global LIFO

Global SMOKECOLOR

Global UTILS

Global lookup_table

#table lookup_table

Type(s)

Fields and Methods inherited from DCSMAP Description

DCSMAP.Caucasus

Caucasus map.

DCSMAP.MarianaIslands

Mariana Islands map.

DCSMAP.NTTR

Nevada Test and Training Range map.

DCSMAP.Normandy

Normandy map.

DCSMAP.PersianGulf

Persian Gulf map.

DCSMAP.Syria

Syria map.

DCSMAP.TheChannel

The Channel map.

FIFO , extends Core.Base#BASE
Fields and Methods inherited from FIFO Description

FIFO.ClassName

Name of the class.

FIFO:Flatten()

FIFO Housekeeping

FIFO:Flush()

FIFO Print stacks to dcs.log

FIFO:GetIDStack()

FIFO Get the data stack by UniqueID

FIFO:GetIDStackSorted()

FIFO Get table of UniqueIDs sorthed smallest to largest

FIFO:GetPointerStack()

FIFO Get the data stack by pointer

FIFO:GetSize()

FIFO Get stack size

FIFO:HasUniqueID(UniqueID)

FIFO Check if a certain UniqeID exists

FIFO:IsEmpty()

FIFO Check Stack is empty

FIFO:IsNotEmpty()

FIFO Check Stack is NOT empty

FIFO:New()

Instantiate a new FIFO Stack

FIFO:Pull()

FIFO Pull Object from Stack

FIFO:PullByID(UniqueID)

FIFO Pull Object from Stack by UniqueID

FIFO:PullByPointer(Pointer)

FIFO Pull Object from Stack by Pointer

FIFO:Push(Object, UniqueID)

FIFO Push Object to Stack

FIFO.counter

FIFO.lid

Class id string for output to DCS log file.

FIFO.pointer

FIFO.stackbyid

FIFO.stackbypointer

FIFO.uniquecounter

FIFO.version

Version of FiFo

Fields and Methods inherited from BASE Description

FIFO.ClassID

The ID number of the class.

FIFO.ClassName

The name of the class.

FIFO.ClassNameAndID

The name of the class concatenated with the ID number of the class.

FIFO:ClearState(Object, StateName)

Clear the state of an object.

FIFO:CreateEventBirth(EventTime, Initiator, IniUnitName, place, subplace)

Creation of a Birth Event.

FIFO:CreateEventCrash(EventTime, Initiator)

Creation of a Crash Event.

FIFO:CreateEventDead(EventTime, Initiator)

Creation of a Dead Event.

FIFO:CreateEventPlayerEnterAircraft(PlayerUnit)

Creation of a S_EVENT_PLAYER_ENTER_AIRCRAFT event.

FIFO:CreateEventRemoveUnit(EventTime, Initiator)

Creation of a Remove Unit Event.

FIFO:CreateEventTakeoff(EventTime, Initiator)

Creation of a Takeoff Event.

FIFO:E(Arguments)

Log an exception which will be traced always.

FIFO:EventDispatcher()

Returns the event dispatcher

FIFO:EventRemoveAll()

Remove all subscribed events

FIFO:F(Arguments)

Trace a function call.

FIFO:F2(Arguments)

Trace a function call level 2.

FIFO:F3(Arguments)

Trace a function call level 3.

FIFO:GetClassID()

Get the ClassID of the class instance.

FIFO:GetClassName()

Get the ClassName of the class instance.

FIFO:GetClassNameAndID()

Get the ClassName + ClassID of the class instance.

FIFO:GetEventPriority()

Get the Class Event processing Priority.

FIFO:GetParent(Child, FromClass)

This is the worker method to retrieve the Parent class.

FIFO:GetState(Object, Key)

Get a Value given a Key from the Object.

FIFO:HandleEvent(EventID, EventFunction)

Subscribe to a DCS Event.

FIFO:I(Arguments)

Log an information which will be traced always.

FIFO:Inherit(Child, Parent)

This is the worker method to inherit from a parent class.

FIFO:IsInstanceOf(ClassName)

This is the worker method to check if an object is an (sub)instance of a class.

FIFO:IsTrace()

Enquires if tracing is on (for the class).

FIFO:New()

BASE constructor.

FIFO:OnEvent(EventData)

Occurs when an object is completely destroyed.

FIFO:OnEventBDA(EventData)

BDA.

FIFO:OnEventBaseCaptured(EventData)

Occurs when a ground unit captures either an airbase or a farp.

FIFO:OnEventBirth(EventData)

Occurs when any object is spawned into the mission.

FIFO:OnEventCrash(EventData)

Occurs when any aircraft crashes into the ground and is completely destroyed.

FIFO:OnEventDead(EventData)

Occurs when an object is dead.

FIFO:OnEventDetailedFailure(EventData)

Unknown precisely what creates this event, likely tied into newer damage model.

FIFO:OnEventDiscardChairAfterEjection(EventData)

Discard chair after ejection.

FIFO:OnEventEjection(EventData)

Occurs when a pilot ejects from an aircraft initiator : The unit that has ejected

FIFO:OnEventEngineShutdown(EventData)

Occurs when any aircraft shuts down its engines.

FIFO:OnEventEngineStartup(EventData)

Occurs when any aircraft starts its engines.

FIFO:OnEventHit(EventData)

Occurs whenever an object is hit by a weapon.

FIFO:OnEventHumanFailure(EventData)

Occurs when any system fails on a human controlled aircraft.

FIFO:OnEventKill(EventData)

Occurs on the death of a unit.

FIFO:OnEventLand(EventData)

Occurs when an aircraft lands at an airbase, farp or ship initiator : The unit that has landed.

FIFO:OnEventLandingAfterEjection(EventData)

Occurs shortly after the landing animation of an ejected pilot touching the ground and standing up.

FIFO:OnEventLandingQualityMark(EventData)

Landing quality mark.

FIFO:OnEventMarkAdded(EventData)

Occurs when a new mark was added.

FIFO:OnEventMarkChange(EventData)

Occurs when a mark text was changed.

FIFO:OnEventMarkRemoved(EventData)

Occurs when a mark was removed.

FIFO:OnEventMissionEnd(EventData)

Occurs when a mission ends.

FIFO:OnEventMissionStart(EventData)

Occurs when a mission starts.

FIFO:OnEventParatrooperLanding(EventData)

Weapon add.

FIFO:OnEventPilotDead(EventData)

Occurs when the pilot of an aircraft is killed.

FIFO:OnEventPlayerEnterAircraft(EventData)

Occurs when a player enters a slot and takes control of an aircraft.

FIFO:OnEventPlayerEnterUnit(EventData)

Occurs when any player assumes direct control of a unit.

FIFO:OnEventPlayerLeaveUnit(EventData)

Occurs when any player relieves control of a unit to the AI.

FIFO:OnEventRefueling(EventData)

Occurs when an aircraft connects with a tanker and begins taking on fuel.

FIFO:OnEventRefuelingStop(EventData)

Occurs when an aircraft is finished taking fuel.

FIFO:OnEventScore(EventData)

Occurs when any modification to the "Score" as seen on the debrief menu would occur.

FIFO:OnEventShootingEnd(EventData)

Occurs when any unit stops firing its weapon.

FIFO:OnEventShootingStart(EventData)

Occurs when any unit begins firing a weapon that has a high rate of fire.

FIFO:OnEventShot(EventData)

Occurs whenever any unit in a mission fires a weapon.

FIFO:OnEventTakeoff(EventData)

Occurs when an aircraft takes off from an airbase, farp, or ship.

FIFO:OnEventTriggerZone(EventData)

Trigger zone.

FIFO:OnEventUnitLost(EventData)

Occurs when the game thinks an object is destroyed.

FIFO:ScheduleOnce(Start, SchedulerFunction, ...)

Schedule a new time event.

FIFO:ScheduleRepeat(Start, Repeat, RandomizeFactor, Stop, SchedulerFunction, ...)

Schedule a new time event.

FIFO:ScheduleStop(SchedulerFunction)

Stops the Schedule.

FIFO.Scheduler

FIFO:SetEventPriority(EventPriority)

Set the Class Event processing Priority.

FIFO:SetState(Object, Key, Value)

Set a state or property of the Object given a Key and a Value.

FIFO:T(Arguments)

Trace a function logic level 1.

FIFO:T2(Arguments)

Trace a function logic level 2.

FIFO:T3(Arguments)

Trace a function logic level 3.

FIFO:TraceAll(TraceAll)

Trace all methods in MOOSE

FIFO:TraceClass(Class)

Set tracing for a class

FIFO:TraceClassMethod(Class, Method)

Set tracing for a specific method of class

FIFO:TraceLevel(Level)

Set trace level

FIFO:TraceOff()

Set trace off.

FIFO:TraceOn()

Set trace on.

FIFO:TraceOnOff(TraceOnOff)

Set trace on or off Note that when trace is off, no BASE.Debug statement is performed, increasing performance! When Moose is loaded statically, (as one file), tracing is switched off by default.

FIFO:UnHandleEvent(EventID)

UnSubscribe to a DCS event.

FIFO._

FIFO:_F(Arguments, DebugInfoCurrentParam, DebugInfoFromParam)

Trace a function call.

FIFO:_T(Arguments, DebugInfoCurrentParam, DebugInfoFromParam)

Trace a function logic.

FIFO.__

FIFO:onEvent(event)

Fields and Methods inherited from FIFO.IDEntry Description

FIFO.IDEntry.data

FIFO.IDEntry.pointer

FIFO.IDEntry.uniqueID

Fields and Methods inherited from FLARECOLOR Description

FLARECOLOR.Green

FLARECOLOR.Red

FLARECOLOR.White

FLARECOLOR.Yellow

LIFO , extends Core.Base#BASE
Fields and Methods inherited from LIFO Description

LIFO.ClassName

Name of the class.

LIFO:Flatten()

LIFO Housekeeping

LIFO:Flush()

LIFO Print stacks to dcs.log

LIFO:GetIDStack()

LIFO Get the data stack by UniqueID

LIFO:GetIDStackSorted()

LIFO Get table of UniqueIDs sorthed smallest to largest

LIFO:GetPointerStack()

LIFO Get the data stack by pointer

LIFO:GetSize()

LIFO Get stack size

LIFO:HasUniqueID(UniqueID)

LIFO Check if a certain UniqeID exists

LIFO:IsEmpty()

LIFO Check Stack is empty

LIFO:IsNotEmpty()

LIFO Check Stack is NOT empty

LIFO:New()

Instantiate a new LIFO Stack

LIFO:Pull()

LIFO Pull Object from Stack

LIFO:PullByID(UniqueID)

LIFO Pull Object from Stack by UniqueID

LIFO:PullByPointer(Pointer)

LIFO Pull Object from Stack by Pointer

LIFO:Push(Object, UniqueID)

LIFO Push Object to Stack

LIFO.counter

LIFO.lid

Class id string for output to DCS log file.

LIFO.pointer

LIFO.stackbyid

LIFO.stackbypointer

LIFO.uniquecounter

LIFO.version

Version of LiFo

Fields and Methods inherited from BASE Description

LIFO.ClassID

The ID number of the class.

LIFO.ClassName

The name of the class.

LIFO.ClassNameAndID

The name of the class concatenated with the ID number of the class.

LIFO:ClearState(Object, StateName)

Clear the state of an object.

LIFO:CreateEventBirth(EventTime, Initiator, IniUnitName, place, subplace)

Creation of a Birth Event.

LIFO:CreateEventCrash(EventTime, Initiator)

Creation of a Crash Event.

LIFO:CreateEventDead(EventTime, Initiator)

Creation of a Dead Event.

LIFO:CreateEventPlayerEnterAircraft(PlayerUnit)

Creation of a S_EVENT_PLAYER_ENTER_AIRCRAFT event.

LIFO:CreateEventRemoveUnit(EventTime, Initiator)

Creation of a Remove Unit Event.

LIFO:CreateEventTakeoff(EventTime, Initiator)

Creation of a Takeoff Event.

LIFO:E(Arguments)

Log an exception which will be traced always.

LIFO:EventDispatcher()

Returns the event dispatcher

LIFO:EventRemoveAll()

Remove all subscribed events

LIFO:F(Arguments)

Trace a function call.

LIFO:F2(Arguments)

Trace a function call level 2.

LIFO:F3(Arguments)

Trace a function call level 3.

LIFO:GetClassID()

Get the ClassID of the class instance.

LIFO:GetClassName()

Get the ClassName of the class instance.

LIFO:GetClassNameAndID()

Get the ClassName + ClassID of the class instance.

LIFO:GetEventPriority()

Get the Class Event processing Priority.

LIFO:GetParent(Child, FromClass)

This is the worker method to retrieve the Parent class.

LIFO:GetState(Object, Key)

Get a Value given a Key from the Object.

LIFO:HandleEvent(EventID, EventFunction)

Subscribe to a DCS Event.

LIFO:I(Arguments)

Log an information which will be traced always.

LIFO:Inherit(Child, Parent)

This is the worker method to inherit from a parent class.

LIFO:IsInstanceOf(ClassName)

This is the worker method to check if an object is an (sub)instance of a class.

LIFO:IsTrace()

Enquires if tracing is on (for the class).

LIFO:New()

BASE constructor.

LIFO:OnEvent(EventData)

Occurs when an object is completely destroyed.

LIFO:OnEventBDA(EventData)

BDA.

LIFO:OnEventBaseCaptured(EventData)

Occurs when a ground unit captures either an airbase or a farp.

LIFO:OnEventBirth(EventData)

Occurs when any object is spawned into the mission.

LIFO:OnEventCrash(EventData)

Occurs when any aircraft crashes into the ground and is completely destroyed.

LIFO:OnEventDead(EventData)

Occurs when an object is dead.

LIFO:OnEventDetailedFailure(EventData)

Unknown precisely what creates this event, likely tied into newer damage model.

LIFO:OnEventDiscardChairAfterEjection(EventData)

Discard chair after ejection.

LIFO:OnEventEjection(EventData)

Occurs when a pilot ejects from an aircraft initiator : The unit that has ejected

LIFO:OnEventEngineShutdown(EventData)

Occurs when any aircraft shuts down its engines.

LIFO:OnEventEngineStartup(EventData)

Occurs when any aircraft starts its engines.

LIFO:OnEventHit(EventData)

Occurs whenever an object is hit by a weapon.

LIFO:OnEventHumanFailure(EventData)

Occurs when any system fails on a human controlled aircraft.

LIFO:OnEventKill(EventData)

Occurs on the death of a unit.

LIFO:OnEventLand(EventData)

Occurs when an aircraft lands at an airbase, farp or ship initiator : The unit that has landed.

LIFO:OnEventLandingAfterEjection(EventData)

Occurs shortly after the landing animation of an ejected pilot touching the ground and standing up.

LIFO:OnEventLandingQualityMark(EventData)

Landing quality mark.

LIFO:OnEventMarkAdded(EventData)

Occurs when a new mark was added.

LIFO:OnEventMarkChange(EventData)

Occurs when a mark text was changed.

LIFO:OnEventMarkRemoved(EventData)

Occurs when a mark was removed.

LIFO:OnEventMissionEnd(EventData)

Occurs when a mission ends.

LIFO:OnEventMissionStart(EventData)

Occurs when a mission starts.

LIFO:OnEventParatrooperLanding(EventData)

Weapon add.

LIFO:OnEventPilotDead(EventData)

Occurs when the pilot of an aircraft is killed.

LIFO:OnEventPlayerEnterAircraft(EventData)

Occurs when a player enters a slot and takes control of an aircraft.

LIFO:OnEventPlayerEnterUnit(EventData)

Occurs when any player assumes direct control of a unit.

LIFO:OnEventPlayerLeaveUnit(EventData)

Occurs when any player relieves control of a unit to the AI.

LIFO:OnEventRefueling(EventData)

Occurs when an aircraft connects with a tanker and begins taking on fuel.

LIFO:OnEventRefuelingStop(EventData)

Occurs when an aircraft is finished taking fuel.

LIFO:OnEventScore(EventData)

Occurs when any modification to the "Score" as seen on the debrief menu would occur.

LIFO:OnEventShootingEnd(EventData)

Occurs when any unit stops firing its weapon.

LIFO:OnEventShootingStart(EventData)

Occurs when any unit begins firing a weapon that has a high rate of fire.

LIFO:OnEventShot(EventData)

Occurs whenever any unit in a mission fires a weapon.

LIFO:OnEventTakeoff(EventData)

Occurs when an aircraft takes off from an airbase, farp, or ship.

LIFO:OnEventTriggerZone(EventData)

Trigger zone.

LIFO:OnEventUnitLost(EventData)

Occurs when the game thinks an object is destroyed.

LIFO:ScheduleOnce(Start, SchedulerFunction, ...)

Schedule a new time event.

LIFO:ScheduleRepeat(Start, Repeat, RandomizeFactor, Stop, SchedulerFunction, ...)

Schedule a new time event.

LIFO:ScheduleStop(SchedulerFunction)

Stops the Schedule.

LIFO.Scheduler

LIFO:SetEventPriority(EventPriority)

Set the Class Event processing Priority.

LIFO:SetState(Object, Key, Value)

Set a state or property of the Object given a Key and a Value.

LIFO:T(Arguments)

Trace a function logic level 1.

LIFO:T2(Arguments)

Trace a function logic level 2.

LIFO:T3(Arguments)

Trace a function logic level 3.

LIFO:TraceAll(TraceAll)

Trace all methods in MOOSE

LIFO:TraceClass(Class)

Set tracing for a class

LIFO:TraceClassMethod(Class, Method)

Set tracing for a specific method of class

LIFO:TraceLevel(Level)

Set trace level

LIFO:TraceOff()

Set trace off.

LIFO:TraceOn()

Set trace on.

LIFO:TraceOnOff(TraceOnOff)

Set trace on or off Note that when trace is off, no BASE.Debug statement is performed, increasing performance! When Moose is loaded statically, (as one file), tracing is switched off by default.

LIFO:UnHandleEvent(EventID)

UnSubscribe to a DCS event.

LIFO._

LIFO:_F(Arguments, DebugInfoCurrentParam, DebugInfoFromParam)

Trace a function call.

LIFO:_T(Arguments, DebugInfoCurrentParam, DebugInfoFromParam)

Trace a function logic.

LIFO.__

LIFO:onEvent(event)

Fields and Methods inherited from LIFO.IDEntry Description

LIFO.IDEntry.data

LIFO.IDEntry.pointer

LIFO.IDEntry.uniqueID

Fields and Methods inherited from SMOKECOLOR Description

SMOKECOLOR.Blue

SMOKECOLOR.Green

SMOKECOLOR.Orange

SMOKECOLOR.Red

SMOKECOLOR.White

Fields and Methods inherited from UTILS Description

UTILS.BasicSerialize(s)

UTILS.BearingToCardinal(Heading)

Heading Degrees (0-360) to Cardinal

UTILS.BeaufortScale(speed)

Beaufort scale: returns Beaufort number and wind description as a function of wind speed in m/s.

UTILS.CelsiusToFahrenheit(Celcius)

Convert temperature from Celsius to Fahrenheit.

UTILS.CheckFileExists(Path, Filename)

Function to check if a file exists.

UTILS.CheckMemory(output)

Checks the current memory usage collectgarbage("count").

UTILS.ClockToSeconds(clock)

Convert clock time from hours, minutes and seconds to seconds.

UTILS.DeepCopy(object)

Deep copy a table.

UTILS.DisplayMissionTime(duration)

Display clock and mission time on screen as a message to all.

UTILS.DoString(s)

UTILS.FeetToMeters(feet)

UTILS.FileExists(file)

Checks if a file exists or not.

UTILS.GMTToLocalTimeDifference()

Get the time difference between GMT and local time.

UTILS.GenerateFMFrequencies()

Function to generate valid FM frequencies in mHz for radio beacons (FM).

UTILS.GenerateLaserCodes()

Function to generate valid laser codes for JTAC.

UTILS.GenerateUHFrequencies()

Function to generate valid UHF Frequencies in mHz (AM).

UTILS.GenerateVHFrequencies()

Function to generate valid VHF frequencies in kHz for radio beacons (FM).

UTILS.GetCallsignName(Callsign)

Get the callsign name from its enumerator value

UTILS.GetCharacters(str)

Get a table of all characters in a string.

UTILS.GetCoalitionName(Coalition)

Get the coalition name from its numerical ID, e.g.

UTILS.GetDCSMap()

Returns the DCS map/theatre as optained by env.mission.theatre

UTILS.GetDCSMissionDate()

Returns the mission date.

UTILS.GetDayOfYear(Year, Month, Day)

Get the day of the year.

UTILS.GetMagneticDeclination(map)

Returns the magnetic declination of the map.

UTILS.GetMarkID()

UTILS.GetMissionDay(Time)

Returns the day of the mission.

UTILS.GetMissionDayOfYear(Time)

Returns the current day of the year of the mission.

UTILS.GetModulationName(Modulation)

Get the modulation name from its numerical value.

UTILS.GetOSTime()

Get OS time.

UTILS.GetRandomTableElement(t, replace)

Get a random element of a table.

UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, Rising, Tlocal)

Get sunrise or sun set of a specific day of the year at a specific location.

UTILS.GetSunrise(Day, Month, Year, Latitude, Longitude, Rising, Tlocal)

Get sun rise of a specific day of the year at a specific location.

UTILS.GetSunset(Day, Month, Year, Latitude, Longitude, Rising, Tlocal)

Get sun set of a specific day of the year at a specific location.

UTILS.HdgDiff(h1, h2)

Calculate the difference between two "heading", i.e.

UTILS.IsInRadius(InVec2, Vec2, Radius)

UTILS.IsInSphere(InVec3, Vec3, Radius)

UTILS.IsInstanceOf(object, className)

Function to infer instance of an object

Examples:

  • UTILS.IsInstanceOf( 'some text', 'string' ) will return true

  • UTILS.IsInstanceOf( some_function, 'function' ) will return true

  • UTILS.IsInstanceOf( 10, 'number' ) will return true

  • UTILS.IsInstanceOf( false, 'boolean' ) will return true

  • UTILS.IsInstanceOf( nil, 'nil' ) will return true

  • UTILS.IsInstanceOf( ZONE:New( 'some zone', ZONE ) will return true

  • UTILS.IsInstanceOf( ZONE:New( 'some zone', 'ZONE' ) will return true

  • UTILS.IsInstanceOf( ZONE:New( 'some zone', 'zone' ) will return true

  • UTILS.IsInstanceOf( ZONE:New( 'some zone', 'BASE' ) will return true

  • UTILS.IsInstanceOf( ZONE:New( 'some zone', 'GROUP' ) will return false

UTILS.IsLoadingDoorOpen(unit_name)

(Helicopter) Check if one loading door is open.

UTILS.KiloMetersToFeet(kilometers)

UTILS.KiloMetersToNM(kilometers)

UTILS.KiloMetersToSM(kilometers)

UTILS.KmphToKnots(knots)

UTILS.KmphToMps(kmph)

UTILS.KnotsToAltKIAS(knots, altitude)

Convert knots to alitude corrected KIAS, e.g.

UTILS.KnotsToKmph(knots)

UTILS.KnotsToMps(knots)

Convert knots to meters per second.

UTILS.LoadFromFile(Path, Filename)

Function to save an object to a file

UTILS.LoadSetOfGroups(Path, Filename, Spawn)

Load back a SET of groups from file.

UTILS.LoadSetOfStatics(Path, Filename)

Load back a SET of statics from file.

UTILS.LoadStationaryListOfGroups(Path, Filename, Reduce)

Load back a stationary list of groups from file.

UTILS.LoadStationaryListOfStatics(Path, Filename, Reduce)

Load back a stationary list of statics from file.

UTILS.MetersToFeet(meters)

UTILS.MetersToNM(meters)

UTILS.MetersToSM(meters)

UTILS.MiphToMps(miph)

UTILS.MpsToKmph(mps)

UTILS.MpsToKnots(mps)

Convert meters per second to knots.

UTILS.MpsToMiph(mps)

Convert meters per second to miles per hour.

UTILS.NMToKiloMeters(NM)

UTILS.NMToMeters(NM)

UTILS.OneLineSerialize(tbl)

Porting in Slmod's serialize_slmod2.

UTILS.RandomGaussian(x0, sigma, xmin, xmax, imax)

Generate a Gaussian pseudo-random number.

UTILS.Randomize(value, fac, lower, upper)

Randomize a value by a certain amount.

UTILS.RemoveMark(MarkID, Delay)

Remove an object (marker, circle, arrow, text, quad, ...) on the F10 map.

UTILS.ReplaceIllegalCharacters(Text, ReplaceBy)

Replace illegal characters [<>|/?*:\] in a string.

UTILS.Rotate2D(a, angle)

Rotate 3D vector in the 2D (x,z) plane.

UTILS.Round(num, idp)

From http://lua-users.org/wiki/SimpleRound use negative idp for rounding ahead of decimal place, positive for rounding after decimal place

UTILS.SaveSetOfGroups(Set, Path, Filename)

Function to save the state of a set of Wrapper.Group#GROUP objects.

UTILS.SaveSetOfStatics(Set, Path, Filename)

Function to save the state of a set of Wrapper.Static#STATIC objects.

UTILS.SaveStationaryListOfGroups(List, Path, Filename)

Function to save the state of a list of groups found by name

UTILS.SaveStationaryListOfStatics(List, Path, Filename)

Function to save the state of a list of statics found by name

UTILS.SaveToFile(Path, Filename, Data)

Function to save an object to a file

UTILS.SecondsOfToday()

Seconds of today.

UTILS.SecondsToClock(seconds, short)

Convert time in seconds to hours, minutes and seconds.

UTILS.SecondsToMidnight()

Cound seconds until next midnight.

UTILS.ShuffleTable(t)

Shuffle a table accoring to Fisher Yeates algorithm

UTILS.Split(str, sep)

Split string at seperators.

UTILS.TACANToFrequency(TACANChannel, TACANMode)

Converts a TACAN Channel/Mode couple into a frequency in Hz.

UTILS.ToDegree(angle)

UTILS.ToRadian(angle)

UTILS.ToStringBRAANATO(FromGrp, ToGrp)

Create a BRAA NATO call string BRAA between two GROUP objects

UTILS.Vec2Add(a, b)

Calculate the total vector of two 2D vectors by adding the x,y components of each other.

UTILS.Vec2Dot(a, b)

Calculate the dot product of two 2D vectors.

UTILS.Vec2Hdg(a)

Calculate "heading" of a 2D vector in the X-Y plane.

UTILS.Vec2Norm(a)

Calculate the euclidean norm (length) of a 2D vector.

UTILS.Vec2Rotate2D(a, angle)

Rotate 2D vector in the 2D (x,z) plane.

UTILS.Vec2Substract(a, b)

Calculate the difference between two 2D vectors by substracting the x,y components from each other.

UTILS.Vec2Translate(a, distance, angle)

Translate 2D vector in the 2D (x,z) plane.

UTILS.VecAdd(a, b)

Calculate the total vector of two 3D vectors by adding the x,y,z components of each other.

UTILS.VecAngle(a, b)

Calculate the angle between two 3D vectors.

UTILS.VecCross(a, b)

Calculate the cross product of two 3D vectors.

UTILS.VecDist2D(a, b)

Calculate the distance between two 2D vectors.

UTILS.VecDist3D(a, b)

Calculate the distance between two 3D vectors.

UTILS.VecDot(a, b)

Calculate the dot product of two vectors.

UTILS.VecHdg(a)

Calculate "heading" of a 3D vector in the X-Z plane.

UTILS.VecNorm(a)

Calculate the euclidean norm (length) of a 3D vector.

UTILS.VecSubstract(a, b)

Calculate the difference between two 3D vectors by substracting the x,y,z components from each other.

UTILS.VecTranslate(a, distance, angle)

Translate 3D vector in the 2D (x,z) plane.

UTILS._MarkID

Marker index counter. Running number when marker is added.

UTILS.hPa2inHg(hPa)

Convert pressure from hecto Pascal (hPa) to inches of mercury (inHg).

UTILS.hPa2mmHg(hPa)

Convert pressure from hecto Pascal (hPa) to millimeters of mercury (mmHg).

UTILS.kg2lbs(kg)

Convert kilo gramms (kg) to pounds (lbs).

UTILS.kpairs(t, getkey, order)

UTILS.rpairs(t)

UTILS.spairs(t, order)

UTILS.tostringLL(lat, lon, acc, DMS)

UTILS.tostringMGRS(MGRS, acc)

See DCS_enum_callsigns

Field(s)

#table CALLSIGN.AWACS

AWACS

#table CALLSIGN.Aircraft

Aircraft

#table CALLSIGN.B1B
#table CALLSIGN.B52
#table CALLSIGN.F15E
#table CALLSIGN.F16
#table CALLSIGN.F18
#table CALLSIGN.FARP

FARP

#table CALLSIGN.JTAC

JTAC

#table CALLSIGN.Tanker

Tanker

Function(s)

DCS map as returned by env.mission.theatre.

Field(s)

#string DCSMAP.Caucasus

Caucasus map.

#string DCSMAP.MarianaIslands

Mariana Islands map.

#string DCSMAP.NTTR

Nevada Test and Training Range map.

#string DCSMAP.Normandy

Normandy map.

#string DCSMAP.PersianGulf

Persian Gulf map.

#string DCSMAP.Syria

Syria map.

#string DCSMAP.TheChannel

The Channel map.

Function(s)

FIFO class.

Field(s)

#string FIFO.ClassName

Name of the class.

#number FIFO.counter
#string FIFO.lid

Class id string for output to DCS log file.

#number FIFO.pointer
#string FIFO.version

Version of FiFo

Function(s)

FIFO Housekeeping

Defined in:

FIFO

Return value:

self

FIFO Print stacks to dcs.log

Defined in:

FIFO

Return value:

self

FIFO Get the data stack by UniqueID

Defined in:

FIFO

Return value:

#table:

Table of #FIFO.IDEntry entries

FIFO Get table of UniqueIDs sorthed smallest to largest

Defined in:

FIFO

Return value:

#table:

Table of #FIFO.IDEntry entries

FIFO Get the data stack by pointer

Defined in:

FIFO

Return value:

#table:

Table of #FIFO.IDEntry entries

FIFO Get stack size

Defined in:

FIFO

Return value:

#number:

size

FIFO Check if a certain UniqeID exists

Defined in:

FIFO

Parameter:

UniqueID

Return value:

#boolean:

exists

FIFO Check Stack is empty

Defined in:

FIFO

Return value:

#boolean:

empty

FIFO Check Stack is NOT empty

Defined in:

FIFO

Return value:

#boolean:

notempty

Instantiate a new FIFO Stack

Defined in:

FIFO

Return value:

self

FIFO Pull Object from Stack

Defined in:

FIFO

Return value:

#table:

Object or nil if stack is empty

FIFO Pull Object from Stack by UniqueID

Defined in:

FIFO

Parameter:

UniqueID

Return value:

#table:

Object or nil if stack is empty

FIFO Pull Object from Stack by Pointer

Defined in:

FIFO

Parameter:

#number Pointer

Return value:

#table:

Object or nil if stack is empty

FIFO Push Object to Stack

Defined in:

FIFO

Parameters:

#table Object

#string UniqueID

(optional) - will default to current pointer + 1

Return value:

self

Field(s)

#string FIFO.ClassName

Name of the class.

#number FIFO.counter
#string FIFO.lid

Class id string for output to DCS log file.

#number FIFO.pointer
#string FIFO.version

Version of FiFo

Function(s)

Clear the state of an object.

Defined in:

Parameters:

Object

The object that holds the Value set by the Key.

StateName

The key that is should be cleared.

Creation of a Birth Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

#string IniUnitName

The initiating unit name.

place

subplace

Creation of a Crash Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Creation of a Dead Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Creation of a S_EVENT_PLAYER_ENTER_AIRCRAFT event.

Defined in:

Parameter:

Wrapper.Unit#UNIT PlayerUnit

The aircraft unit the player entered.

Creation of a Remove Unit Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Creation of a Takeoff Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Log an exception which will be traced always.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Returns the event dispatcher

Defined in:

Return value:

Remove all subscribed events

Defined in:

Return value:

Trace a function call.

Must be at the beginning of the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function call level 2.

Must be at the beginning of the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function call level 3.

Must be at the beginning of the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Get the ClassID of the class instance.

Defined in:

Return value:

#string:

The ClassID of the class instance.

Get the ClassName of the class instance.

Defined in:

Return value:

#string:

The ClassName of the class instance.

Get the ClassName + ClassID of the class instance.

The ClassName + ClassID is formatted as '%s#%09d'.

Defined in:

Return value:

#string:

The ClassName + ClassID of the class instance.

Get the Class Event processing Priority.

The Event processing Priority is a number from 1 to 10, reflecting the order of the classes subscribed to the Event to be processed.

Defined in:

Return value:

#number:

The Event processing Priority.

This is the worker method to retrieve the Parent class.

Note that the Parent class must be passed to call the parent class method.

self:GetParent(self):ParentMethod()

Defined in:

Parameters:

#BASE Child

This is the Child class from which the Parent class needs to be retrieved.

#BASE FromClass

(Optional) The class from which to get the parent.

Return value:

Get a Value given a Key from the Object.

Note that if the Object is destroyed, set to nil, or garbage collected, then the Values and Keys will also be gone.

Defined in:

Parameters:

Object

The object that holds the Value set by the Key.

Key

The key that is used to retrieve the value. Note that the key can be a #string, but it can also be any other type!

Return value:

The Value retrieved or nil if the Key was not found and thus the Value could not be retrieved.

Subscribe to a DCS Event.

Defined in:

Parameters:

Event ID.

#function EventFunction

(optional) The function to be called when the event occurs for the unit.

Return value:

Log an information which will be traced always.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

This is the worker method to inherit from a parent class.

Defined in:

Parameters:

Child

is the Child class that inherits.

#BASE Parent

is the Parent class that the Child inherits from.

Return value:

Child

This is the worker method to check if an object is an (sub)instance of a class.

Examples:

  • ZONE:New( 'some zone' ):IsInstanceOf( ZONE ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'ZONE' ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'zone' ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'BASE' ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'GROUP' ) will return false

Defined in:

Parameter:

ClassName

is the name of the class or the class itself to run the check against

Return value:

#boolean:

Enquires if tracing is on (for the class).

Defined in:

Return value:

#boolean:

BASE constructor.

This is an example how to use the BASE:New() constructor in a new class definition when inheriting from BASE.

function EVENT:New()
  local self = BASE:Inherit( self, BASE:New() ) -- #EVENT
  return self
end

Defined in:

Return value:

Occurs when an object is completely destroyed.

initiator : The unit that is was destroyed.

Defined in:

Parameter:

The EventData structure.

BDA.

Defined in:

Parameter:

The EventData structure.

Occurs when a ground unit captures either an airbase or a farp.

initiator : The unit that captured the base. place: The airbase that was captured, can be a FARP or Airbase. When calling place:getCoalition() the faction will already be the new owning faction.

Defined in:

Parameter:

The EventData structure.

Occurs when any object is spawned into the mission.

initiator : The unit that was spawned.

Defined in:

Parameter:

The EventData structure.

Occurs when any aircraft crashes into the ground and is completely destroyed.

initiator : The unit that has crashed.

Defined in:

Parameter:

The EventData structure.

Occurs when an object is dead.

initiator : The unit that is dead.

Defined in:

Parameter:

The EventData structure.

Unknown precisely what creates this event, likely tied into newer damage model.

Will update this page when new information become available.

  • initiator: The unit that had the failure.

Defined in:

Parameter:

The EventData structure.

Discard chair after ejection.

Defined in:

Parameter:

The EventData structure.

Occurs when a pilot ejects from an aircraft initiator : The unit that has ejected

Defined in:

Parameter:

The EventData structure.

Occurs when any aircraft shuts down its engines.

initiator : The unit that is stopping its engines..

Defined in:

Parameter:

The EventData structure.

Occurs when any aircraft starts its engines.

initiator : The unit that is starting its engines..

Defined in:

Parameter:

The EventData structure.

Occurs whenever an object is hit by a weapon.

initiator : The unit object the fired the weapon. weapon: Weapon object that hit the target. target: The Object that was hit.

Defined in:

Parameter:

The EventData structure.

Occurs when any system fails on a human controlled aircraft.

initiator : The unit that had the failure.

Defined in:

Parameter:

The EventData structure.

Occurs on the death of a unit.

Contains more and different information. Similar to unit_lost it will occur for aircraft before the aircraft crash event occurs.

  • initiator: The unit that killed the target.
  • target: Target Object
  • weapon: Weapon Object

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft lands at an airbase, farp or ship initiator : The unit that has landed.

place: Object that the unit landed on. Can be an Airbase Object, FARP, or Ships.

Defined in:

Parameter:

The EventData structure.

Occurs shortly after the landing animation of an ejected pilot touching the ground and standing up.

Event does not occur if the pilot lands in the water and sub combs to Davey Jones Locker.

  • initiator: Static object representing the ejected pilot. Place : Aircraft that the pilot ejected from.
  • place: may not return as a valid object if the aircraft has crashed into the ground and no longer exists.
  • subplace: is always 0 for unknown reasons.

Defined in:

Parameter:

The EventData structure.

Landing quality mark.

Defined in:

Parameter:

The EventData structure.

Occurs when a new mark was added.

MarkID: ID of the mark.

Defined in:

Parameter:

The EventData structure.

Occurs when a mark text was changed.

MarkID: ID of the mark.

Defined in:

Parameter:

The EventData structure.

Occurs when a mark was removed.

MarkID: ID of the mark.

Defined in:

Parameter:

The EventData structure.

Occurs when a mission ends.

Defined in:

Parameter:

The EventData structure.

Occurs when a mission starts.

Defined in:

Parameter:

The EventData structure.

Weapon add.

Fires when entering a mission per pylon with the name of the weapon (double pylons not counted, infinite wep reload not counted.

Defined in:

Parameter:

The EventData structure.

Occurs when the pilot of an aircraft is killed.

Can occur either if the player is alive and crashes or if a weapon kills the pilot without completely destroying the plane. initiator : The unit that the pilot has died in.

Defined in:

Parameter:

The EventData structure.

Occurs when a player enters a slot and takes control of an aircraft.

NOTE: This is a workaround of a long standing DCS bug with the PLAYER_ENTER_UNIT event. initiator : The unit that is being taken control of.

Defined in:

Parameter:

The EventData structure.

Occurs when any player assumes direct control of a unit.

initiator : The unit that is being taken control of.

Defined in:

Parameter:

The EventData structure.

Occurs when any player relieves control of a unit to the AI.

initiator : The unit that the player left.

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft connects with a tanker and begins taking on fuel.

initiator : The unit that is receiving fuel.

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft is finished taking fuel.

initiator : The unit that was receiving fuel.

Defined in:

Parameter:

The EventData structure.

Occurs when any modification to the "Score" as seen on the debrief menu would occur.

There is no information on what values the score was changed to. Event is likely similar to player_comment in this regard.

Defined in:

Parameter:

The EventData structure.

Occurs when any unit stops firing its weapon.

Event will always correspond with a shooting start event. initiator : The unit that was doing the shooting.

Defined in:

Parameter:

The EventData structure.

Occurs when any unit begins firing a weapon that has a high rate of fire.

Most common with aircraft cannons (GAU-8), auto cannons, and machine guns. initiator : The unit that is doing the shooting. target: The unit that is being targeted.

Defined in:

Parameter:

The EventData structure.

Occurs whenever any unit in a mission fires a weapon.

But not any machine gun or auto cannon based weapon, those are handled by EVENT.ShootingStart.

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft takes off from an airbase, farp, or ship.

initiator : The unit that took off. place: Object from where the AI took-off from. Can be an Airbase Object, FARP, or Ships.

Defined in:

Parameter:

The EventData structure.

Trigger zone.

Defined in:

Parameter:

The EventData structure.

Occurs when the game thinks an object is destroyed.

  • initiator: The unit that is was destroyed.

Defined in:

Parameter:

The EventData structure.

Schedule a new time event.

Note that the schedule will only take place if the scheduler is started. Even for a single schedule event, the scheduler needs to be started also.

Defined in:

Parameters:

#number Start

Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.

#function SchedulerFunction

The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

#table ...

Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.

Return value:

#number:

The ScheduleID of the planned schedule.

Schedule a new time event.

Note that the schedule will only take place if the scheduler is started. Even for a single schedule event, the scheduler needs to be started also.

Defined in:

Parameters:

#number Start

Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.

#number Repeat

Specifies the interval in seconds when the scheduler will call the event function.

#number RandomizeFactor

Specifies a randomization factor between 0 and 1 to randomize the Repeat.

#number Stop

Specifies the amount of seconds when the scheduler will be stopped.

#function SchedulerFunction

The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

#table ...

Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.

Return value:

#number:

The ScheduleID of the planned schedule.

Stops the Schedule.

Defined in:

Parameter:

#function SchedulerFunction

The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

Set the Class Event processing Priority.

The Event processing Priority is a number from 1 to 10, reflecting the order of the classes subscribed to the Event to be processed.

Defined in:

Parameter:

#number EventPriority

The Event processing Priority.

Return value:

self

Set a state or property of the Object given a Key and a Value.

Note that if the Object is destroyed, set to nil, or garbage collected, then the Values and Keys will also be gone.

Defined in:

Parameters:

Object

The object that will hold the Value set by the Key.

Key

The key that is used as a reference of the value. Note that the key can be a #string, but it can also be any other type!

Value

The value to is stored in the object.

Return value:

The Value set.

Trace a function logic level 1.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function logic level 2.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function logic level 3.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace all methods in MOOSE

Defined in:

Parameter:

#boolean TraceAll

true = trace all methods in MOOSE.

Set tracing for a class

Defined in:

Parameter:

#string Class

Set tracing for a specific method of class

Defined in:

Parameters:

#string Class

#string Method

Set trace level

Defined in:

Parameter:

#number Level

Set trace off.

Defined in:

Usage:

-- Switch the tracing Off
BASE:TraceOff()

Set trace on.

Defined in:

Usage:

-- Switch the tracing On
BASE:TraceOn()

Set trace on or off Note that when trace is off, no BASE.Debug statement is performed, increasing performance! When Moose is loaded statically, (as one file), tracing is switched off by default.

So tracing must be switched on manually in your mission if you are using Moose statically. When moose is loading dynamically (for moose class development), tracing is switched on by default.

Defined in:

Parameter:

#boolean TraceOnOff

Switch the tracing on or off.

Usage:


  -- Switch the tracing On
  BASE:TraceOnOff( true )

  -- Switch the tracing Off
  BASE:TraceOnOff( false )

UnSubscribe to a DCS event.

Defined in:

Parameter:

Event ID.

Return value:

Trace a function call.

This function is private.

Defined in:

Parameters:

Arguments

A #table or any field.

DebugInfoCurrentParam

DebugInfoFromParam

Trace a function logic.

Defined in:

Parameters:

Arguments

A #table or any field.

DebugInfoCurrentParam

DebugInfoFromParam

TODO: Complete DCS#Event structure. - The main event handling function... This function captures all events generated for the class. @param #BASE self @param DCS#Event event

Defined in:

Parameter:

event

Field(s)

Function(s)

Field(s)

Function(s)

LIFO class.

Field(s)

#string LIFO.ClassName

Name of the class.

#number LIFO.counter
#string LIFO.lid

Class id string for output to DCS log file.

#number LIFO.pointer
#string LIFO.version

Version of LiFo

Function(s)

LIFO Housekeeping

Defined in:

LIFO

Return value:

self

LIFO Print stacks to dcs.log

Defined in:

LIFO

Return value:

self

LIFO Get the data stack by UniqueID

Defined in:

LIFO

Return value:

#table:

Table of #LIFO.IDEntry entries

LIFO Get table of UniqueIDs sorthed smallest to largest

Defined in:

LIFO

Return value:

#table:

Table of #LIFO.IDEntry entries

LIFO Get the data stack by pointer

Defined in:

LIFO

Return value:

#table:

Table of #LIFO.IDEntry entries

LIFO Get stack size

Defined in:

LIFO

Return value:

#number:

size

LIFO Check if a certain UniqeID exists

Defined in:

LIFO

Parameter:

UniqueID

Return value:

#boolean:

exists

LIFO Check Stack is empty

Defined in:

LIFO

Return value:

#boolean:

empty

LIFO Check Stack is NOT empty

Defined in:

LIFO

Return value:

#boolean:

notempty

Instantiate a new LIFO Stack

Defined in:

LIFO

Return value:

self

LIFO Pull Object from Stack

Defined in:

LIFO

Return value:

#table:

Object or nil if stack is empty

LIFO Pull Object from Stack by UniqueID

Defined in:

LIFO

Parameter:

UniqueID

Return value:

#table:

Object or nil if stack is empty

LIFO Pull Object from Stack by Pointer

Defined in:

LIFO

Parameter:

#number Pointer

Return value:

#table:

Object or nil if stack is empty

LIFO Push Object to Stack

Defined in:

LIFO

Parameters:

#table Object

#string UniqueID

(optional) - will default to current pointer + 1

Return value:

self

Field(s)

#string LIFO.ClassName

Name of the class.

#number LIFO.counter
#string LIFO.lid

Class id string for output to DCS log file.

#number LIFO.pointer
#string LIFO.version

Version of LiFo

Function(s)

Clear the state of an object.

Defined in:

Parameters:

Object

The object that holds the Value set by the Key.

StateName

The key that is should be cleared.

Creation of a Birth Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

#string IniUnitName

The initiating unit name.

place

subplace

Creation of a Crash Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Creation of a Dead Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Creation of a S_EVENT_PLAYER_ENTER_AIRCRAFT event.

Defined in:

Parameter:

Wrapper.Unit#UNIT PlayerUnit

The aircraft unit the player entered.

Creation of a Remove Unit Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Creation of a Takeoff Event.

Defined in:

Parameters:

DCS#Time EventTime

The time stamp of the event.

DCS#Object Initiator

The initiating object of the event.

Log an exception which will be traced always.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Returns the event dispatcher

Defined in:

Return value:

Remove all subscribed events

Defined in:

Return value:

Trace a function call.

Must be at the beginning of the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function call level 2.

Must be at the beginning of the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function call level 3.

Must be at the beginning of the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Get the ClassID of the class instance.

Defined in:

Return value:

#string:

The ClassID of the class instance.

Get the ClassName of the class instance.

Defined in:

Return value:

#string:

The ClassName of the class instance.

Get the ClassName + ClassID of the class instance.

The ClassName + ClassID is formatted as '%s#%09d'.

Defined in:

Return value:

#string:

The ClassName + ClassID of the class instance.

Get the Class Event processing Priority.

The Event processing Priority is a number from 1 to 10, reflecting the order of the classes subscribed to the Event to be processed.

Defined in:

Return value:

#number:

The Event processing Priority.

This is the worker method to retrieve the Parent class.

Note that the Parent class must be passed to call the parent class method.

self:GetParent(self):ParentMethod()

Defined in:

Parameters:

#BASE Child

This is the Child class from which the Parent class needs to be retrieved.

#BASE FromClass

(Optional) The class from which to get the parent.

Return value:

Get a Value given a Key from the Object.

Note that if the Object is destroyed, set to nil, or garbage collected, then the Values and Keys will also be gone.

Defined in:

Parameters:

Object

The object that holds the Value set by the Key.

Key

The key that is used to retrieve the value. Note that the key can be a #string, but it can also be any other type!

Return value:

The Value retrieved or nil if the Key was not found and thus the Value could not be retrieved.

Subscribe to a DCS Event.

Defined in:

Parameters:

Event ID.

#function EventFunction

(optional) The function to be called when the event occurs for the unit.

Return value:

Log an information which will be traced always.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

This is the worker method to inherit from a parent class.

Defined in:

Parameters:

Child

is the Child class that inherits.

#BASE Parent

is the Parent class that the Child inherits from.

Return value:

Child

This is the worker method to check if an object is an (sub)instance of a class.

Examples:

  • ZONE:New( 'some zone' ):IsInstanceOf( ZONE ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'ZONE' ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'zone' ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'BASE' ) will return true

  • ZONE:New( 'some zone' ):IsInstanceOf( 'GROUP' ) will return false

Defined in:

Parameter:

ClassName

is the name of the class or the class itself to run the check against

Return value:

#boolean:

Enquires if tracing is on (for the class).

Defined in:

Return value:

#boolean:

BASE constructor.

This is an example how to use the BASE:New() constructor in a new class definition when inheriting from BASE.

function EVENT:New()
  local self = BASE:Inherit( self, BASE:New() ) -- #EVENT
  return self
end

Defined in:

Return value:

Occurs when an object is completely destroyed.

initiator : The unit that is was destroyed.

Defined in:

Parameter:

The EventData structure.

BDA.

Defined in:

Parameter:

The EventData structure.

Occurs when a ground unit captures either an airbase or a farp.

initiator : The unit that captured the base. place: The airbase that was captured, can be a FARP or Airbase. When calling place:getCoalition() the faction will already be the new owning faction.

Defined in:

Parameter:

The EventData structure.

Occurs when any object is spawned into the mission.

initiator : The unit that was spawned.

Defined in:

Parameter:

The EventData structure.

Occurs when any aircraft crashes into the ground and is completely destroyed.

initiator : The unit that has crashed.

Defined in:

Parameter:

The EventData structure.

Occurs when an object is dead.

initiator : The unit that is dead.

Defined in:

Parameter:

The EventData structure.

Unknown precisely what creates this event, likely tied into newer damage model.

Will update this page when new information become available.

  • initiator: The unit that had the failure.

Defined in:

Parameter:

The EventData structure.

Discard chair after ejection.

Defined in:

Parameter:

The EventData structure.

Occurs when a pilot ejects from an aircraft initiator : The unit that has ejected

Defined in:

Parameter:

The EventData structure.

Occurs when any aircraft shuts down its engines.

initiator : The unit that is stopping its engines..

Defined in:

Parameter:

The EventData structure.

Occurs when any aircraft starts its engines.

initiator : The unit that is starting its engines..

Defined in:

Parameter:

The EventData structure.

Occurs whenever an object is hit by a weapon.

initiator : The unit object the fired the weapon. weapon: Weapon object that hit the target. target: The Object that was hit.

Defined in:

Parameter:

The EventData structure.

Occurs when any system fails on a human controlled aircraft.

initiator : The unit that had the failure.

Defined in:

Parameter:

The EventData structure.

Occurs on the death of a unit.

Contains more and different information. Similar to unit_lost it will occur for aircraft before the aircraft crash event occurs.

  • initiator: The unit that killed the target.
  • target: Target Object
  • weapon: Weapon Object

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft lands at an airbase, farp or ship initiator : The unit that has landed.

place: Object that the unit landed on. Can be an Airbase Object, FARP, or Ships.

Defined in:

Parameter:

The EventData structure.

Occurs shortly after the landing animation of an ejected pilot touching the ground and standing up.

Event does not occur if the pilot lands in the water and sub combs to Davey Jones Locker.

  • initiator: Static object representing the ejected pilot. Place : Aircraft that the pilot ejected from.
  • place: may not return as a valid object if the aircraft has crashed into the ground and no longer exists.
  • subplace: is always 0 for unknown reasons.

Defined in:

Parameter:

The EventData structure.

Landing quality mark.

Defined in:

Parameter:

The EventData structure.

Occurs when a new mark was added.

MarkID: ID of the mark.

Defined in:

Parameter:

The EventData structure.

Occurs when a mark text was changed.

MarkID: ID of the mark.

Defined in:

Parameter:

The EventData structure.

Occurs when a mark was removed.

MarkID: ID of the mark.

Defined in:

Parameter:

The EventData structure.

Occurs when a mission ends.

Defined in:

Parameter:

The EventData structure.

Occurs when a mission starts.

Defined in:

Parameter:

The EventData structure.

Weapon add.

Fires when entering a mission per pylon with the name of the weapon (double pylons not counted, infinite wep reload not counted.

Defined in:

Parameter:

The EventData structure.

Occurs when the pilot of an aircraft is killed.

Can occur either if the player is alive and crashes or if a weapon kills the pilot without completely destroying the plane. initiator : The unit that the pilot has died in.

Defined in:

Parameter:

The EventData structure.

Occurs when a player enters a slot and takes control of an aircraft.

NOTE: This is a workaround of a long standing DCS bug with the PLAYER_ENTER_UNIT event. initiator : The unit that is being taken control of.

Defined in:

Parameter:

The EventData structure.

Occurs when any player assumes direct control of a unit.

initiator : The unit that is being taken control of.

Defined in:

Parameter:

The EventData structure.

Occurs when any player relieves control of a unit to the AI.

initiator : The unit that the player left.

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft connects with a tanker and begins taking on fuel.

initiator : The unit that is receiving fuel.

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft is finished taking fuel.

initiator : The unit that was receiving fuel.

Defined in:

Parameter:

The EventData structure.

Occurs when any modification to the "Score" as seen on the debrief menu would occur.

There is no information on what values the score was changed to. Event is likely similar to player_comment in this regard.

Defined in:

Parameter:

The EventData structure.

Occurs when any unit stops firing its weapon.

Event will always correspond with a shooting start event. initiator : The unit that was doing the shooting.

Defined in:

Parameter:

The EventData structure.

Occurs when any unit begins firing a weapon that has a high rate of fire.

Most common with aircraft cannons (GAU-8), auto cannons, and machine guns. initiator : The unit that is doing the shooting. target: The unit that is being targeted.

Defined in:

Parameter:

The EventData structure.

Occurs whenever any unit in a mission fires a weapon.

But not any machine gun or auto cannon based weapon, those are handled by EVENT.ShootingStart.

Defined in:

Parameter:

The EventData structure.

Occurs when an aircraft takes off from an airbase, farp, or ship.

initiator : The unit that took off. place: Object from where the AI took-off from. Can be an Airbase Object, FARP, or Ships.

Defined in:

Parameter:

The EventData structure.

Trigger zone.

Defined in:

Parameter:

The EventData structure.

Occurs when the game thinks an object is destroyed.

  • initiator: The unit that is was destroyed.

Defined in:

Parameter:

The EventData structure.

Schedule a new time event.

Note that the schedule will only take place if the scheduler is started. Even for a single schedule event, the scheduler needs to be started also.

Defined in:

Parameters:

#number Start

Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.

#function SchedulerFunction

The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

#table ...

Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.

Return value:

#number:

The ScheduleID of the planned schedule.

Schedule a new time event.

Note that the schedule will only take place if the scheduler is started. Even for a single schedule event, the scheduler needs to be started also.

Defined in:

Parameters:

#number Start

Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.

#number Repeat

Specifies the interval in seconds when the scheduler will call the event function.

#number RandomizeFactor

Specifies a randomization factor between 0 and 1 to randomize the Repeat.

#number Stop

Specifies the amount of seconds when the scheduler will be stopped.

#function SchedulerFunction

The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

#table ...

Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.

Return value:

#number:

The ScheduleID of the planned schedule.

Stops the Schedule.

Defined in:

Parameter:

#function SchedulerFunction

The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in SchedulerArguments.

Set the Class Event processing Priority.

The Event processing Priority is a number from 1 to 10, reflecting the order of the classes subscribed to the Event to be processed.

Defined in:

Parameter:

#number EventPriority

The Event processing Priority.

Return value:

self

Set a state or property of the Object given a Key and a Value.

Note that if the Object is destroyed, set to nil, or garbage collected, then the Values and Keys will also be gone.

Defined in:

Parameters:

Object

The object that will hold the Value set by the Key.

Key

The key that is used as a reference of the value. Note that the key can be a #string, but it can also be any other type!

Value

The value to is stored in the object.

Return value:

The Value set.

Trace a function logic level 1.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function logic level 2.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace a function logic level 3.

Can be anywhere within the function logic.

Defined in:

Parameter:

Arguments

A #table or any field.

Trace all methods in MOOSE

Defined in:

Parameter:

#boolean TraceAll

true = trace all methods in MOOSE.

Set tracing for a class

Defined in:

Parameter:

#string Class

Set tracing for a specific method of class

Defined in:

Parameters:

#string Class

#string Method

Set trace level

Defined in:

Parameter:

#number Level

Set trace off.

Defined in:

Usage:

-- Switch the tracing Off
BASE:TraceOff()

Set trace on.

Defined in:

Usage:

-- Switch the tracing On
BASE:TraceOn()

Set trace on or off Note that when trace is off, no BASE.Debug statement is performed, increasing performance! When Moose is loaded statically, (as one file), tracing is switched off by default.

So tracing must be switched on manually in your mission if you are using Moose statically. When moose is loading dynamically (for moose class development), tracing is switched on by default.

Defined in:

Parameter:

#boolean TraceOnOff

Switch the tracing on or off.

Usage:


  -- Switch the tracing On
  BASE:TraceOnOff( true )

  -- Switch the tracing Off
  BASE:TraceOnOff( false )

UnSubscribe to a DCS event.

Defined in:

Parameter:

Event ID.

Return value:

Trace a function call.

This function is private.

Defined in:

Parameters:

Arguments

A #table or any field.

DebugInfoCurrentParam

DebugInfoFromParam

Trace a function logic.

Defined in:

Parameters:

Arguments

A #table or any field.

DebugInfoCurrentParam

DebugInfoFromParam

TODO: Complete DCS#Event structure. - The main event handling function... This function captures all events generated for the class. @param #BASE self @param DCS#Event event

Defined in:

Parameter:

event

Field(s)

Function(s)

Field(s)

Function(s)

Utilities static class.

Field(s)

#number UTILS._MarkID

Marker index counter. Running number when marker is added.

Function(s)

porting in Slmod's "safestring" basic serialize

Defined in:

UTILS

Parameter:

s

Heading Degrees (0-360) to Cardinal

Defined in:

UTILS

Parameter:

#number Heading

The heading

Return value:

#string:

Cardinal, e.g. "NORTH"

Beaufort scale: returns Beaufort number and wind description as a function of wind speed in m/s.

Defined in:

UTILS

Parameter:

#number speed

Wind speed in m/s.

Return values:

#number:

Beaufort number.

#string:

Beauford wind description.

Convert temperature from Celsius to Fahrenheit.

Defined in:

UTILS

Parameter:

#number Celcius

Temperature in degrees Celsius.

Return value:

#number:

Temperature in degrees Fahrenheit.

Function to check if a file exists.

Defined in:

UTILS

Parameters:

#string Path

The path to use. Use double backslashes \\ on Windows filesystems.

#string Filename

The name of the file.

Return value:

#boolean:

outcome True if reading is possible, else false.

Checks the current memory usage collectgarbage("count").

Info is printed to the DCS log file. Time stamp is the current mission runtime.

Defined in:

UTILS

Parameter:

#boolean output

If true, print to DCS log file.

Return value:

#number:

Memory usage in kByte.

Convert clock time from hours, minutes and seconds to seconds.

Defined in:

UTILS

Parameter:

#string clock

String of clock time. E.g., "06:12:35" or "5:1:30+1". Format is (H)H:(M)M:((S)S)(+D) H=Hours, M=Minutes, S=Seconds, D=Days.

Return value:

#number:

Seconds. Corresponds to what you cet from timer.getAbsTime() function.

Deep copy a table.

See http://lua-users.org/wiki/CopyTable

Defined in:

UTILS

Parameter:

#table object

The input table.

Return value:

#table:

Copy of the input table.

Display clock and mission time on screen as a message to all.

Defined in:

UTILS

Parameter:

#number duration

Duration in seconds how long the time is displayed. Default is 5 seconds.

porting in Slmod's dostring

Defined in:

UTILS

Parameter:

s

Defined in:

UTILS

Parameter:

feet

Checks if a file exists or not.

This requires io to be desanitized.

Defined in:

UTILS

Parameter:

#string file

File that should be checked.

Return value:

#boolean:

True if the file exists, false if the file does not exist or nil if the io module is not available and the check could not be performed.

Get the time difference between GMT and local time.

Defined in:

UTILS

Return value:

#number:

Local time difference in hours compared to GMT. E.g. Dubai is GMT+4 ==> +4 is returned.

Function to generate valid FM frequencies in mHz for radio beacons (FM).

Defined in:

UTILS

Return value:

#table:

Table of frequencies.

Function to generate valid laser codes for JTAC.

Defined in:

UTILS

Return value:

#table:

Laser Codes.

Function to generate valid UHF Frequencies in mHz (AM).

Defined in:

UTILS

Return value:

#table:

UHF Frequencies

Function to generate valid VHF frequencies in kHz for radio beacons (FM).

Defined in:

UTILS

Return value:

#table:

VHFrequencies

Get the callsign name from its enumerator value

Defined in:

UTILS

Parameter:

#number Callsign

The enumerator callsign.

Return value:

#string:

The callsign name or "Ghostrider".

Get a table of all characters in a string.

Defined in:

UTILS

Parameter:

#string str

Sting.

Return value:

#table:

Individual characters.

Get the coalition name from its numerical ID, e.g.

coaliton.side.RED.

Defined in:

UTILS

Parameter:

#number Coalition

The coalition ID.

Return value:

#string:

The coalition name, i.e. "Neutral", "Red" or "Blue" (or "Unknown").

Returns the DCS map/theatre as optained by env.mission.theatre

Defined in:

UTILS

Return value:

#string:

DCS map name.

Returns the mission date.

This is the date the mission started.

Defined in:

UTILS

Return values:

#string:

Mission date in yyyy/mm/dd format.

#number:

The year anno domini.

#number:

The month.

#number:

The day.

Get the day of the year.

Counting starts on 1st of January.

Defined in:

UTILS

Parameters:

#number Year

The year.

#number Month

The month.

#number Day

The day.

Return value:

#number:

The day of the year.

Returns the magnetic declination of the map.

Returned values for the current maps are:

  • Caucasus +6 (East), year ~ 2011
  • NTTR +12 (East), year ~ 2011
  • Normandy -10 (West), year ~ 1944
  • Persian Gulf +2 (East), year ~ 2011
  • The Cannel Map -10 (West)
  • Syria +5 (East)
  • Mariana Islands +2 (East)

Defined in:

UTILS

Parameter:

#string map

(Optional) Map for which the declination is returned. Default is from env.mission.theatre

Return value:

#number:

Declination in degrees.

get a new mark ID for markings

Defined in:

UTILS

Returns the day of the mission.

Defined in:

UTILS

Parameter:

#number Time

(Optional) Abs. time in seconds. Default now, i.e. the value return from timer.getAbsTime().

Return value:

#number:

Day of the mission. Mission starts on day 0.

Returns the current day of the year of the mission.

Defined in:

UTILS

Parameter:

#number Time

(Optional) Abs. time in seconds. Default now, i.e. the value return from timer.getAbsTime().

Return value:

#number:

Current day of year of the mission. For example, January 1st returns 0, January 2nd returns 1 etc.

Get the modulation name from its numerical value.

Defined in:

UTILS

Parameter:

#number Modulation

The modulation enumerator number. Can be either 0 or 1.

Return value:

#string:

The modulation name, i.e. "AM"=0 or "FM"=1. Anything else will return "Unknown".

Get OS time.

Needs os to be desanitized!

Defined in:

UTILS

Return value:

#number:

Os time in seconds.

Get a random element of a table.

Defined in:

UTILS

Parameters:

#table t

Table.

#boolean replace

If true, the drawn element is replaced, i.e. not deleted.

Return value:

#number:

Table element.

Get sunrise or sun set of a specific day of the year at a specific location.

Defined in:

UTILS

Parameters:

#number DayOfYear

The day of the year.

#number Latitude

Latitude.

#number Longitude

Longitude.

#boolean Rising

If true, calc sun rise, or sun set otherwise.

#number Tlocal

Local time offset in hours. E.g. +4 for a location which has GMT+4.

Return value:

#number:

Sun rise/set in seconds of the day.

Get sun rise of a specific day of the year at a specific location.

Defined in:

UTILS

Parameters:

#number Day

Day of the year.

#number Month

Month of the year.

#number Year

Year.

#number Latitude

Latitude.

#number Longitude

Longitude.

#boolean Rising

If true, calc sun rise, or sun set otherwise.

#number Tlocal

Local time offset in hours. E.g. +4 for a location which has GMT+4. Default 0.

Return value:

#number:

Sun rise in seconds of the day.

Get sun set of a specific day of the year at a specific location.

Defined in:

UTILS

Parameters:

#number Day

Day of the year.

#number Month

Month of the year.

#number Year

Year.

#number Latitude

Latitude.

#number Longitude

Longitude.

#boolean Rising

If true, calc sun rise, or sun set otherwise.

#number Tlocal

Local time offset in hours. E.g. +4 for a location which has GMT+4. Default 0.

Return value:

#number:

Sun rise in seconds of the day.

Calculate the difference between two "heading", i.e.

angles in [0,360) deg.

Defined in:

UTILS

Parameters:

#number h1

Heading one.

#number h2

Heading two.

Return value:

#number:

Heading difference in degrees.

Test if a Vec2 is in a radius of another Vec2

Defined in:

UTILS

Parameters:

InVec2

Vec2

Radius

Test if a Vec3 is in the sphere of another Vec3

Defined in:

UTILS

Parameters:

InVec3

Vec3

Radius

Function to infer instance of an object

Examples:

  • UTILS.IsInstanceOf( 'some text', 'string' ) will return true

  • UTILS.IsInstanceOf( some_function, 'function' ) will return true

  • UTILS.IsInstanceOf( 10, 'number' ) will return true

  • UTILS.IsInstanceOf( false, 'boolean' ) will return true

  • UTILS.IsInstanceOf( nil, 'nil' ) will return true

  • UTILS.IsInstanceOf( ZONE:New( 'some zone', ZONE ) will return true

  • UTILS.IsInstanceOf( ZONE:New( 'some zone', 'ZONE' ) will return true

  • UTILS.IsInstanceOf( ZONE:New( 'some zone', 'zone' ) will return true

  • UTILS.IsInstanceOf( ZONE:New( 'some zone', 'BASE' ) will return true

  • UTILS.IsInstanceOf( ZONE:New( 'some zone', 'GROUP' ) will return false

Defined in:

UTILS

Parameters:

object

is the object to be evaluated

className

is the name of the class to evaluate (can be either a string or a Moose class)

Return value:

#boolean:

(Helicopter) Check if one loading door is open.

Defined in:

UTILS

Parameter:

#string unit_name

Unit name to be checked

Return value:

#boolean:

Outcome - true if a (loading door) is open, false if not, nil if none exists.

Defined in:

UTILS

Parameter:

kilometers

Defined in:

UTILS

Parameter:

kilometers

Defined in:

UTILS

Parameter:

kilometers

Defined in:

UTILS

Parameter:

knots

Defined in:

UTILS

Parameter:

kmph

Convert knots to alitude corrected KIAS, e.g.

for tankers.

Defined in:

UTILS

Parameters:

#number knots

Speed in knots.

#number altitude

Altitude in feet

Return value:

#number:

Corrected KIAS

Defined in:

UTILS

Parameter:

knots

Convert knots to meters per second.

Defined in:

UTILS

Parameter:

#number knots

Speed in knots.

Return value:

#number:

Speed in m/s.

Function to save an object to a file

Defined in:

UTILS

Parameters:

#string Path

The path to use. Use double backslashes \\ on Windows filesystems.

#string Filename

The name of the file.

Return values:

#boolean:

outcome True if reading is possible and successful, else false.

#table:

data The data read from the filesystem (table of lines of text). Each line is one single #string!

Load back a SET of groups from file.

Defined in:

UTILS

Parameters:

#string Path

The path to use. Use double backslashes \\ on Windows filesystems.

#string Filename

The name of the file.

#boolean Spawn

If set to false, do not re-spawn the groups loaded in location and reduce to size.

Return value:

Set of GROUP objects. Returns nil when file cannot be read. Returns a table of data entries if Spawn is false: { groupname=groupname, size=size, coordinate=coordinate }

Load back a SET of statics from file.

Defined in:

UTILS

Parameters:

#string Path

The path to use. Use double backslashes \\ on Windows filesystems.

#string Filename

The name of the file.

Return value:

Set SET_STATIC containing the static objects.

Load back a stationary list of groups from file.

Defined in:

UTILS

Parameters:

#string Path

The path to use. Use double backslashes \\ on Windows filesystems.

#string Filename

The name of the file.

#boolean Reduce

If false, existing loaded groups will not be reduced to fit the saved number.

Return value:

#table:

Table of data objects (tables) containing groupname, coordinate and group object. Returns nil when file cannot be read.

Load back a stationary list of statics from file.

Defined in:

UTILS

Parameters:

#string Path

The path to use. Use double backslashes \\ on Windows filesystems.

#string Filename

The name of the file.

#boolean Reduce

If false, do not destroy the units with size=0.

Return value:

#table:

Table of data objects (tables) containing staticname, size (0=dead else 1), coordinate and the static object. Returns nil when file cannot be read.

Defined in:

UTILS

Parameter:

meters

Defined in:

UTILS

Parameter:

meters

Defined in:

UTILS

Parameter:

meters

Defined in:

UTILS

Parameter:

miph

Defined in:

UTILS

Parameter:

mps

Convert meters per second to knots.

Defined in:

UTILS

Parameter:

#number mps

Speed in m/s.

Return value:

#number:

Speed in knots.

Convert meters per second to miles per hour.

Defined in:

UTILS

Parameter:

#number mps

Speed in m/s.

Return value:

#number:

Speed in miles per hour.

Defined in:

UTILS

Parameter:

NM

Defined in:

UTILS

Parameter:

NM

Porting in Slmod's serialize_slmod2.

Defined in:

UTILS

Parameter:

#table tbl

Input table.

Generate a Gaussian pseudo-random number.

Defined in:

UTILS

Parameters:

#number x0

Expectation value of distribution.

#number sigma

(Optional) Standard deviation. Default 10.

#number xmin

(Optional) Lower cut-off value.

#number xmax

(Optional) Upper cut-off value.

#number imax

(Optional) Max number of tries to get a value between xmin and xmax (if specified). Default 100.

Return value:

#number:

Gaussian random number.

Randomize a value by a certain amount.

Defined in:

UTILS

Parameters:

#number value

The value which should be randomized

#number fac

Randomization factor.

#number lower

(Optional) Lower limit of the returned value.

#number upper

(Optional) Upper limit of the returned value.

Return value:

#number:

Randomized value.

Usages:

  • UTILS.Randomize(100, 0.1) returns a value between 90 and 110, i.e. a plus/minus ten percent variation.
  • UTILS.Randomize(100, 0.5, nil, 120) returns a value between 50 and 120, i.e. a plus/minus fivty percent variation with upper bound 120.

Remove an object (marker, circle, arrow, text, quad, ...) on the F10 map.

Defined in:

UTILS

Parameters:

#number MarkID

Unique ID of the object.

#number Delay

(Optional) Delay in seconds before the mark is removed.

Replace illegal characters [<>|/?*:\] in a string.

Defined in:

UTILS

Parameters:

#string Text

Input text.

#string ReplaceBy

Replace illegal characters by this character or string. Default underscore "_".

Return value:

#string:

The input text with illegal chars replaced.

Rotate 3D vector in the 2D (x,z) plane.

y-component (usually altitude) unchanged.

Defined in:

UTILS

Parameters:

Vector in 3D with x, y, z components.

#number angle

Rotation angle in degrees.

Return value:

Vector rotated in the (x,z) plane.

From http://lua-users.org/wiki/SimpleRound use negative idp for rounding ahead of decimal place, positive for rounding after decimal place

Defined in:

UTILS

Parameters:

num

idp

Function to save the state of a set of Wrapper.Group#GROUP objects.

Defined in:

UTILS

Parameters:

of objects to save

#string Path

The path to use. Use double backslashes \\ on Windows filesystems.

#string Filename

The name of the file.

Return value:

#boolean:

outcome True if saving is successful, else false.

Usage:

We will go through the set and find the corresponding group and save the current group size and current position.
The idea is to respawn the groups **spawned during an earlier run of the mission** at the given location and reduce 
the number of units in the group when reloading the data again to restart the saved mission. Note that *dead* groups 
cannot be covered with this.
**Note** Do NOT use dashes or hashes in group template names (-,#)!
The data will be a simple comma separated list of groupname and size, with one header line.
The current task/waypoint/etc cannot be restored. 

Function to save the state of a set of Wrapper.Static#STATIC objects.

Defined in:

UTILS

Parameters:

of objects to save

#string Path

The path to use. Use double backslashes \\ on Windows filesystems.

#string Filename

The name of the file.

Return value:

#boolean:

outcome True if saving is successful, else false.

Usage:

We will go through the set and find the corresponding static and save the current name and postion when alive.
The data will be a simple comma separated list of name and state etc, with one header line.

Function to save the state of a list of groups found by name

Defined in:

UTILS

Parameters:

#table List

Table of strings with groupnames

#string Path

The path to use. Use double backslashes \\ on Windows filesystems.

#string Filename

The name of the file.

Return value:

#boolean:

outcome True if saving is successful, else false.

Usage:

We will go through the list and find the corresponding group and save the current group size (0 when dead).
These groups are supposed to be put on the map in the ME and have *not* moved (e.g. stationary SAM sites). 
Position is still saved for your usage.
The idea is to reduce the number of units when reloading the data again to restart the saved mission.
The data will be a simple comma separated list of groupname and size, with one header line.

Function to save the state of a list of statics found by name

Defined in:

UTILS

Parameters:

#table List

Table of strings with statics names

#string Path

The path to use. Use double backslashes \\ on Windows filesystems.

#string Filename

The name of the file.

Return value:

#boolean:

outcome True if saving is successful, else false.

Usage:

We will go through the list and find the corresponding static and save the current alive state as 1 (0 when dead).
Position is saved for your usage. **Note** this works on UNIT-name level.
The idea is to reduce the number of units when reloading the data again to restart the saved mission.
The data will be a simple comma separated list of name and state etc, with one header line.

Function to save an object to a file

Defined in:

UTILS

Parameters:

#string Path

The path to use. Use double backslashes \\ on Windows filesystems.

#string Filename

The name of the file. Existing file will be overwritten.

#table Data

The LUA data structure to save. This will be e.g. a table of text lines with an \n at the end of each line.

Return value:

#boolean:

outcome True if saving is possible, else false.

Seconds of today.

Defined in:

UTILS

Return value:

#number:

Seconds passed since last midnight.

Convert time in seconds to hours, minutes and seconds.

Defined in:

UTILS

Parameters:

#number seconds

Time in seconds, e.g. from timer.getAbsTime() function.

#boolean short

(Optional) If true, use short output, i.e. (HH:)MM:SS without day.

Return value:

#string:

Time in format Hours:Minutes:Seconds+Days (HH:MM:SS+D).

Cound seconds until next midnight.

Defined in:

UTILS

Return value:

#number:

Seconds to midnight.

Shuffle a table accoring to Fisher Yeates algorithm

Defined in:

UTILS

Parameter:

#table t

Table to be shuffled.

Return value:

#table:

Shuffled table.

Split string at seperators.

C.f. http://stackoverflow.com/questions/1426954/split-string-in-lua

Defined in:

UTILS

Parameters:

#string str

Sting to split.

#string sep

Speparator for split.

Return value:

#table:

Split text.

Converts a TACAN Channel/Mode couple into a frequency in Hz.

Defined in:

UTILS

Parameters:

#number TACANChannel

The TACAN channel, i.e. the 10 in "10X".

#string TACANMode

The TACAN mode, i.e. the "X" in "10X".

Return value:

#number:

Frequency in Hz or #nil if parameters are invalid.

Defined in:

UTILS

Parameter:

angle

Defined in:

UTILS

Parameter:

angle

Create a BRAA NATO call string BRAA between two GROUP objects

Defined in:

UTILS

Parameters:

GROUP object

GROUP object

Return value:

#string:

Formatted BRAA NATO call

Calculate the total vector of two 2D vectors by adding the x,y components of each other.

Defined in:

UTILS

Parameters:

Vector in 2D with x, y components.

Vector in 2D with x, y components.

Return value:

Vector c=a+b with c(i)=a(i)+b(i), i=x,y.

Calculate the dot product of two 2D vectors.

The result is a number.

Defined in:

UTILS

Parameters:

Vector in 2D with x, y components.

Vector in 2D with x, y components.

Return value:

#number:

Scalar product of the two vectors a*b.

Calculate "heading" of a 2D vector in the X-Y plane.

Defined in:

UTILS

Parameter:

Vector in "D with x, y components.

Return value:

#number:

Heading in degrees in [0,360).

Calculate the euclidean norm (length) of a 2D vector.

Defined in:

UTILS

Parameter:

Vector in 2D with x, y components.

Return value:

#number:

Norm of the vector.

Rotate 2D vector in the 2D (x,z) plane.

Defined in:

UTILS

Parameters:

Vector in 2D with x, y components.

#number angle

Rotation angle in degrees.

Return value:

Vector rotated in the (x,y) plane.

Calculate the difference between two 2D vectors by substracting the x,y components from each other.

Defined in:

UTILS

Parameters:

Vector in 2D with x, y components.

Vector in 2D with x, y components.

Return value:

Vector c=a-b with c(i)=a(i)-b(i), i=x,y.

Translate 2D vector in the 2D (x,z) plane.

Defined in:

UTILS

Parameters:

Vector in 2D with x, y components.

#number distance

The distance to translate.

#number angle

Rotation angle in degrees.

Return value:

Translated vector.

Calculate the total vector of two 3D vectors by adding the x,y,z components of each other.

Defined in:

UTILS

Parameters:

Vector in 3D with x, y, z components.

Vector in 3D with x, y, z components.

Return value:

Vector c=a+b with c(i)=a(i)+b(i), i=x,y,z.

Calculate the angle between two 3D vectors.

Defined in:

UTILS

Parameters:

Vector in 3D with x, y, z components.

Vector in 3D with x, y, z components.

Return value:

#number:

Angle alpha between and b in degrees. alpha=acos(ab)/(|a||b|), ( denotes the dot product).

Calculate the cross product of two 3D vectors.

The result is a 3D vector.

Defined in:

UTILS

Parameters:

Vector in 3D with x, y, z components.

Vector in 3D with x, y, z components.

Return value:

Vector

Calculate the distance between two 2D vectors.

Defined in:

UTILS

Parameters:

Vector in 3D with x, y components.

Vector in 3D with x, y components.

Return value:

#number:

Distance between the vectors.

Calculate the distance between two 3D vectors.

Defined in:

UTILS

Parameters:

Vector in 3D with x, y, z components.

Vector in 3D with x, y, z components.

Return value:

#number:

Distance between the vectors.

Calculate the dot product of two vectors.

The result is a number.

Defined in:

UTILS

Parameters:

Vector in 3D with x, y, z components.

Vector in 3D with x, y, z components.

Return value:

#number:

Scalar product of the two vectors a*b.

Calculate "heading" of a 3D vector in the X-Z plane.

Defined in:

UTILS

Parameter:

Vector in 3D with x, y, z components.

Return value:

#number:

Heading in degrees in [0,360).

Calculate the euclidean norm (length) of a 3D vector.

Defined in:

UTILS

Parameter:

Vector in 3D with x, y, z components.

Return value:

#number:

Norm of the vector.

Calculate the difference between two 3D vectors by substracting the x,y,z components from each other.

Defined in:

UTILS

Parameters:

Vector in 3D with x, y, z components.

Vector in 3D with x, y, z components.

Return value:

Vector c=a-b with c(i)=a(i)-b(i), i=x,y,z.

Translate 3D vector in the 2D (x,z) plane.

y-component (usually altitude) unchanged.

Defined in:

UTILS

Parameters:

Vector in 3D with x, y, z components.

#number distance

The distance to translate.

#number angle

Rotation angle in degrees.

Return value:

Vector rotated in the (x,z) plane.

Convert pressure from hecto Pascal (hPa) to inches of mercury (inHg).

Defined in:

UTILS

Parameter:

#number hPa

Pressure in hPa.

Return value:

#number:

Pressure in inHg.

Convert pressure from hecto Pascal (hPa) to millimeters of mercury (mmHg).

Defined in:

UTILS

Parameter:

#number hPa

Pressure in hPa.

Return value:

#number:

Pressure in mmHg.

Convert kilo gramms (kg) to pounds (lbs).

Defined in:

UTILS

Parameter:

#number kg

Mass in kg.

Return value:

#number:

Mass in lbs.

Here is a customized version of pairs, which I called kpairs because it iterates over the table in a sorted order, based on a function that will determine the keys as reference first.

Defined in:

UTILS

Parameters:

t

getkey

order

Here is a customized version of pairs, which I called rpairs because it iterates over the table in a random order.

Defined in:

UTILS

Parameter:

t

Here is a customized version of pairs, which I called spairs because it iterates over the table in a sorted order.

Defined in:

UTILS

Parameters:

t

order

acc: in DM: decimal point of minutes. In DMS: decimal point of seconds. position after the decimal of the least significant digit: So: 42.32 - acc of 2.

Defined in:

UTILS

Parameters:

lat

lon

acc

DMS

acc- the accuracy of each easting/northing. 0, 1, 2, 3, 4, or 5.

Defined in:

UTILS

Parameters:

MGRS

acc