VR-Forces 5.2 Lua Function Documentation

LocationReference

(For high level concepts about how to use Lua to write scripted tasks, please see VR-Forces User's Guide.)

A LocationReference is an object that references a location in the world. It references it as either an absolute position, or by referring to another object in the simulation. These are called Absolute type and Object type references, respectively. getLocation3D() can be used to get the current location regardless of reference method, but be aware that this location may not be constant over time. The isDynamic() function indicates whether or not this instance is guaranteed to be constant over time.

Function List

LocationReference (objectOrLocation) Constructor for LocationReference.
getLocation3D () This function works for both Absolute and Object location reference types.
getLocationType () Returns the type of location reference this instance is.
getSimObject () If the LocationReference is an Object type reference, then this returns the SimObject.
isDynamic () Indicates if this LocationReference can change over time, which is the case if it references an Object location.
isLeftOfLine (loc1, loc2) Determines whether this point is left of the line defined by the two locations.
isValid () Indicates if this LocationReference is valid and can be used.
setSimLocation3D (location) Sets this LocationReference to be an Absolute location type and sets it to base the location on the Location3D provided.
setSimObject (object) Sets this LocationReference to be an Object type reference and sets it to base the location on the SimObject provided.


Functions

LocationReference (objectOrLocation)
Constructor for LocationReference. Will initialize it to be an Object location type or Absolute location type reference, depending on the input parameter.

Parameters:

  • objectOrLocation: (SimObject or Location3D) The provided argument can be either a SimObject or Location3D. When a SimObject is provided, the LocationReference is initialized as an Object type reference. When a Location3D is provided, it is initialized as an Absolute type reference.

Return value:

    A LocationReference object.
getLocation3D ()
This function works for both Absolute and Object location reference types. In Object locations, this provides the current location of the referenced object, which may change in the future. In Absolute locations, it provides the location.

Return value:

    A Location3D that is the current location of this LocationReference.
getLocationType ()
Returns the type of location reference this instance is. It will be either a specific Absolute location in the world, or refer to an Object (entity, waypoint, etc).

Return value:

    0 for Absolute location, 1 for Object based location.
getSimObject ()
If the LocationReference is an Object type reference, then this returns the SimObject.

Return value:

    SimObject or nil
isDynamic ()
Indicates if this LocationReference can change over time, which is the case if it references an Object location.

Return value:

    True if this LocationReference can change over time.
isLeftOfLine (loc1, loc2)
Determines whether this point is left of the line defined by the two locations. "Left" is from the point of view of an upright observer on the earth at loc1.

Parameters:

  • loc1: Location3D of the first point defining the line.
  • loc2: Location3D of the second point defining the line.

Return value:

    Boolean, true if this point is to the left of the line.
isValid ()
Indicates if this LocationReference is valid and can be used.

Return value:

    True if the LocationReference is valid and can be used.
setSimLocation3D (location)
Sets this LocationReference to be an Absolute location type and sets it to base the location on the Location3D provided.

Parameters:

  • location: A Location3D to be the new absolute location.
setSimObject (object)
Sets this LocationReference to be an Object type reference and sets it to base the location on the SimObject provided.

Parameters:

  • object: SimObject to be the new location.

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