VR-Forces 4.2 Class Documentation
List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes
DtLuaScriptInterfaceImpl Class Reference
Inheritance diagram for DtLuaScriptInterfaceImpl:
Inheritance graph
[legend]

Classes

struct  LuaExtension

Public Member Functions

virtual ~DtLuaScriptInterfaceImpl ()
virtual void init ()
 Derived class inits may do things, so init should always be called.
virtual DtString type () const
 Script engine type.
virtual bool invokeInit ()
virtual void invokeSuspend ()
virtual bool invokeResume ()
virtual void invokeTick ()
 This will be called by the parent to invoke the script tick.
virtual bool invokeCheck ()
virtual void invokeCheckInit ()
virtual bool loadScript (bool reload)
 This will be called by the parent to let the interface know when to load the script.
virtual void setLuaState (lua_State *L)
virtual lua_State * getLuaState ()
virtual DtReaderWritersaveState ()
 Called when the scenario is saved.
virtual bool loadState (const DtReaderWriter *loadState)
 Called when the scenario is loaded.
virtual void processClearForReuse ()
 This function should be overridden by the inheritor to clear out any task specific variables.
virtual bool initializeVRFLuaExtensions (lua_State *L)
virtual bool importTaskParams (lua_State *L)
void luaEndTask (bool success)
 Admin functions called from Lua.
int luaSendTask (DtScriptVrfObject &object, const ::std::string taskName, luabind::object const &parameters)
 Send task to another entity.
int luaSendTaskActAsSubtask (DtScriptVrfObject &object, const ::std::string taskName, luabind::object const &parameters, bool actAsSubtask)
void luaStopAllTasks ()
 Stops all tasks started by this task.
void luaSendSetDataToSelf (const ::std::string setName, luabind::object const &parameters)
 Send a set-data message to self.
void luaSendSetData (DtScriptVrfObject &object, const ::std::string setName, luabind::object const &parameters)
 Send a set-data message to another entity.
luabind::object luaGetReactionStatus ()
 Provide current reaction status to lua scripts.
std::string luaGetScriptId ()
 Provide the current script ID to lua scripts.
luabind::object luaGetObjectsNear (const DtLocation3D &loc, double distance)
luabind::object luaGetObjectsNearWithFilter (const DtLocation3D &loc, double distance, luabind::object const &parameters)
luabind::object luaGetVrfObjects ()
 Returns a list of all scripted objects.
DtLuaFeatureSet luaGetFeaturesWithinArea (luabind::object const &points, luabind::object const &attributes)
 Routines to query and return feature sets Returns a feature set which contains all features within the specified geometry containing the specified attributes.
DtLuaFeatureSet luaGetFeaturesWithinAreaNoAttributes (luabind::object const &points)
DtLuaFeatureSet luaGetFeaturesWithinRange (const DtLocation3D &, double range, luabind::object const &attributes)
 Returns a feature set which contains all features within the specified point and box size containing the specified attributes.
DtLuaFeatureSet luaGetFeaturesWithinRangeNoAttributes (const DtLocation3D &, double range)
boost::shared_ptr< DtLuaAsyncJobluaNavigateThroughFeatures (const luabind::object &parameters)
 Returns an async job object which will produce a path (set of points) from the input points.
void luaSendMessage (const DtScriptVrfObject &receiver, const std::string &message)
void luaDeleteObject (std::string const &receiver)
void luaDeleteScriptObject (const DtScriptVrfObject &receiver)
virtual void processTextReport (const DtVrfObjectMessage *m)
int luaStartSubtask (const std::string taskName, luabind::object const &parameters)
 Global functions that have Lua-specific dependencies.
void luaStopSubtask (int subtaskId)
 Global functions that have Lua-specific dependencies.
void luaStopAllSubtasks ()
 Stops all subtasks that were started by this task.
