VR-Forces 5.0.3 Lua Function Documentation

embarkationUtil

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


Embarkation Utilities

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(...)

Function List

availableSlots (embarkationSlots) Returns available slots from a list of embarkation slots (originated from vrf:getEmbarkationSlots(...)) Given a table containing embarkation slots, return the available slots.
closestEgressTo2D (referenceOffset, egressPoints) Return an egress point nearest to the given VectorOffset3D.
compareSlotDistanceLessThan (left, right) Given left and right elements in form {, #} Compare # and return true if left # is less than right #.
getOffsetsFromEgressPointsJobResults (jobResults) return an array (table) of VectorOffset3D that are egress positions returned from job results vrf:getEmbarkationEgressPoints()
isEmbarkationSlot (element) Returns true if the given table is an embarkation slot (in form returned by vrf:getEmbarkationSlots(...)
isEmbarkationSlotList (element) Returns true if the given table is a list of embarkation slots (in form returned by vrf:getEmbarkationSlots(...)
locationForOffset (simObject, offsetVector) Returns a Location3D relative to the given SimObject at the given offset vector.
makeEmbarkationManifest (passengers) Returns a table that contains a list of vehicles and passengers.
printEmbarkationSlots (embarkationSlots) Print the embarkation slots in the given list.
slotsByType (embarkationSlots, slotType) Returns embarkation slots matching the slot_type.
slotsOnSide (embarkationSlots, leftSide) Returns the embarkation slots on left or right side.
sortSlotsNearToFar (embarkationSlots, vectorRef, index) Returns a list of embarkation slots near to far along reference direction.


Functions

availableSlots (embarkationSlots)
Returns available slots from a list of embarkation slots (originated from vrf:getEmbarkationSlots(...)) Given a table containing embarkation slots, return the available slots.

Parameters:

  • embarkationSlots: is a lua table

Return value:

    a lua table containing available slots.
closestEgressTo2D (referenceOffset, egressPoints)
Return an egress point nearest to the given VectorOffset3D. The most common way to do this is to pass in a referenceOffset that is related to the bounding volume of a simulation object, and the egress points for that object.

Parameters:

  • referenceOffset: VectorOffset3D An offset vector relative to a vehicle location that indicates the desired exit, e.g (0.0, -4.0, 0.0) is the back, or (2.0, 0.0, 0.0) is right.
  • egressPoints: Table An array (table) of VectorOffset3D returned from vrf:getEmbarkationEgressPoints ()

Return value:

    a VectorOffset3D that is the closest egress point to the reference offset.
compareSlotDistanceLessThan (left, right)
Given left and right elements in form {, #} Compare # and return true if left # is less than right #. Used by embarkation slot sorter.

Parameters:

  • left: Table. In the form of {, #}.
  • right: Table. In the form of {, #}.

Return value:

    Boolean. True if left[2] < right[2]
getOffsetsFromEgressPointsJobResults (jobResults)
return an array (table) of VectorOffset3D that are egress positions returned from job results vrf:getEmbarkationEgressPoints()

Parameters:

  • jobResults: Table. Returned from vrf:getEmbarkationEgressPoints()

Return value:

    Array (table) of VectorOffset3D values.
isEmbarkationSlot (element)
Returns true if the given table is an embarkation slot (in form returned by vrf:getEmbarkationSlots(...)

Parameters:

  • element: is a lua table

Return value:

    true if the contents of element look like an embarkation slot
isEmbarkationSlotList (element)
Returns true if the given table is a list of embarkation slots (in form returned by vrf:getEmbarkationSlots(...)

Parameters:

  • element: is a lua table

Return value:

    true if the contents of element look like a list of embarkation slots
locationForOffset (simObject, offsetVector)
Returns a Location3D relative to the given SimObject at the given offset vector. Given a simobject and an offset vector, compute a Location3D relative to the simobject position

Parameters:

  • simObject: SimObject. Object from whose location we want to compute another location.
  • offsetVector: VectorOffset3D. An offset to add to that object's location to result in a new location.

Return value:

    Location3D. The new location.
makeEmbarkationManifest (passengers)
Returns a table that contains a list of vehicles and passengers. Given a list of simObjects, make a table of transports and passengers, excluding any of the given passengers that are not actually on a transport.

Parameters:

  • passengers:

Return value:

    a table of simobjects, in the form {{transport, {passenger, ...}},...}
printEmbarkationSlots (embarkationSlots)
Print the embarkation slots in the given list. Given a lua table containing embarkation slots, print them.

Parameters:

  • embarkationSlots: Table. Embarkation slots in the form returned by vrf:getEmbarkationSlots(...)
slotsByType (embarkationSlots, slotType)
Returns embarkation slots matching the slot_type.

Parameters:

  • embarkationSlots: Table. An array of embarkation slots in the form returned by vrf:getEmbarkationSlots(...)
  • slotType:

Return value:

    Table. A list of embarkation slots that exactly match the type. List is in form returned by vrf:getEmbarkationSlots(...)
slotsOnSide (embarkationSlots, leftSide)
Returns the embarkation slots on left or right side. Uses the offsets in a slot to determine if it is left or right. (negative y is left)

Parameters:

  • embarkationSlots: a lua table containing embarkation slots
  • leftSide: true searches for slots on the left side of a vehicle (facing front), false returns right

Return value:

    table of embarkation slots on the given side.
sortSlotsNearToFar (embarkationSlots, vectorRef, index)
Returns a list of embarkation slots near to far along reference direction. Given a list of embarkation slots, a VectorOffset3D reference point and an index (0, 1 or 2) representing forward, side, up, return a list of embarkation slots sorted closest to the reference vector.

Parameters:

  • embarkationSlots: Table. Embarkation slots in form returned by vrf:getEmbarkationSlots(...)
  • vectorRef: VectorOffset3D. A direction vector to use to evaluate near or far.
  • index:

Return value:

    Table. A list of embarkation slots sorted near to far along direction of vectorRef. Slots are in form returned by vrf:getEmbarkationSlots(...)

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