VR-Forces 5.1.1 Lua Function Documentation

These pages document the Lua functions that you can use in scripted tasks. For high level concepts about how to use Lua to write scripted tasks, please see VR-Forces User's Guide.

The modules listed in the table of contents include classes, packages of functions in a name space, and collections of global functions:

  • Global functions (usage: vrf:<function name>(...))
    • vrf
  • Classes (usage: <class object>:<function name>(...))
    • Features
      • FeatureGeometry
      • FeatureSet
    • Geometry
      • Location3D
      • Vector3D
      • VectorGeoc3D
      • VectorOffset3D
    • Simulation Objects
      • SimObject
      • this
    • Simulation Object Component Systems
      • ComponentSystem
      • SystemAttribute
      • SwingingArtPart
      • TranslatableArtPart
      • SensorGimbal
    • ScriptAnimationModel
    • AsyncJob
    • TranslatableStream
  • Modules (general usage: <module name>.<function name>(...))
    • fsm
    • fsm2
    • parseUtil
    • spatialUtil
  • Packages of functions (usage: <function name>(...))
    • aggregateUtils
    • airportDataUtils
    • fileUtils
    • munitionLauncherUtils
    • pathUtil
    • vrfUtil
  • Documentation
    • Set Catalog
    • Task Catalog
    • How to Print

Table of Contents

!HowToPrint This section of the Lua API documentation does not describe a module of code; its purpose is to collect the information on print-related functions in other modules into one place.
!Set Catalog This section lists all the built in set-data command names, and the arguments each one accepts.
!Task Catalog This section lists all the C++ task names, and the arguments each one accepts.
AerodromeObject The AerodromeObject class refers to a single aerodrome object that contains data about the geometry and other characteristics of an aerodrome.
AirRefuelSupplier The AirRefuelSupplier is an object that controls the refuel points of a tanker aircraft.
AsyncJob An AsyncJob represents a the status of a job that is running asynchronously to the Lua task.
ComponentSystem A component system is a capability that is assigned to the entity in the Entity Editor.
Detonation A collection of detonation parameters Includes the location of the detonation, munitionType of the detonation, the detonation result, Warhead type, fuse type, quanity in the detonation, and if more than one, rate of munitions.
ExtendableArtPart The ExtendableArtPart is a class of Lua object that represents a rotating articulated part.
FeatureGeometry This module contains contains functions for operating on FeatureGeometry objects.
FeatureSet A FeatureSet is an object that contains a set of features.
Location3D This module contains functions for creating and operating on a 3D point object.
LocationReference A LocationReference is an object that references a location in the world.
ScriptAnimationModel The DtScriptAnimationModel class refers to an animation model that can be used by a scripted task to animate an entity's movement.
SensorGimbal The SensorGimbal is a sensor that rotates on a gimbal.
SimObject The SimObject class refers to a single object in the simulation.
SwingingArtPart The SwingingArtPart is a class of Lua object that represents a rotating articulated part.
SystemAttribute This section of the Lua documentation lists the attributes that entity systems can provide in the componentSystem:getAttribute function.
See the ComponentSystem module documentation.
TranslatableArtPart The TranslatableArtPart is a class of Lua object that represents a translating articulated part.
TranslatableStream A TranslatableStream is a text stream class that can be translated by VR-Force for display in the GUI as text that is translated to the current language the user is displaying (as long as those translations exist.) See the VR-Forces Users Guide, section 2.5, for information about localizing the GUI.
Vector3D A Vector3D is a vector in earth-relative coordinates, e.g.
VectorGeoc3D A VectorGeoc3D is a straight line in space, unlike a Vector3D.
VectorOffset3D A VectorOffset3D is a direction vector that is relative to some direction specified by a Vector3D.
WeaponInfo A WeaponInfo is a class providing information about a specific weapon available on the ownship entity.
aggregateUtils AggregateUtils is a collection of tables and functions that provide useful capabilities and definitions related to aggregates.
airportDataUtils Functions that compute information of interest about airports and runways.
behaviorEngine This package implements a behavior engine aimed at supporting unit behaviors, or "commands." These commands are invoked and executed the same way all Lua task scripts are.
componentSystemUtil Utilities to provide information on component systems in a convenient form.
contactsUtils

Contact Utilities

Summary

Utilities to provide information about reported hostile (or other) contacts.

Dependencies

Please make sure that this is preceded by these inclusions:

require "vrfutil"

Usage

require "contactsUtils"
dataFileUtils Contains utility functions for reading data from text files.
displayGraphUtil