bool luaIsSubtaskRunning (int subtaskId)
bool luaIsSubtaskComplete (int subtaskId)
bool luaIsSubtaskCanceled (int subtaskId)
bool luaSubtaskResult (int subtaskId)
DtScriptVrfObject luaCreateEntity (luabind::object const &parameters)
 Create an entity.
DtScriptVrfObject luaCreateTacticalGraphic (luabind::object const &parameters)
 Create a tactical graphic. Must specify name or type.
DtScriptVrfObject luaCreateObstacle (luabind::object const &parameters)
 Create an obstacle.
DtScriptVrfObject luaCreateRoute (luabind::object const &parameters)
 Create a route.
DtScriptVrfObject luaCreateArea (luabind::object const &parameters)
 Create an area.
DtScriptVrfObject luaCreateWaypoint (luabind::object const &parameters)
 Create a waypoint.
DtScriptVrfObject luaCreatePhaseLine (luabind::object const &parameters)
 Creates a phase line.
unsigned luaBitwiseOr (unsigned val1, unsigned val2)
unsigned luaBitwiseAnd (unsigned val1, unsigned val2)
unsigned luaBitwiseXor (unsigned val1, unsigned val2)
unsigned luaBitwiseNot (unsigned val)
unsigned luaBitwiseLeftShift (unsigned val, unsigned shift)
unsigned luaBitwiseRightShift (unsigned val, unsigned shift)
- Public Member Functions inherited from DtScriptInterface
virtual ~DtScriptInterface ()
virtual void setTaskId (int taskId)
virtual int taskId () const
virtual void setScriptId (const DtString &scriptId)
virtual const DtStringscriptId () const
virtual void setScriptPath (const DtFilename &scriptPath)
virtual const DtFilename & scriptPath () const
virtual void setEntity (DtVrfObject *entity)
virtual DtVrfObjectentity () const
virtual void setTaskVariables (const DtRwVariableBindings &variables)
virtual const
DtRwVariableBindings
taskVariables () const
virtual bool updateTaskVariables ()
virtual void setTaskStarting (bool v)
virtual bool taskStarting () const
virtual void setController (DtScriptTaskControllerInterface *controller)
virtual
DtScriptTaskControllerInterface
controller ()
virtual void setTaskResuming (bool v)
 Flag indicating if the task is resuming from a suspended state.
virtual bool taskResuming () const
 Flag indicating if the task is resuming from a suspended state.
double scriptGetExerciseTime ()
 Methods that are available for any script to use.
double scriptGetTimeOfDay ()
 Methods that are available for any script to use.
double scriptGetWindSpeed ()
 Returns wind speed in meters/second.
double scriptGetWindDirection ()
 Returns wind direction in radians.
DtScriptVrfObject scriptGetVrfObjectByName (const std::string name)
 Methods that are available for any script to use.
void printError (const std::string message)
 Methods that are available for any script to use.
void printWarn (const std::string message)
 Methods that are available for any script to use.
void printInfo (const std::string message)
 Methods that are available for any script to use.
void printVerbose (const std::string message)
 Methods that are available for any script to use.
void printDebug (const std::string message)
 Methods that are available for any script to use.
bool entityTypeMatches (const std::string &, const std::string &)
 Methods that are available for any script to use.
void setTickPeriod (double)
 Tick management. Will store information in PSR of controller only.
double getTerrainAltitude (const double lat, const double lon, bool &dataAvailable, std::string &surface) const
 Gets the terrain height at the given location.
double getGroundAltitude (const double lat, const double lon, bool &isWater, bool &dataAvailable)
 Gets the height of the ground at the given location.
void chordIntersectionDebug (const DtLocation3D &startLoc, const DtLocation3D &endLoc)
 Script function for debugging chord-terrain intersections.
bool doesChordHitTerrain (const DtLocation3D &pt1, const DtLocation3D &pt2, bool &dataAvailable) const
 Determines if the chord formed by (point1, point2) intersects the terrain.
DtLocation3D findClosestPointToRoad (const DtLocation3D &point, double searchRadius, bool &dataAvailable, bool &success) const
 Methods that are available for any script to use.
std::string getForceName (int forceType)
 Methods that are available for any script to use.
bool forcesHostile (std::string force1, std::string force2)
 Methods that are available for any script to use.

Static Public Member Functions

static DtScriptInterfacecreator ()
static void addLuaScriptInterfaceExtension (DtLuaScriptInterfaceExtension::CreatorFcn extension, void *usr)
 Add a new extension creator function.
static void addLuaScriptInterfaceExtension (DtLuaScriptInterfaceExtension::CreatorFcn extension, const DtVrfObject *onlyForEntity, void *usr)
 Add a new extension creator function.
static void removeLuaScriptInterfaceExtension (DtLuaScriptInterfaceExtension::CreatorFcn extension, void *usr)
 Remove an extension.
static void removeLuaScriptInterfaceExtension (DtLuaScriptInterfaceExtension::CreatorFcn extension, const DtVrfObject *onlyForEntity, void *usr)
 Removes only for particular entity if registered for that entity.
static void addKeyToIgnore (const std::string &)
 When serializing ignore any key found in this list. Uses instance of luaObjectSerializer.
static void removeKeyToIgnore (const std::string &)
 Removes a key to ignore during serialization Uses instance of luaObjectSerializer.
static void textReportCallback (const DtVrfObjectMessage *m, void *usr)

Protected Types

typedef std::vector
< DtLuaScriptInterfaceExtension * > 
LocalInterfaceExtensions
typedef std::vector< LuaExtensionGlobalInterfaceExtensions

Protected Member Functions

 DtLuaScriptInterfaceImpl ()
 DtLuaScriptInterfaceImpl (const DtLuaScriptInterfaceImpl &other)
DtLuaScriptInterfaceImploperator= (const DtLuaScriptInterfaceImpl &other)
virtual bool callLuaNoArgFunction (const std::string &functionName)
- Protected Member Functions inherited from DtScriptInterface
 DtScriptInterface ()
 Call the DtScriptInterfaceHandler::createScriptInterface() function to create one.
 DtScriptInterface (const DtScriptInterface &other)
DtScriptInterfaceoperator= (const DtScriptInterface &other)
virtual void scriptTaskComplete (bool success)
 This function is meant to be called by the script itself or the script object to tell the parent that the script task is complete.
virtual void scriptTaskError ()
virtual bool scriptText (DtString &text)
 Returns the script text as a string and a bool on whether the text is valid or not.
virtual const DtReaderWritergetTaskParam (const DtString &paramName)
virtual bool getParamMetaDataType (const DtString &paramName, DtString &typeName)

Protected Attributes

lua_State * myLState
bool myLuaScriptWarningShown
LocalInterfaceExtensions myInterfaceExtensions
- Protected Attributes inherited from DtScriptInterface
int myTaskId
DtString myScriptId
DtFilename myScriptPath
DtScriptTaskControllerInterfacemyControllerInterface
DtVrfObjectmyEntity
DtRwVariableBindings myTaskVariables
bool myTaskStarting
 Indicates that a new task is starting, and should be initialized on the next tick.
bool myTaskResuming

Static Protected Attributes

static GlobalInterfaceExtensions theLuaInterfaceExtensions

Member Typedef Documentation

Constructor & Destructor Documentation

DtLuaScriptInterfaceImpl::DtLuaScriptInterfaceImpl ( )
protected
DtLuaScriptInterfaceImpl::DtLuaScriptInterfaceImpl ( const DtLuaScriptInterfaceImpl other)
protected
virtual DtLuaScriptInterfaceImpl::~DtLuaScriptInterfaceImpl ( )
virtual

Member Function Documentation

DtLuaScriptInterfaceImpl& DtLuaScriptInterfaceImpl::operator= ( const DtLuaScriptInterfaceImpl other)
protected
static DtScriptInterface* DtLuaScriptInterfaceImpl::creator ( )
static
virtual void DtLuaScriptInterfaceImpl::init ( void  )
virtual