Introduction

The functions in this library assist with generating graph commands in the dot language (see https://graphviz.org/doc/info/lang.html) and displaying the graph.
embarkationUtil

Summary

Embarkation utilities help computation about embarkation slots.

Dependencies

Please make sure that this is preceded by these inclusions:

require "vrfutil"

Usage

require "embarkationUtil"

Constants

ConstantDescription
SLOT_NUMBER = "slot_number"Index into an embarkation slot returned by vrf:getEmbarkationSlots(...)
SLOT_NAME = "slot_name"Index into an embarkation slot returned by vrf:getEmbarkationSlots(...)
SLOT_TYPE = "slot_type"Index into an embarkation slot returned by vrf:getEmbarkationSlots(...)
SLOT_POSITION = "slot_position"Index into an embarkation slot returned by vrf:getEmbarkationSlots(...)
OCCUPIED = "occupied"Index into an embarkation slot returned by vrf:getEmbarkationSlots(...)
AVAILABLE = "available"Index into an embarkation slot returned by vrf:getEmbarkationSlots(...)
engagementUtil Functions that assist in calculating targets, line of sight.
Usage:
 require "engagementUtil"  

Embarkation Utilities

Summary

Embarkation utilities help computation about embarkation slots.

Dependencies

Please make sure that this is preceded by these inclusions:

require "vrfutil"
require "formationUtils"

Usage

require "engagementUtil"

Constants

ConstantDescription
GRENADE_LAUNCHER_RANGE_MAX = 400A maximum limit in meters on the practical use of a M203 Launcher, for purposes of engagement behaviors.
GRENADE_LAUNCHER_RANGE_MINA minimum limit in meters on the practical use of a M203 Launcher, for purposes of engagement behaviors.
grenadeLauncherWeaponSystemNamesAn array of weapon system names that helps behaviors find a grenade launcher on a "this" simulated object.
formationUtils Functions that help with access to and manipulation of formation definition data, including formation names and position offsets.
Usage:
 formationFns = require "formationUtils"  
formName = formationFns.getValidFormationNameFor(this, "Line")

fsm A design pattern for doing finite state machines (FSMs) in Lua.
fsm2 A design pattern for implementing finite state machines (FSMs) in Lua.
lightDataUtils

Summary

Defines tables that contain data that can be used in changing runway/aerodrome light settings to some predefined states.

msgUtil Message Util is a collection of functions that maintain queues of object or text messages that the entity receives.
munitionLauncherUtils This package contains some functions that support munition-launching scripts such as Delayed_homing and Launch_ASW_Missile.
parseUtil Lua functions that assist with parsing of strings, especially from received messages.
pathUtil pathUtil is a collection of utility functions that help with path planning and ground-clamping points on a route.
spatialUtil Functions that compute things in space using points, vectors, etc.
taskVisualizationUtil
terrainReasoningUtil

Terrain Reasoning Utilities

Summary

Terrain Reasoning Utilities provide helper functions for processing the results of terrain reasoning queries.

Dependencies

Please make sure that this is preceded by these inclusions:

require "vrfutil"
require "formationUtils"

Usage

require "terrainReasoningUtil"

Constants

ConstantDescription
_NumElementsInGroup = 5The number of elements in a position group returned by vrf:findPositionGroupsInArea(...)
_NumElementsInPair = 2A textual mnemonic for a non-intuitive numerical value that indicates a limit on how many Location3Ds constitute a fighting position returned by terrain reasoning queries.
_IndexOfPairsTableInPositionGroup = 5In a position group returned from vrf:findPositionGroupsInArea(...), in what element can one find the position pairs? E.g.
this The 'this' object instance refers to the SimObject on which the script is running.
threatLevelUtil

Threat Level Utilities

Summary

Provides functions that rank entity entity types an a threat level scale.

unitUtil

Summary

These utilities help computation about units.

Dependencies

Please make sure that this is preceded by these inclusions:

require "vrfutil"
require "formationUtils"
vrf This module defines API functions that pass information to and from the simulation without reference to a particular simulation object or other class instance.
vrfutil Vrfutil is a collection of tables and functions that provide useful capabilities and definitions to Lua scripts in VR-Forces.
weaponUtils

Weapon Utilities

Summary

Provides functions for the use of weaponInfo data on the host entity.

Dependencies

Please make sure that this is preceded by these inclusions:

require "vrfutil"

Usage

require "weaponUtils"

Copyright© 2024 MAK Technologies, Inc. All rights reserved.