Derived class inits may do things, so init should always be called.

Reimplemented from DtScriptInterface.

virtual DtString DtLuaScriptInterfaceImpl::type ( ) const
virtual

Script engine type.

Implements DtScriptInterface.

virtual bool DtLuaScriptInterfaceImpl::invokeInit ( )
virtual

Implements DtScriptInterface.

virtual void DtLuaScriptInterfaceImpl::invokeSuspend ( )
virtual

Implements DtScriptInterface.

virtual bool DtLuaScriptInterfaceImpl::invokeResume ( )
virtual

Implements DtScriptInterface.

virtual void DtLuaScriptInterfaceImpl::invokeTick ( )
virtual

This will be called by the parent to invoke the script tick.

Implements DtScriptInterface.

virtual bool DtLuaScriptInterfaceImpl::invokeCheck ( )
virtual

Implements DtScriptInterface.

virtual void DtLuaScriptInterfaceImpl::invokeCheckInit ( )
virtual

Implements DtScriptInterface.

virtual bool DtLuaScriptInterfaceImpl::loadScript ( bool  reload)
virtual

This will be called by the parent to let the interface know when to load the script.

Implements DtScriptInterface.

virtual void DtLuaScriptInterfaceImpl::setLuaState ( lua_State *  L)
virtual
virtual lua_State* DtLuaScriptInterfaceImpl::getLuaState ( )
virtual
virtual DtReaderWriter* DtLuaScriptInterfaceImpl::saveState ( )
virtual

Called when the scenario is saved.

The stateState pointer may not be valid, in which case something went wrong with saving

Implements DtScriptInterface.

virtual bool DtLuaScriptInterfaceImpl::loadState ( const DtReaderWriter savedState)
virtual

Called when the scenario is loaded.

The load state pointer may not be valid, which does not indicate that the scenario loaded incorrectly, but that the data for this particular script interface was either corrupt or did not exist.

Implements DtScriptInterface.

virtual void DtLuaScriptInterfaceImpl::processClearForReuse ( )
virtual

This function should be overridden by the inheritor to clear out any task specific variables.

This version should probably be called last if you override it rather than first to take care of things before these things get cleared.

Reimplemented from DtScriptInterface.

static void DtLuaScriptInterfaceImpl::addLuaScriptInterfaceExtension ( DtLuaScriptInterfaceExtension::CreatorFcn  extension,
void *  usr 
)
static

Add a new extension creator function.

This creator will be called every time a new lua environment is created. Will be applied to all entities

Parameters
usrA pointer that will be passed to the creator function when called.
static void DtLuaScriptInterfaceImpl::addLuaScriptInterfaceExtension ( DtLuaScriptInterfaceExtension::CreatorFcn  extension,
const DtVrfObject onlyForEntity,
void *  usr 
)
static

Add a new extension creator function.

This creator will be called every time a new lua environment is created.

Parameters
onlyForEntityOnly invoke the creator if the entity being tasked is the entity this is registered for
usrA pointer that will be passed to the creator function when called.
static void DtLuaScriptInterfaceImpl::removeLuaScriptInterfaceExtension ( DtLuaScriptInterfaceExtension::CreatorFcn  extension,
void *  usr 
)
static

Remove an extension.

static void DtLuaScriptInterfaceImpl::removeLuaScriptInterfaceExtension ( DtLuaScriptInterfaceExtension::CreatorFcn  extension,
const DtVrfObject onlyForEntity,
void *  usr 
)
static

Removes only for particular entity if registered for that entity.

If there is one registered for all entities and none registered for this entity then no action is taken

virtual bool DtLuaScriptInterfaceImpl::initializeVRFLuaExtensions ( lua_State *  L)
virtual
virtual bool DtLuaScriptInterfaceImpl::importTaskParams ( lua_State *  L)
virtual
static void DtLuaScriptInterfaceImpl::addKeyToIgnore ( const std::string &  )
static

When serializing ignore any key found in this list. Uses instance of luaObjectSerializer.

static void DtLuaScriptInterfaceImpl::removeKeyToIgnore ( const std::string &  )
static

Removes a key to ignore during serialization Uses instance of luaObjectSerializer.

void DtLuaScriptInterfaceImpl::luaEndTask ( bool  success)

Admin functions called from Lua.

int DtLuaScriptInterfaceImpl::luaStartSubtask ( const std::string  taskName,
luabind::object const &  parameters 
)

Global functions that have Lua-specific dependencies.

Subtasking related functions called from Lua Starts a subtask and returns the subtask ID. ID of -1 indicates it failed to start.

void DtLuaScriptInterfaceImpl::luaStopSubtask ( int  subtaskId)

Global functions that have Lua-specific dependencies.

Subtasking related functions called from Lua Starts a subtask and returns the subtask ID. ID of -1 indicates it failed to start.

void DtLuaScriptInterfaceImpl::luaStopAllSubtasks ( )

Stops all subtasks that were started by this task.

bool DtLuaScriptInterfaceImpl::luaIsSubtaskRunning ( int  subtaskId)
Returns
True if this subtask has been started, and has not yet completed.
bool DtLuaScriptInterfaceImpl::luaIsSubtaskComplete ( int  subtaskId)
Returns
True if this subtask has completed running. (not canceled and not complete)
bool DtLuaScriptInterfaceImpl::luaIsSubtaskCanceled ( int  subtaskId)
Returns
True if this subtask has been canceled.
bool DtLuaScriptInterfaceImpl::luaSubtaskResult ( int  subtaskId)
Returns
True if this subtask has completed, and the completion result was success.
int DtLuaScriptInterfaceImpl::luaSendTask ( DtScriptVrfObject object,
const ::std::string  taskName,
luabind::object const &  parameters 
)

Send task to another entity.

int DtLuaScriptInterfaceImpl::luaSendTaskActAsSubtask ( DtScriptVrfObject object,
const ::std::string  taskName,
luabind::object const &  parameters,
bool  actAsSubtask 
)
void DtLuaScriptInterfaceImpl::luaStopAllTasks ( )

Stops all tasks started by this task.

void DtLuaScriptInterfaceImpl::luaSendSetDataToSelf ( const ::std::string  setName,
luabind::object const &  parameters 
)

Send a set-data message to self.

void DtLuaScriptInterfaceImpl::luaSendSetData ( DtScriptVrfObject object,
const ::std::string  setName,
luabind::object const &  parameters 
)

Send a set-data message to another entity.

luabind::object DtLuaScriptInterfaceImpl::luaGetReactionStatus ( )

Provide current reaction status to lua scripts.

std::string DtLuaScriptInterfaceImpl::luaGetScriptId ( )

Provide the current script ID to lua scripts.

luabind::object DtLuaScriptInterfaceImpl::luaGetObjectsNear ( const DtLocation3D loc,
double  distance 
)
luabind::object DtLuaScriptInterfaceImpl::luaGetObjectsNearWithFilter ( const DtLocation3D loc,
double  distance,
luabind::object const &  parameters 
)
luabind::object DtLuaScriptInterfaceImpl::luaGetVrfObjects ( )

Returns a list of all scripted objects.

DtLuaFeatureSet DtLuaScriptInterfaceImpl::luaGetFeaturesWithinArea ( luabind::object const &  points,
luabind::object const &  attributes 
)

Routines to query and return feature sets Returns a feature set which contains all features within the specified geometry containing the specified attributes.

DtLuaFeatureSet DtLuaScriptInterfaceImpl::luaGetFeaturesWithinAreaNoAttributes ( luabind::object const &  points)
DtLuaFeatureSet DtLuaScriptInterfaceImpl::luaGetFeaturesWithinRange ( const DtLocation3D ,
double  range,
luabind::object const &  attributes 
)

Returns a feature set which contains all features within the specified point and box size containing the specified attributes.

The range is in meters. The range will create a bounding box with the point supplied at the center

DtLuaFeatureSet DtLuaScriptInterfaceImpl::luaGetFeaturesWithinRangeNoAttributes ( const DtLocation3D ,
double  range 
)
boost::shared_ptr<DtLuaAsyncJob> DtLuaScriptInterfaceImpl::luaNavigateThroughFeatures ( const luabind::object &  parameters)

Returns an async job object which will produce a path (set of points) from the input points.

The output path object will be altered as to move around the features.

void DtLuaScriptInterfaceImpl::luaSendMessage ( const DtScriptVrfObject receiver,
const std::string &  message 
)
void DtLuaScriptInterfaceImpl::luaDeleteObject ( std::string const &  receiver)
void DtLuaScriptInterfaceImpl::luaDeleteScriptObject ( const DtScriptVrfObject receiver)
static void DtLuaScriptInterfaceImpl::textReportCallback ( const DtVrfObjectMessage m,
void *  usr 
)
static
virtual void DtLuaScriptInterfaceImpl::processTextReport ( const DtVrfObjectMessage m)
virtual
DtScriptVrfObject DtLuaScriptInterfaceImpl::luaCreateEntity ( luabind::object const &  parameters)

Create an entity.

Series of create commands that will use base DtCreateObjectBuilder to create the object and return the created object

DtScriptVrfObject DtLuaScriptInterfaceImpl::luaCreateTacticalGraphic ( luabind::object const &  parameters)

Create a tactical graphic. Must specify name or type.

DtScriptVrfObject DtLuaScriptInterfaceImpl::luaCreateObstacle ( luabind::object const &  parameters)

Create an obstacle.

DtScriptVrfObject DtLuaScriptInterfaceImpl::luaCreateRoute ( luabind::object const &  parameters)

Create a route.

DtScriptVrfObject DtLuaScriptInterfaceImpl::luaCreateArea ( luabind::object const &  parameters)

Create an area.

DtScriptVrfObject DtLuaScriptInterfaceImpl::luaCreateWaypoint ( luabind::object const &  parameters)

Create a waypoint.

DtScriptVrfObject DtLuaScriptInterfaceImpl::luaCreatePhaseLine ( luabind::object const &  parameters)

Creates a phase line.

unsigned DtLuaScriptInterfaceImpl::luaBitwiseOr ( unsigned  val1,
unsigned  val2 
)

Series of bitwise operations

unsigned DtLuaScriptInterfaceImpl::luaBitwiseAnd ( unsigned  val1,
unsigned  val2 
)

Series of bitwise operations

unsigned DtLuaScriptInterfaceImpl::luaBitwiseXor ( unsigned  val1,
unsigned  val2 
)

Series of bitwise operations

unsigned DtLuaScriptInterfaceImpl::luaBitwiseNot ( unsigned  val)

Series of bitwise operations

unsigned DtLuaScriptInterfaceImpl::luaBitwiseLeftShift ( unsigned  val,
unsigned  shift 
)

Series of bitwise operations

unsigned DtLuaScriptInterfaceImpl::luaBitwiseRightShift ( unsigned  val,
unsigned  shift 
)

Series of bitwise operations

virtual bool DtLuaScriptInterfaceImpl::callLuaNoArgFunction ( const std::string &  functionName)
protectedvirtual

Member Data Documentation

lua_State* DtLuaScriptInterfaceImpl::myLState
protected
bool DtLuaScriptInterfaceImpl::myLuaScriptWarningShown
protected
LocalInterfaceExtensions DtLuaScriptInterfaceImpl::myInterfaceExtensions
protected
GlobalInterfaceExtensions DtLuaScriptInterfaceImpl::theLuaInterfaceExtensions
staticprotected

The documentation for this class was generated from the following file:

Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)