VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
luaScriptInterfaceImpl.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 #pragma once
6 
7 #include <vrfLua/vrfLuaDefines.h>
8 #include <vrfLua/luaFeatureSet.h>
9 #include <vrfLua/luaPathJob.h>
10 
13 #include "vrfutil/scriptGeometry.h"
15 #include <luabind/luabind.hpp>
18 #include <vrfutil/objectCounter.h>
19 
20 #include <lua.hpp>
21 #include <lauxlib.h>
22 #include <lualib.h>
23 
24 #include <boost/signals2.hpp>
30 
31 namespace makVrfEvents
32 {
33  class DtEvent;
34  class DtInfluenceEvent;
35 }
36 
38 class DtScriptWeaponInfo;
40 
45 typedef luabind::object (*ReaderWriterToLuaTableFcn)(lua_State* LS, const DtReaderWriter* rwString,
46  const DtSimulationServices* mgr, const DtString& parameterType);
47 
48 const char ContactObservedOnly[] = "observedOnly";
49 const char ContactAliveOnly[] = "aliveOnly";
50 const char ContactHostileOnly[] = "hostileOnly";
51 const char ContactCurrentlyDetectedOnly[] = "currentlyDetectedOnly";
52 
57  : public DtScriptInterface
58 #ifdef DtObjectDebugger_Enable
59  , public DtObjectDebugger<DtLuaScriptInterfaceImpl>
60 #endif
61 {
62 protected:
64 
67 
68 public:
69  virtual ~DtLuaScriptInterfaceImpl() override;
70 
71  static DtScriptInterface* creator(DtSimulationServices*);
72 
73  virtual void init() override;
74 
75  virtual DtString type() const override;
76 
77  virtual bool invokeInit() override;
78  virtual void invokeSuspend() override;
79  virtual bool invokeResume() override;
80  virtual void invokeTick() override;
81  virtual bool invokeCheck() override;
82  virtual void invokeCheckInit() override;
83  virtual void invokeShutdown() override;
84  virtual void invokeUpdateDisplayGraph() override;
85 
88  virtual void invokeDisable() override;
89 
90  virtual bool loadScript(bool reload) override;
91 
92  virtual void setLuaState(lua_State* L);
93  virtual lua_State* getLuaState();
94 
95  virtual std::string dumpLuaStack() const;
96  virtual int luaStackSize() const;
97  virtual void collectGarbage();
98 
99  virtual DtReaderWriter* saveState() override;
100  virtual bool loadState(const DtReaderWriter* loadState) override;
101  virtual void processClearForReuse() override;
102 
107  static void addLuaScriptInterfaceExtension(DtLuaScriptInterfaceExtension::CreatorFcn extension, void* usr);
108 
113  static void addLuaScriptInterfaceExtension(DtLuaScriptInterfaceExtension::CreatorFcn extension,
114  const DtLocalObject* onlyForEntity, void* usr);
115 
117  static void removeLuaScriptInterfaceExtension(DtLuaScriptInterfaceExtension::CreatorFcn extension, void* usr);
118 
121  static void removeLuaScriptInterfaceExtension(DtLuaScriptInterfaceExtension::CreatorFcn extension,
122  const DtLocalObject* onlyForEntity, void* usr);
123 
124  virtual bool initializeVRFLuaExtensions(lua_State* L);
125  virtual bool importTaskParams(lua_State* L);
126 
128  virtual bool importSetParams(lua_State* L);
129 
131  virtual luabind::object createLuaTableFromRegistry(lua_State* L, const DtReaderWriterRegistry& rwRegistry, bool requireMetadata = true, bool hasParamMetaData = true);
134  static luabind::object createLuaTableFromRwRegistry(lua_State* L, const DtReaderWriterRegistry& rwRegistry, DtSimulationServices* simServices);
135 
137  static void addKeyToIgnore(const std::string&);
138 
140  static void removeKeyToIgnore(const std::string&);
141 
143  void luaEndTask(bool success);
144  void luaEndSet();
145 
147 
149 
150  virtual void luaPlayScenarioEvent(DtScriptVrfObject eventName);
151  virtual void luaStopScenarioEvent(DtScriptVrfObject eventName);
152  virtual void luaStopScenarioEventWithRewind(DtScriptVrfObject eventName, bool rewind);
153  virtual bool luaIsScenarioEventPlaying(DtScriptVrfObject eventName);
154  virtual void luaSetScenarioEventEnabled(DtScriptVrfObject eventName, bool);
155  virtual bool luaIsScenarioEventEnabled(DtScriptVrfObject eventName);
157 
159 
160 
164  virtual int taskIdNumber();
166  virtual int luaSendEmbeddedEntityTask(std::string eeName, std::string taskName, luabind::object const& parms);
167  virtual int luaSendEmbeddedEntityTaskActAsSubtask(std::string eeName, std::string taskName,
168  luabind::object const& parms, bool actAsSubtask);
170  virtual int luaSendEmbeddedEntitySet(std::string eeName, std::string setName, luabind::object const& parms);
172 
174 
175  int luaStartSubtask(const std::string taskName, luabind::object const& parameters);
177  void luaStopSubtask(int subtaskId);
179  void luaStopAllSubtasks();
181  bool luaIsSubtaskRunning(int subtaskId);
183  bool luaIsSubtaskComplete(int subtaskId);
185  bool luaIsSubtaskCanceled(int subtaskId);
187  bool luaSubtaskResult(int subtaskId);
191  void luaCleanupInactiveSubtaskStatus();
193 
196  virtual void luaSendChatMessage(const std::string& user, const std::string& channel, int force, const std::string& message);
197  virtual void luaSendChatMessageForceString(const std::string& user, const std::string& channel, const std::string& force, const std::string& message);
198 
200  void luaSendReportWithoutRecipients(const::std::string reportType,
201  luabind::object const& parameters);
202  void luaSendReport(const::std::string reportType,
203  luabind::object const& reciptients,
204  luabind::object const& parameters);
205 
207  int luaSendTask(DtScriptVrfObject& object, const::std::string taskName,
208  luabind::object const& parameters);
209  int luaSendTaskNotAsSubtask(DtScriptVrfObject& object, const::std::string taskName,
210  luabind::object const& parameters);
211  int luaSendTaskActAsSubtask(DtScriptVrfObject& object, const::std::string taskName,
212  luabind::object const& parameters, bool actAsSubtask);
213  int luaSendRadioTask(DtScriptVrfObject& object, const::std::string taskName,
214  luabind::object const& parameters);
215  int luaSendRadioTaskActAsSubtask(DtScriptVrfObject& object, const::std::string taskName,
216  luabind::object const& parameters, bool actAsSubtask);
217  int luaSendTaskActAsSubtaskWithRadio(DtScriptVrfObject& object, const::std::string taskName,
218  luabind::object const& parameters, bool actAsSubtask, bool sendWithRadio);
219 
221  void luaStopAllTasks();
222 
224  void luaSendSetDataToSelf(const::std::string setName,
225  luabind::object const& parameters);
226 
228  void luaSendSetData(DtScriptVrfObject& object, const::std::string setName,
229  luabind::object const& parameters);
230  void luaSendRadioSetData(DtScriptVrfObject& object, const::std::string setName,
231  luabind::object const& parameters);
232  void sendSetDataWithRadio(DtScriptVrfObject& object, const::std::string setName,
233  luabind::object const& parameters, bool useRadio);
234 
235  bool luaIsTaskAvailable(const::std::string taskName);
236  bool luaIsSetAvailable(const::std::string setName);
237 
239  luabind::object luaGetReactionStatus();
240 
249  luabind::object luaGetOrbatList();
250 
252  std::string luaGetScriptId();
253 
255  std::string luaGetSystemName();
256 
257  luabind::object luaGetObjectsNear(const DtLocation3D& loc, double distance);
258  luabind::object luaGetObjectsNearWithFilter(const DtLocation3D& loc, double distance, luabind::object const& parameters);
259 
260  luabind::object luaGetScriptAttribute(const std::string& attributeName, bool& error);
261 
263  luabind::object luaGetVrfObjects();
264 
266 
267  luabind::object luaGetDesignatorsNearWithFilter(const DtLocation3D& loc, double distance,
268  const luabind::object& params);
269 
270  luabind::object luaGetDesignatorsNear(const DtLocation3D& loc, double distance);
272 
274 
275  DtLuaFeatureSet luaGetFeaturesWithinArea(luabind::object const& points, luabind::object const& attributes);
278  DtLuaFeatureSet luaGetFeaturesWithinAreaNoAttributes(luabind::object const& points);
279 
282  DtLuaFeatureSet luaGetFeaturesWithinRange(const DtLocation3D&, double range, luabind::object const& attributes);
284  DtLuaFeatureSet luaGetFeaturesWithinRangeNoAttributes(const DtLocation3D&, double range);
285 
287  DtLuaFeatureSet luaGetFeaturesType(const std::string& type);
289  DtLuaFeatureSet luaGetFeatures();
291 
293 
294  DtLuaFeatureGeometry luaMakePointGeometry(const DtLocation3D&);
297  DtLuaFeatureGeometry luaMakePathGeometry(luabind::object const& table);
299  DtLuaFeatureGeometry luaMakeAreaGeometry(luabind::object const& table);
301 
303  std::shared_ptr<DtLuaAsyncJob> generateRandomPoints(const luabind::object& parameters);
304 
306  std::shared_ptr<DtLuaAsyncJob> findNearbyPointOfInterest(const int type);
307 
309  std::shared_ptr<DtLuaAsyncJob> findCoverPoint(
310  const DtLocation3D& startLocation, const DtLocation3D& threatLocation,
311  double threatRadius, double distanceFromThreat, double range, unsigned numberOfPoints);
312 
314  luabind::object findLadders(lua_State* L, const DtLocation3D& startLocation, double range);
316  luabind::object findLaddersWithId(lua_State* L, const DtLocation3D& startLocation,
317  double range, const unsigned int id);
318 
320  std::shared_ptr<DtLuaAsyncJob> findPathToLocation(
321  const DtLocation3D& startLocation, const DtLocation3D& destinationLocation,
322  bool useAbstractGraphs, const DtLocation3D& avoidLocation, double avoidanceRadius);
323  std::shared_ptr<DtLuaAsyncJob> findPathToLocationWithParameters(const DtLocation3D& startLocation,
324  const DtLocation3D& destinationLocation, const luabind::object& parameters);
325 
326  std::shared_ptr<DtLuaAsyncJob> findPathToLocationWithParameterObject(const DtLocation3D& startLocation,
327  const DtLocation3D& destinationLocation, DtLuaNavFindPathParameters& parameters);
328 
331  std::shared_ptr<DtLuaAsyncJob> placeFormation(const luabind::object& parameters);
332  std::shared_ptr<DtLuaAsyncJob> placeFormationWithWidth(const luabind::object& parameters,
333  double entityWidth);
334 
340  luabind::object findNavSectors(lua_State* L, const DtLocation3D& location);
341 
343  DtTranslatableStream translateStringFromScript(const std::string& format);
344 
347  std::shared_ptr<DtLuaAsyncJob> luaNavigateThroughFeatures(const luabind::object& parameters);
348 
351  virtual std::shared_ptr<DtLuaAsyncJob> luaFindHighPoints(const luabind::object& corners, unsigned int nPoints);
352  virtual std::shared_ptr<DtLuaAsyncJob> luaFindHighPointsDebug(const luabind::object& corners, unsigned int nPoints, bool bDebug);
354 
356  /*
357  job = vrf:luaFindSinglePosition(taskParameters.targetArea:getLocations3D(),
358  taskParameters.battlePosition,
359  targetHeightMeters, -- 2/3 vehicle height, for example.
360  double viewHeightMeters, -- 2/3 vehicle height, for example.
361  double hideHeightMeters, -- 1.1x vehicle height, for example.
362  double forwardBackSearchLimitMeters, -- 50m forward + 50m backward = 100m
363  double forwardBackSearchIntervalMeters, -- half vehicle length, for example.
364  double maxSlopeDegrees, -- *todo add comments*
365  )
366  )
367 
368  */
369  virtual std::shared_ptr<DtLuaAsyncJob> luaFindSinglePosition(
370  const luabind::object& targetAreaCorners,
371  const DtLocation3D& pivotPoint,
372  double targetHeightMeters,
373  double viewHeightMeters,
374  double hideHeightMeters,
375  double forwardBackSearchLimitMeters,
376  double forwardBackSearchIntervalMeters,
377  double maxSlopeDegrees);
378 
380  /*
381  job = vrf:luaFindSinglePosition(taskParameters.targetArea:getLocations3D(),
382  taskParameters.battlePosition,
383  targetHeightMeters, -- 2/3 vehicle height, for example.
384  double viewHeightMeters, -- 2/3 vehicle height, for example.
385  double hideHeightMeters, -- 1.1x vehicle height, for example.
386  double forwardBackSearchLimitMeters, -- 50m forward + 50m backward = 100m
387  double forwardBackSearchIntervalMeters, -- half vehicle length, for example.
388  double maxSlopeDegrees, -- *todo add comments*
389  bool bDebug -- Log additional information)
390  )
391  */
392  virtual std::shared_ptr<DtLuaAsyncJob> luaFindSinglePositionDebug(
393  const luabind::object& targetAreaCorners,
394  const DtLocation3D& pivotPoint,
395  double targetHeightMeters,
396  double viewHeightMeters,
397  double hideHeightMeters,
398  double forwardBackSearchLimitMeters,
399  double forwardBackSearchIntervalMeters,
400  double maxSlopeDegrees,
401  bool bDebug);
402 
403 
405  /*
406  job = vrf:findVehicleFightingPositions(taskParameters.numberOfPoints,
407  taskParameters.targetArea:getLocations3D(),
408  taskParameters.battlePosition,
409  maxVolume, -- half dimensions of hide position
410  maxVolume:getUp() * 0.67, --67% of total height for shooting height
411  maxVolume:getUp() * 0.50, -- half height for target height
412  searchWidthForward, -- how much forward and back to search forward and back
413  searchWidthSide -- how much side to side to search
414  positionSpacing -- how many meters between positions, side to side
415  )
416  */
417  virtual std::shared_ptr<DtLuaAsyncJob> luaFindVehicleFightingPositions(
418  unsigned int nPositionPairs,
419  const luabind::object& targetAreaCorners,
420  const DtLocation3D& originPoint,
421  const DtVectorOffset3D& hideVolume,
422  double shootHeight,
423  double targetHeight,
424  double forwardBackSearchLimit,
425  double sideSideSearchLimit,
426  double maxSlopeDegrees,
427  double positionSpacing);
428 
430  virtual std::shared_ptr<DtLuaAsyncJob> luaFindVehicleFightingPositionsDebug(
431  unsigned int nPositionPairs,
432  const luabind::object& targetAreaCorners,
433  const DtLocation3D& originPoint,
434  const DtVectorOffset3D& hideVolume,
435  double shootHeight,
436  double targetHeight,
437  double forwardBackSearchLimit,
438  double sideSideSearchLimit,
439  double maxSlopeDegrees,
440  double positionSpacing,
441  bool useDebug);
442 
443  virtual std::shared_ptr<DtLuaAsyncJob> luaFindPositionGroupsInAreaHilltop(
444  unsigned int nPositionPairsPerGroup,
445  const luabind::object& searchAreaVertices,
446  const luabind::object& targetsAreaVertices,
447  double viewHeightMeters,
448  double coverHeightMeters,
449  unsigned int forwardBackRangeMeters,
450  unsigned int sideSideRangeMeters,
451  unsigned int searchIntervalMeters,
452  double maxSlopeDegrees,
453  unsigned int positionsLateralSpacingMeters);
454 
455  virtual std::shared_ptr<DtLuaAsyncJob> luaFindPositionGroupsInAreaHilltopDebug(
456  unsigned int nPositionPairsPerGroup,
457  const luabind::object& searchAreaVertices,
458  const luabind::object& targetsAreaVertices,
459  double viewHeightMeters,
460  double coverHeightMeters,
461  unsigned int forwardBackRangeMeters,
462  unsigned int sideSideRangeMeters,
463  unsigned int searchIntervalMeters,
464  double maxSlopeDegrees,
465  unsigned int positionsLateralSpacingMeters,
466  bool useDebug);
467 
468  virtual std::shared_ptr<DtLuaAsyncJob> luaFindPositionGroupsInAreaRidge(
469  unsigned int nPositionPairsPerGroup,
470  const luabind::object& searchAreaVertices,
471  const luabind::object& targetsAreaVertices,
472  unsigned int targetsAreaSampleRate,
473  const luabind::object& tableOfDoubles
474  );
475 
476  virtual std::shared_ptr<DtLuaAsyncJob> luaFindPositionGroupsInAreaRidgeDebug(
477  unsigned int nPositionPairsPerGroup,
478  const luabind::object& searchAreaVertices,
479  const luabind::object& targetsAreaVertices,
480  unsigned int targetsAreaSampleRate,
481  const luabind::object& tableOfDoubles
482  , bool useDebug);
483 
486  std::shared_ptr<DtLuaAsyncJob> getAllEmbarkationSlots(DtScriptVrfObject& object);
487 
490  std::shared_ptr<DtLuaAsyncJob> getEmbarkationSlots(DtScriptVrfObject& object);
491 
493  std::shared_ptr<DtLuaAsyncJob> getEmbarkationSlotsFiltered(DtScriptVrfObject& object,
494  bool bAllSlots);
495 
497  std::shared_ptr<DtLuaAsyncJob> reserveEmbarkationSlot(DtScriptVrfObject& object, int slotNumber);
498 
500  std::shared_ptr<DtLuaAsyncJob> getEmbarkationEgressPoints(DtScriptVrfObject& object);
501 
502  void luaSendMessage(const DtScriptVrfObject& receiver, const std::string& message);
503  void luaSendRadioMessage(const DtScriptVrfObject& receiver, const std::string& message);
504  void luaSendRadioMessageToUuid(const std::string& uuid, const std::string& message);
505  void luaDeleteObject(std::string const& receiver);
506  void luaDeleteScriptObject(const DtScriptVrfObject& receiver);
507  void luaSetInterest(const DtLocation3D& location, double range);
508 
509  void luaSendObjectMessage(const DtScriptVrfObject& receiver, const std::string& messageType, const luabind::object& messageContents);
510  void luaSendRadioObjectMessage(const DtScriptVrfObject& receiver, const std::string& messageType, const luabind::object& messageContents);
511  void luaRegisterForObjectMessage(const std::string& messageType);
512  void luaUnregisterForObjectMessage(const std::string& messageType);
513  void processObjectMessage(const DtVrfObjectMessage* msg);
514 
515  static void textReportCallback(const DtVrfObjectMessage* m, void* usr);
516  virtual void queueTextReport(const DtVrfObjectMessage* m);
517  virtual void processTextReport(const DtVrfObjectMessage* m);
518 
519  void luaSendInfluence(const DtScriptVrfObject& target,
520  const std::string& influenceName, luabind::object const& influenceParams);
521 
523  static void addReaderWriterToLuaTableFunction(const DtString&, ReaderWriterToLuaTableFcn);
524 
525  static void influenceEventCallback(std::shared_ptr<const makVrfEvents::DtInfluenceEvent> event, void* usr);
526  virtual void queueInfluence(std::shared_ptr<const makVrfEvents::DtInfluenceEvent> e);
527  virtual void processInfluence(std::shared_ptr<const makVrfEvents::DtInfluenceEvent> e);
528 
530  virtual void processEntityDestroyed() override;
531 
533  luabind::object luaGetCloudLayerDescriptionsAt(lua_State *L, const DtLocation3D& location);
536 
539 
540  virtual double luaGetIllumination(DtScriptVrfObject& object);
541  virtual double luaGetExpectedIllumination(DtScriptVrfObject& object, double dateAndTimeOfDay);
542  virtual double luaGetSnowAccumulationByLocation(const DtLocation3D& object);
543  virtual double luaGetSnowRoadAccumulationByLocation(const DtLocation3D& object);
544  virtual double luaGetRainAccumulationByLocation(const DtLocation3D& object);
545 
546  virtual double luaGetAirTemperatureByLocation(const DtLocation3D& object);
547  virtual double luaGetAirPressureByLocation(const DtLocation3D& object);
548  virtual unsigned int luaGetPrecipitationByLocation(const DtLocation3D& location, double*);
549  virtual double luaGetPrecipitationIntensityByLocation(const DtLocation3D& object);
550  virtual unsigned int luaGetPrecipitationTypeByLocation(const DtLocation3D& object);
551  virtual double luaGetVisibilityDistanceByLocation(const DtLocation3D& object);
552  virtual int luaGetVisibilityObscurantByLocation(const DtLocation3D& object);
553  virtual double luaGetWindDirectionByLocation(const DtLocation3D& object);
554  virtual double luaGetWindSpeedByLocation(const DtLocation3D& object);
555  virtual double luaGetUnderwaterVisibilityByLocation(const DtLocation3D& object);
556  virtual unsigned int luaGetSwellStateByLocation(const DtLocation3D& object);
557  virtual double luaGetSwellStateDirectionByLocation(const DtLocation3D& object);
558  virtual unsigned int luaGetSeaStateByLocation(const DtLocation3D& object);
559  virtual double luaGetSeaStateDirectionByLocation(const DtLocation3D& object);
560  virtual double luaGetSurgeDepthByLocation(const DtLocation3D& object);
561  virtual double luaGetIlluminationByLocation(const DtLocation3D& object);
562  virtual double luaGetExpectedIlluminationByLocation(const DtLocation3D& object, double dateAndTimeOfDay);
564 
567  virtual double luaRunDurationTime();
568  virtual void luaRunForDuration(double);
569  virtual void luaStopSimulationDurationTimer();
571 
574  virtual void luaSetCheckpointMode(bool);
575  virtual void initializeCheckpointStateTable(lua_State* L);
576 
585  virtual int luaAskUserQuestion(const DtTranslatableStream& title, const DtTranslatableStream& message,
586  luabind::object const& options, int displayFlags);
587  virtual int luaAskUserQuestionST(const std::string& title, const DtTranslatableStream& message,
588  luabind::object const& options, int displayFlags);
589  virtual int luaAskUserQuestionTS(const DtTranslatableStream& title, const std::string& message,
590  luabind::object const& options, int displayFlags);
591  virtual int luaAskUserQuestionSS(const std::string& title, const std::string& message,
592  luabind::object const& options, int displayFlags);
593 
597  virtual int luaStatusOfUserQuestion(int questionId);
598 
600  virtual void luaCancelUserQuestion(int questionId);
601 
605 
607  DtScriptVrfObject luaCreateEntity(luabind::object const& parameters);
608  void luaCreateEntityParallel(luabind::object const& parameters);
609 
611  DtScriptVrfObject luaCreateFromOrbat(std::string orbatItem, const DtLocation3D& loc);
612 
614  DtScriptVrfObject luaCreateTacticalGraphic(luabind::object const& parameters);
615 
617  DtScriptVrfObject luaCreateObstacle(luabind::object const& parameters);
618 
620  DtScriptVrfObject luaCreateRoute(luabind::object const& parameters);
621 
623  DtScriptVrfObject luaCreateArea(luabind::object const& parameters);
624 
626  DtScriptVrfObject luaCreateWaypoint(luabind::object const& parameters);
627 
629  DtScriptVrfObject luaCreatePhaseLine(luabind::object const& parameters);
631 
638  std::vector<DtLocation3D> luaMakeOffsetPoints(
639  luabind::object const& fromPoints,
640  const DtVectorOffset3D& offset);
641  std::vector<DtLocation3D> luaMakeOffsetPointsWithRadius(luabind::object const& fromPoints,
642  const DtVectorOffset3D& offset, const double minimumTurnRadius);
643 
645  void luaCreateSelectionGroup(const std::string& name, luabind::object const& parameters);
646 
650  void luaFinishTest(const int status, const std::string message);
651 
653  bool luaUpdateTaskVisualization(const std::string& visualizationName,
654  const std::string& visualizationType, luabind::object const& parameters);
655 
657  void luaDeleteTaskVisualization(const std::string& visualizationName);
658 
660  void luaRequire(lua_State* L, const std::string& filename);
661 
664  unsigned luaBitwiseOr(unsigned val1, unsigned val2);
665  unsigned luaBitwiseAnd(unsigned val1, unsigned val2);
666  unsigned luaBitwiseXor(unsigned val1, unsigned val2);
667  unsigned luaBitwiseNot(unsigned val);
668  unsigned luaBitwiseLeftShift(unsigned val, unsigned shift);
669  unsigned luaBitwiseRightShift(unsigned val, unsigned shift);
671 
672  bool luaIntersectSegments2D(const DtLocation3D& p1, const DtLocation3D& p2,
673  const DtLocation3D& p3, const DtLocation3D& p4,
674  DtLocation3D& intersectPoint);
675 
677  virtual bool luaIsDatabaseLoggingEnabled();
678 
680  virtual void luaLogEventToDatabase(unsigned eventType, luabind::object const& parameters);
681 
686  {
687  public:
688  DtLuaScriptFunctionReference(const std::string& functionName)
690  , myFunctionName(functionName)
691  {
692 
693  }
694 
695  virtual ~DtLuaScriptFunctionReference() override {
696 
697  }
698 
699  std::string functionName() const
700  {
701  return myFunctionName;
702  }
703 
704  virtual bool operator<(const DtScriptFunctionReference& other) const override
705  {
706  try
707  {
708  const DtLuaScriptFunctionReference& rhs =
709  dynamic_cast<const DtLuaScriptFunctionReference&>(other);
710  return myFunctionName.compare(rhs.myFunctionName) < 0;
711  }
712  catch(...)
713  {
714  DtInfo << "DtLuaScriptFunctionReference::operator< attempt to compare with wrong type.\n";
715  return false;
716  }
717  }
718 
719  protected:
720  std::string myFunctionName;
721  };
722 
725  virtual void addPostSetDataCallback(const std::string& setDataType,
726  const std::string& functionName);
729  virtual void removePostSetDataCallback(const std::string& setDataType,
730  const std::string& functionName);
731 
734  virtual void invokePostSetDataCallback(
735  DtScriptFunctionReferencePtr functionReference,
736  DtSetDataRequestMessage* setDatRequest) override;
737 
743  virtual luabind::object luaGetParamPropertyFromType(
744  const std::string typeString, std::string const& paramName);
745 
746  virtual luabind::object luaGetApplicationSetting(
747  const std::string settingName);
748 
750  virtual void putObjectsFromTableIntoGlobalTable(lua_State* state, luabind::object& table);
751  virtual void putObjectsFromGlobalTableIntoTable(lua_State* state, luabind::object& table);
752 
754  virtual luabind::object luaGetSubordinateFunctionNames();
755 
757  virtual luabind::object luaGetParameterSubordinateFunctionsFromType(
758  const std::string typeString);
759 
760  virtual void connectForCallbacks();
761  virtual void processEvents();
762 
764  std::shared_ptr<DtLuaAsyncJob> luaGetWeaponSystemsInfo(DtScriptVrfObject& object);
765 
766 protected:
770  virtual bool callLuaNoArgFunction(const std::string& functionName, bool* functionExists = nullptr);
771 
772  virtual void updateFuncCallCount();
773 
774  lua_State* myLState;
775  unsigned myFuncCallCount;
777 
778  typedef std::vector<DtLuaScriptInterfaceExtension*> LocalInterfaceExtensions;
780 
782  {
783  LuaExtension() : creator(nullptr), onlyForEntity(nullptr), usr(nullptr) {};
784  LuaExtension(const LuaExtension& orig) : creator(orig.creator), onlyForEntity(orig.onlyForEntity),
785  usr(orig.usr) {};
786 
789  void* usr;
790  };
791 
792  typedef std::vector<LuaExtension> GlobalInterfaceExtensions;
793 
795 
796  luabind::object myCheckpointStateTable;
797 
798  typedef std::map<DtString, ReaderWriterToLuaTableFcn> ReaderWriterToLuaTableMap;
801 
802  std::vector<DtVrfObjectMessage*> myTextReportCallbacks;
803  std::vector<std::shared_ptr<const makVrfEvents::DtInfluenceEvent> > myInfluenceEvents;
804 
805  bool myNeedsInvokeShutdown = true;
806 };
807 
809 
817 namespace luaScriptInterface
818 {
819  typedef luabind::object (*rwToLuaBindObjectFcn)(
820  const DtReaderWriter* rw, lua_State* L);
821 
822  luabind::object luaGetEntityParam(lua_State* L,
823  const DtScriptVrfObject& entity, std::string const& paramName);
824 
825  luabind::object luaGetSystemAttribute(
826  const DtScriptComponentSystem& system, const std::string& attributeName
827  , bool *error
828  , lua_State *L
829  );
830 
832  luabind::object luaGetContactInfo(lua_State* L, const DtScriptOwnshipObject& thisEntity,
833  const DtScriptVrfObject& otherEntity);
834 
838  luabind::object luaGetSubordinateFormation(lua_State* L,
839  const DtScriptOwnshipObject& entity,
840  DtScriptVrfObject& leadSubordinate);
841 
849  std::list<DtVectorOffset3D> luaGetOptionFormationPositions(lua_State* L,
850  const DtScriptVrfObject& unit,
851  const std::string& formationName, luabind::object const& options,
852  int* leaderIndex);
853 
855  std::list<DtVectorOffset3D> luaGetFormationPositions(lua_State* L,
856  const DtScriptVrfObject& unit,
857  const std::string& formationName,
858  int* leaderIndex);
859 
862  luabind::object luaGetParameterSubordinateFunctions(lua_State* L, const DtScriptVrfObject& entity);
863 
865  luabind::object luaGetSubordinateFunctions(lua_State* L, const DtScriptVrfObject& entity);
866 
870  bool luaSetSubordinateFunctions(lua_State* L, const DtScriptVrfObject& entity, luabind::object const& subsAndFunctions);
871 
873  std::string luaGetSubordinateFunction(lua_State* L, const DtScriptVrfObject& entity, const DtScriptVrfObject& subEntity);
874 
878  bool luaSetSubordinateFunction(lua_State* L, const DtScriptVrfObject& entity, const DtScriptVrfObject& subEntity, const std::string& subFunction);
879 
881  luabind::object luaGetAisData(lua_State* L, const DtScriptVrfObject& entity);
882 
884  luabind::object luaGetIffSystem(lua_State* L, const DtScriptVrfObject& entity);
885 
887  luabind::object luaGetIffModeData(lua_State* L, const DtScriptVrfObject& entity, const DtModeType mode);
888  void getMode1Data(lua_State* L, luabind::object& result, const DtIffMode1Settings* settings);
889  void getMode2Data(lua_State* L, luabind::object& result, const DtIffMode2Settings* settings);
890  void getMode3AData(lua_State* L, luabind::object& result, const DtIffMode3ASettings* settings);
891  void getMode3CData(lua_State* L, luabind::object& result, const DtIffMode3CSettings* settings);
892  void getMode5Data(lua_State* L, luabind::object& result, const DtIffMode5Settings* settings);
893  void getModeSData(lua_State* L, luabind::object& result, const DtIffModeSSettings* settings);
894  void getTCASData(lua_State* L, luabind::object& result, const DtIffTCASDataSettings* settings);
895 
897  bool luaGetIffModeIsOn(lua_State* L, const DtScriptVrfObject& entity, const DtModeType mode);
898 
899 
900 
902  luabind::object luaGetTargetPriorityList(lua_State* L, const DtScriptOwnshipObject& thisEntity);
903 
911  std::list<DtScriptVrfObject> luaGetContactsWithFilter(
912  lua_State* L, const DtScriptOwnshipObject& entity,
913  luabind::object const& typeFilters, bool observedOnly);
916  std::list<DtScriptVrfObject> luaGetContactsWithFilterAliveOnly(
917  lua_State* L, const DtScriptOwnshipObject& entity,
918  luabind::object const& typeFilters, bool observedOnly,
919  bool aliveOnly);
920 
923  std::list<DtScriptVrfObject> luaGetHostileContactsWithFilterAliveOnly(
924  lua_State* L, const DtScriptOwnshipObject& entity,
925  luabind::object const& typeFilters, bool observedOnly,
926  bool aliveOnly);
927 
932  std::list<DtScriptVrfObject> luaGetContacts(
933  lua_State* L, const DtScriptOwnshipObject& entity,
934  luabind::object const& typeFilters,
935  luabind::object const& flags);
936 
937  std::vector<DtScriptVrfObject> luaGetAllHostileContacts(
938  lua_State* L, const DtScriptOwnshipObject& entity,
939  luabind::object const& options);
940 
943  luabind::object luaGetWeaponInfoList(lua_State* L, const DtScriptOwnshipObject& thisEntity);
944 
945  luabind::object luaGetWeaponInfo(lua_State* L, const DtScriptOwnshipObject& thisEntity, const std::string& weaponId);
946 
950  bool luaSetStateProperty(lua_State* L, DtScriptOwnshipObject& entity,
951  const std::string& propertyName, luabind::object const& prop);
952 
957  bool luaSetOrAddStateProperty(lua_State* L, DtScriptOwnshipObject& entity,
958  const std::string& propertyName, luabind::object const& prop, bool addIfNotFound);
959 
967  bool luaSetStatePropertyListItem(lua_State* L,
968  DtScriptOwnshipObject& entity, const std::string& propertyName,
969  luabind::object const& keyValues, luabind::object const& itemValue);
970 
978  lua_State* L, DtScriptOwnshipObject& entity, const std::string& propertyName,
979  int index, luabind::object const& itemValue);
980 
988  bool luaSetStatePropertyMapItem(lua_State* L,
989  DtScriptOwnshipObject& entity, const std::string& propertyName,
990  luabind::object const& keyValue, luabind::object const& itemValue);
991 
994  bool luaSetInternalStateProperty(lua_State* L, DtScriptOwnshipObject& entity,
995  const std::string& context, const std::string& propertyName, luabind::object const& prop);
996 
1000  bool luaSetOrAddInternalStateProperty(lua_State* L, DtScriptOwnshipObject& entity,
1001  const std::string& context, const std::string& propertyName, luabind::object const& prop, bool addIfNotFound);
1002 
1010  const std::string& context, const std::string& propertyName,
1011  luabind::object const& keyValues, luabind::object const& itemValue);
1012 
1019  const std::string& context, const std::string& propertyName,
1020  int index, luabind::object const& itemValue);
1021 
1028  bool luaSetInternalStatePropertyMapItem(lua_State* L, DtScriptOwnshipObject& entity,
1029  const std::string& context, const std::string& propertyName,
1030  luabind::object const& keyValue, luabind::object const& itemValue);
1031 
1037  luabind::object luaGetStateProperty(lua_State* L,
1038  const DtScriptVrfObject& entity, const std::string& propertyName);
1039  luabind::object luaGetStateOwnshipProperty(lua_State* L,
1040  const DtScriptOwnshipObject& entity, const std::string& propertyName);
1041 
1051  luabind::object luaGetStatePropertyListItem(lua_State* L,
1052  const DtScriptVrfObject& entity, const std::string& propertyName,
1053  luabind::object const& keyValues, int& index);
1054  luabind::object luaGetStateOwnshipPropertyListItem(lua_State* L,
1055  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1056  luabind::object const& keyValues, int& index);
1057 
1066  luabind::object luaGetStatePropertyListItemByIndex(lua_State* L,
1067  const DtScriptVrfObject& entity, const std::string& propertyName,
1068  int index);
1069  luabind::object luaGetStateOwnshipPropertyListItemByIndex(lua_State* L,
1070  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1071  int index);
1072 
1081  luabind::object luaGetStatePropertyMapItem(lua_State* L,
1082  const DtScriptVrfObject& entity, const std::string& propertyName,
1083  luabind::object const& keyValue);
1084  luabind::object luaGetStateOwnshipPropertyMapItem(lua_State* L,
1085  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1086  luabind::object const& keyValue);
1087 
1092  luabind::object luaGetInternalStateProperty(lua_State* L, const DtScriptOwnshipObject& entity,
1093  const std::string& context, const std::string& propertyName);
1094 
1103  luabind::object luaGetInternalStatePropertyListItem(lua_State* L, const DtScriptOwnshipObject& entity,
1104  const std::string& context, const std::string& propertyName,
1105  luabind::object const& keyValues, int& index);
1106 
1114  luabind::object luaGetInternalStatePropertyListItemByIndex(lua_State* L, const DtScriptOwnshipObject& entity,
1115  const std::string& context, const std::string& propertyName, int index);
1116 
1124  luabind::object luaGetInternalStatePropertyMapItem(lua_State* L, const DtScriptOwnshipObject& entity,
1125  const std::string& context, const std::string& propertyName, luabind::object const& keyValue);
1126 
1131  luabind::object luaGetParamProperty(lua_State* L,
1132  const DtScriptVrfObject& entity, std::string const& paramName);
1133  luabind::object luaGetOwnshipParamProperty(lua_State* L,
1134  const DtScriptOwnshipObject& entity, std::string const& paramName);
1135 
1144  luabind::object luaGetParameterPropertyListItem(lua_State* L,
1145  const DtScriptVrfObject& entity, const std::string& propertyName,
1146  luabind::object const& keyValues, int& index);
1147  luabind::object luaGetOwnshipParameterPropertyListItem(lua_State* L,
1148  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1149  luabind::object const& keyValues, int& index);
1150 
1158  luabind::object luaGetParameterPropertyListItemByIndex(lua_State* L,
1159  const DtScriptVrfObject& entity, const std::string& propertyName,
1160  int index);
1161  luabind::object luaGetOwnshipParameterPropertyListItemByIndex(lua_State* L,
1162  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1163  int index);
1164 
1172  luabind::object luaGetParameterPropertyMapItem(lua_State* L,
1173  const DtScriptVrfObject& entity, const std::string& propertyName,
1174  luabind::object const& keyValue);
1175  luabind::object luaGetOwnshipParameterPropertyMapItem(lua_State* L,
1176  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1177  luabind::object const& keyValue);
1178 
1179  bool luaSetSystemAttribute(
1180  DtScriptComponentSystem& system, const std::string& attributeName,
1181  const luabind::object & value,
1182  lua_State *L);
1183 
1184  static const std::map<DtString, rwToLuaBindObjectFcn>& rwToLuaBindObjectMap();
1185 };
virtual void invokePostSetDataCallback(DtScriptFunctionReferencePtr functionReference, DtSetDataRequestMessage *setDatRequest)=0
Implement to invoke the function referenced by functionReference. setDatRequest contains the informat...
virtual void processEntityDestroyed()
Can be overridden to perform some processing when the entity is destroyed.
Definition: scriptInterface.h:200
General settings that apply to all modes.
Definition: iffMode5Settings.h:12
std::vector< DtVrfObjectMessage * > myTextReportCallbacks
Definition: luaScriptInterfaceImpl.h:802
virtual bool operator<(const DtScriptFunctionReference &other) const override
Required for std::set.
Definition: luaScriptInterfaceImpl.h:704
virtual void addPostSetDataCallback(const DtSetMessageType &setDataType, DtScriptFunctionReferencePtr functionReference)
Adds a callback to be invoked after the specified type of set data request is executed.
virtual bool invokeInit()=0
luabind::object luaGetParameterPropertyListItemByIndex(lua_State *L, const DtScriptVrfObject &entity, const std::string &propertyName, int index)
Returns an object containing the value of the of an item in the given parameter property. The property must be a list. Returns the item at the given index, using the Lua convention that the first item is at index 1. The result may be a table containing a number of fields that make up the item, or a single value, depending on the data type of the list items. If the property or list item could not be found, the returned table will be empty.
bool luaSetInternalStateProperty(lua_State *L, DtScriptOwnshipObject &entity, const std::string &context, const std::string &propertyName, luabind::object const &prop)
Sets the specified internal state property with the given value. If the property does not exist or th...
std::list< DtScriptVrfObject > luaGetContactsWithFilterAliveOnly(lua_State *L, const DtScriptOwnshipObject &entity, luabind::object const &typeFilters, bool observedOnly, bool aliveOnly)
Same as luaGetContactsWithFiler but adds a boolean flag to indicate that only non-destroyed entities ...
This class is a wrapper for a DtCompSystem for use by scripts. It derives from DtAsciiSerializable so...
Definition: scriptWeaponInfo.h:22
luabind::object luaGetParamProperty(lua_State *L, const DtScriptVrfObject &entity, std::string const &paramName)
Returns an object containing the value of the requested parameter property. May be a table containing...
const char ContactObservedOnly[]
Definition: luaScriptInterfaceImpl.h:48
void getMode1Data(lua_State *L, luabind::object &result, const DtIffMode1Settings *settings)
luabind::object luaGetSubordinateFunctions(lua_State *L, const DtScriptVrfObject &entity)
Return a table of {{&quot;subordinate&quot; = DtScriptVrfObject, &quot;function&quot; = string}}.
std::vector< DtScriptVrfObject > luaGetAllHostileContacts(lua_State *L, const DtScriptOwnshipObject &entity, luabind::object const &options)
static GlobalInterfaceExtensions theLuaInterfaceExtensions
Definition: luaScriptInterfaceImpl.h:794
std::vector< LuaExtension > GlobalInterfaceExtensions
Definition: luaScriptInterfaceImpl.h:792
lua_State * myLState
Definition: luaScriptInterfaceImpl.h:774
virtual bool invokeResume()=0
Definition: iffBasicModeSettings.h:84
luabind::object luaGetStateOwnshipPropertyListItemByIndex(lua_State *L, const DtScriptOwnshipObject &entity, const std::string &propertyName, int index)
virtual bool loadState(const DtReaderWriter *savedState)=0
Called when the scenario is loaded. The load state pointer may not be valid, which does not indicate ...
bool luaSetSubordinateFunctions(lua_State *L, const DtScriptVrfObject &entity, luabind::object const &subsAndFunctions)
Given a table of {{&quot;subordinate&quot; = DtScriptVrfObject, &quot;function&quot; = string}} Set the state propert...
luabind::object luaGetStateOwnshipPropertyMapItem(lua_State *L, const DtScriptOwnshipObject &entity, const std::string &propertyName, luabind::object const &keyValue)
unsigned myFuncCallCount
Definition: luaScriptInterfaceImpl.h:775
luabind::object luaGetSubordinateFormation(lua_State *L, const DtScriptOwnshipObject &entity, DtScriptVrfObject &leadSubordinate)
Gets a table indexed by simObject (subordinates) of position offset relative to the formation leader...
virtual void invokeCheckInit()=0
Definition: luaNavJob.h:319
luabind::object luaGetParameterPropertyListItem(lua_State *L, const DtScriptVrfObject &entity, const std::string &propertyName, luabind::object const &keyValues, int &index)
Returns an object containing the value of the of an item in the given parameter property. The property must be a list. The item returned will have values matching the specified key values in the key fields. The result may be a table containing a number of fields that make up the item, or a single value, depending on the data type of the list items. If the property or list item could not be found, the returned table will be empty. Sets index to be the index of the item, using the Lua convention that the first item is at index 1.
Definition: readerWriter.h:85
void getMode2Data(lua_State *L, luabind::object &result, const DtIffMode2Settings *settings)
#define DT_DEFINE_OBJECT_DEBUGGER_NAME(type)
Definition: objectCounter.h:31
Default on in debug, off in release.
Definition: objectCounter.h:27
luabind::object(* ReaderWriterToLuaTableFcn)(lua_State *LS, const DtReaderWriter *rwString, const DtSimulationServices *mgr, const DtString &parameterType)
When adding decoder functions to turn reader/writer into lua tables, the format must be of the follow...
Definition: luaScriptInterfaceImpl.h:45
bool luaSetStatePropertyListItemByIndex(lua_State *L, DtScriptOwnshipObject &entity, const std::string &propertyName, int index, luabind::object const &itemValue)
Finds the item in the list at the specified index and updates it to the new value. If the list is not long enough, new entries are added. Any items added in this way will be given the same value as the new entry. If the property does not exist or the format of the data is incorrect, returns false. Will try to find the state property in both internal and external properties.
virtual void removePostSetDataCallback(const DtSetMessageType &setDataType, DtScriptFunctionReferencePtr functionReference)
Remove a callback invoked after the specified type of set data request is executed.
Definition: readerWriterRegistry.h:39
virtual DtReaderWriter * saveState()=0
Called when the scenario is saved. The stateState pointer may not be valid, in which case something w...
luabind::object luaGetStatePropertyListItemByIndex(lua_State *L, const DtScriptVrfObject &entity, const std::string &propertyName, int index)
Returns an object containing the value of the of an item in the given state property. The state property must be a list. Returns the item at the given index, using the Lua convention that the first item is at index 1. The result may be a table containing a number of fields that make up the item, or a single value, depending on the data type of the list items. Will try to find the state property in both internal and external properties. If the property or list item could not be found, the returned table will be empty.
luabind::object luaGetInternalStatePropertyMapItem(lua_State *L, const DtScriptOwnshipObject &entity, const std::string &context, const std::string &propertyName, luabind::object const &keyValue)
Returns an object containing the value of the of an item in the given internal state property...
General settings that apply to all modes.
Definition: iffTCASDataSettings.h:12
bool luaSetInternalStatePropertyMapItem(lua_State *L, DtScriptOwnshipObject &entity, const std::string &context, const std::string &propertyName, luabind::object const &keyValue, luabind::object const &itemValue)
Sets a single item in na internal map state property to the given value. First looks in the map to se...
LocalInterfaceExtensions myInterfaceExtensions
Definition: luaScriptInterfaceImpl.h:779
virtual bool loadScript(bool reload=false)=0
This will be called by the parent to let the interface know when to load the script.
bool myLuaScriptWarningShown
Definition: luaScriptInterfaceImpl.h:776
Definition: iffBasicModeSettings.h:100
static ReaderWriterToLuaTableMap theReaderWriterToLuaTableMap
Definition: luaScriptInterfaceImpl.h:799
void getMode3CData(lua_State *L, luabind::object &result, const DtIffMode3CSettings *settings)
luabind::object luaGetParameterSubordinateFunctions(lua_State *L, const DtScriptVrfObject &entity)
Gets a table of entity type and subordinate function handle pairs {{ENTITY_TYPE_STRING, FUNCTION_HANDLE_STRING}}.
luabind::object luaGetWeaponInfo(lua_State *L, const DtScriptOwnshipObject &thisEntity, const std::string &weaponId)
std::list< DtScriptVrfObject > luaGetContactsWithFilter(lua_State *L, const DtScriptOwnshipObject &entity, luabind::object const &typeFilters, bool observedOnly)
This function supports the script API. It gets the list of contacts matching the given filter and ret...
bool luaSetOrAddInternalStateProperty(lua_State *L, DtScriptOwnshipObject &entity, const std::string &context, const std::string &propertyName, luabind::object const &prop, bool addIfNotFound)
Sets the specified internal state property with the given value. If not found and addIfNotFound is tr...
std::string functionName() const
Definition: luaScriptInterfaceImpl.h:699
DtLuaScriptFunctionReference(const std::string &functionName)
Definition: luaScriptInterfaceImpl.h:688
luabind::object luaGetStatePropertyMapItem(lua_State *L, const DtScriptVrfObject &entity, const std::string &propertyName, luabind::object const &keyValue)
Returns an object containing the value of the of an item in the given state property. The state property must be a map. The item returned will have values matching the specified key value. The result may be a table containing a number of fields that make up the item, or a single value, depending on the data type of the list items. Will try to find the state property in both internal and external properties. If the property or map item could not be found, the returned table will be empty.
std::shared_ptr< DtScriptFunctionReference > DtScriptFunctionReferencePtr
Shared ptr to DtScriptFunctionReference.
Definition: scriptInterface.h:54
VectorOffset3D is a direction vector that is relative to some direction specified by a Vector3D...
Definition: scriptGeometry.h:428
Handles translation of messages from C++ structures into Lua tables and the reverse translation as we...
Definition: luaMessageInterface.h:23
void getMode5Data(lua_State *L, luabind::object &result, const DtIffMode5Settings *settings)
luabind::object luaGetOwnshipParamProperty(lua_State *L, const DtScriptOwnshipObject &entity, std::string const &paramName)
std::string luaGetSubordinateFunction(lua_State *L, const DtScriptVrfObject &entity, const DtScriptVrfObject &subEntity)
Return a string representing subordinate function for indicated subordinate.
LuaExtension(const LuaExtension &orig)
Definition: luaScriptInterfaceImpl.h:784
bool luaSetStatePropertyMapItem(lua_State *L, DtScriptOwnshipObject &entity, const std::string &propertyName, luabind::object const &keyValue, luabind::object const &itemValue)
Sets a single item in a map state property to the given value. First looks in the map to see if any e...
void getModeSData(lua_State *L, luabind::object &result, const DtIffModeSSettings *settings)
luabind::object luaGetIffSystem(lua_State *L, const DtScriptVrfObject &entity)
Returns a table of Iff Settings Data for the specified entity.
virtual DtString type() const =0
Script engine type.
DT_DLL_VRVCORE double distance(const makVrv::DtCoordinateSystem &, const DtVector &from, const DtVector &to)
Returns the distance from the two points. Coordinates are in local database coordinates The coordinat...
Represents a feature geometry.
Definition: luaFeatureGeometry.h:25
luabind::object luaGetStateOwnshipPropertyListItem(lua_State *L, const DtScriptOwnshipObject &entity, const std::string &propertyName, luabind::object const &keyValues, int &index)
static const std::map< DtString, rwToLuaBindObjectFcn > & rwToLuaBindObjectMap()
const DtLocalObject * onlyForEntity
Definition: luaScriptInterfaceImpl.h:788
Definition: luaScriptInterfaceImpl.h:56
luabind::object luaGetOwnshipParameterPropertyListItem(lua_State *L, const DtScriptOwnshipObject &entity, const std::string &propertyName, luabind::object const &keyValues, int &index)
bool luaGetIffModeIsOn(lua_State *L, const DtScriptVrfObject &entity, const DtModeType mode)
Returns a bool representing if the specified IFF mode is on or off.
bool luaSetInternalStatePropertyListItemByIndex(lua_State *L, DtScriptOwnshipObject &entity, const std::string &context, const std::string &propertyName, int index, luabind::object const &itemValue)
Finds the item in the internal state property list at the specified index and updates it to the new v...
bool luaSetStateProperty(lua_State *L, DtScriptOwnshipObject &entity, const std::string &propertyName, luabind::object const &prop)
Sets the specified state property with the given value. If the property does not exist or the format ...
luabind::object luaGetSystemAttribute(const DtScriptComponentSystem &system, const std::string &attributeName, bool *error, lua_State *L)
virtual ~DtLuaScriptFunctionReference() override
Definition: luaScriptInterfaceImpl.h:695
luabind::object luaGetInternalStateProperty(lua_State *L, const DtScriptOwnshipObject &entity, const std::string &context, const std::string &propertyName)
Returns an object containing the value of the requested internal state property. May be a table conta...
luabind::object(* rwToLuaBindObjectFcn)(const DtReaderWriter *rw, lua_State *L)
Definition: luaScriptInterfaceImpl.h:819
virtual void invokeDisable()=0
Only called for reactive tasks which can be enabled but not active. When the task is completely disab...
virtual void invokeTick()=0
This will be called by the parent to invoke the script tick.
luabind::object luaGetInternalStatePropertyListItemByIndex(lua_State *L, const DtScriptOwnshipObject &entity, const std::string &context, const std::string &propertyName, int index)
Returns an object containing the value of the of an item in the given internal state property...
std::list< DtVectorOffset3D > luaGetFormationPositions(lua_State *L, const DtScriptVrfObject &unit, const std::string &formationName, int *leaderIndex)
Calls luaGetOptionFormationPositions with empty options.
#define DT_DLL_vrfLua
This file is used to determine how to build.
Definition: vrfLuaDefines.h:25
bool luaSetStatePropertyListItem(lua_State *L, DtScriptOwnshipObject &entity, const std::string &propertyName, luabind::object const &keyValues, luabind::object const &itemValue)
Sets a single item in a list state property to the given value. First looks in the list to see if any...
const char ContactAliveOnly[]
Definition: luaScriptInterfaceImpl.h:49
luabind::object luaGetStatePropertyListItem(lua_State *L, const DtScriptVrfObject &entity, const std::string &propertyName, luabind::object const &keyValues, int &index)
Returns an object containing the value of the of an item in the given state property. The state property must be a list. The item returned will have values matching the specified key values in the key fields. The result may be a table containing a number of fields that make up the item, or a single value, depending on the data type of the list items. Will try to find the state property in both internal and external properties. If the property or list item could not be found, the returned table will be empty. Sets index to be the index of the item, using the Lua convention that the first item is at index 1.
This stream is used by the scripting classes to be able to send out translatable messages from script...
Definition: translatableStream.h:22
luabind::object luaGetContactInfo(lua_State *L, const DtScriptOwnshipObject &thisEntity, const DtScriptVrfObject &otherEntity)
Gets the perceived contact info that this entity has for another entity.
The base class for all messages to/from a specific DtVrfObject. Various subclasses of this class will...
Definition: vrfObjectMessage.h:30
Override of DtScriptInterface::DtScriptFunctionReference that holds a function reference by function ...
Definition: luaScriptInterfaceImpl.h:685
std::vector< DtLuaScriptInterfaceExtension * > LocalInterfaceExtensions
Definition: luaScriptInterfaceImpl.h:778
Abstract object used to hold a reference to a function defined in the script language, to be used later to invoke that function. Used for registering callbacks to be invoked after specified types of set data requests are executed. For this functionality to be used in a derived script interface implementation, a derived class must be implemented to represent a reference to a function in the script language.
Definition: scriptInterface.h:43
Definition: iffMode3CSettings.h:10
luabind::object luaGetEntityParam(lua_State *L, const DtScriptVrfObject &entity, std::string const &paramName)
luabind::object luaGetStateProperty(lua_State *L, const DtScriptVrfObject &entity, const std::string &propertyName)
Returns an object containing the value of the requested state property. May be a table containing a n...
virtual void processClearForReuse()
This function should be overridden by the inheritor to clear out any task specific variables...
Definition: asyncJobServer.h:39
bool luaSetSubordinateFunction(lua_State *L, const DtScriptVrfObject &entity, const DtScriptVrfObject &subEntity, const std::string &subFunction)
Given a table of {{&quot;subordinate&quot; = DtScriptVrfObject, &quot;function&quot; = string}} Set the state propert...
General settings that apply to all modes.
Definition: iffModeSSettings.h:13
std::vector< std::shared_ptr< const makVrfEvents::DtInfluenceEvent > > myInfluenceEvents
Definition: luaScriptInterfaceImpl.h:803
bool luaSetInternalStatePropertyListItem(lua_State *L, DtScriptOwnshipObject &entity, const std::string &context, const std::string &propertyName, luabind::object const &keyValues, luabind::object const &itemValue)
Sets a single item in an internal list state property to the given value. First looks in the list to ...
Contains the DtTranslatableStream class declaration.
const char ContactCurrentlyDetectedOnly[]
Definition: luaScriptInterfaceImpl.h:51
DtLuaScriptInterfaceExtension *(* CreatorFcn)(void *usr)
Prototype for DtLuaScriptInterfaceExtension creator function.
Definition: luaScriptInterfaceExtension.h:37
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:96
luabind::object luaGetOwnshipParameterPropertyMapItem(lua_State *L, const DtScriptOwnshipObject &entity, const std::string &propertyName, luabind::object const &keyValue)
DtScriptInterface & operator=(const DtScriptInterface &other)
virtual bool invokeCheck()=0
The DtLuaFeatureSet class is a wrapper around a DtFeatureSet that will provide feature information fo...
Definition: luaFeatureSet.h:27
luabind::object luaGetAisData(lua_State *L, const DtScriptVrfObject &entity)
Returns a table of AIS data for the specified entity.
LuaExtension()
Definition: luaScriptInterfaceImpl.h:783
std::map< DtString, ReaderWriterToLuaTableFcn > ReaderWriterToLuaTableMap
Definition: luaScriptInterfaceImpl.h:798
DtLuaScriptInterfaceExtension.
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
const char int mode
Definition: ioapi.h:38
luabind::object myCheckpointStateTable
Definition: luaScriptInterfaceImpl.h:796
bool luaSetSystemAttribute(DtScriptComponentSystem &system, const std::string &attributeName, const luabind::object &value, lua_State *L)
Contains Extended DI-Guy Object net types.
luabind::object luaGetTargetPriorityList(lua_State *L, const DtScriptOwnshipObject &thisEntity)
Gets the target priority list that this entity has.
luabind::object luaGetInternalStatePropertyListItem(lua_State *L, const DtScriptOwnshipObject &entity, const std::string &context, const std::string &propertyName, luabind::object const &keyValues, int &index)
Returns an object containing the value of the of an item in the given internal state property...
void getMode3AData(lua_State *L, luabind::object &result, const DtIffMode3ASettings *settings)
void * usr
Definition: luaScriptInterfaceImpl.h:789
const char ContactHostileOnly[]
Definition: luaScriptInterfaceImpl.h:50
Definition: luaScriptInterfaceImpl.h:781
The &quot;this&quot; version is the own-ship object. It is separated to allow special functions for the ownshi...
Definition: scriptVrfObject.h:418
DtLuaMessageInterface * myMessageInterface
Definition: luaScriptInterfaceImpl.h:800
std::list< DtVectorOffset3D > luaGetOptionFormationPositions(lua_State *L, const DtScriptVrfObject &unit, const std::string &formationName, luabind::object const &options, int *leaderIndex)
Gets a list of offset vectors defining the positions in the formation. Returns the index of the leade...
luabind::object luaGetWeaponInfoList(lua_State *L, const DtScriptOwnshipObject &thisEntity)
Lua &quot;getWeaponInfo()&quot; Returns a list of the weapon info for weapons on this entity.
This class is a wrapper for a DtCompSystem for use by scripts. It derives from DtAsciiSerializable so...
Definition: scriptComponentSystem.h:18
This class is a two-way interface between the script language and its parent controller. There are functions that either the parent controller will call on the script interface (such as tick() ) and there will be functions the script interface will call on the parent controller to inform the parent of status updates and for data access.
Definition: scriptInterface.h:32
std::string myFunctionName
Definition: luaScriptInterfaceImpl.h:720
luabind::object luaGetOwnshipParameterPropertyListItemByIndex(lua_State *L, const DtScriptOwnshipObject &entity, const std::string &propertyName, int index)
virtual void invokeSuspend()=0
voidpf uLong offset
Definition: ioapi.h:42
A DtSetDataRequestMessage is a DtRadioMsg with a pointer to a setDataRequest. The type of the DtSetDa...
Definition: setDataRequestMessage.h:29
void getTCASData(lua_State *L, luabind::object &result, const DtIffTCASDataSettings *settings)
luabind::object luaGetStateOwnshipProperty(lua_State *L, const DtScriptOwnshipObject &entity, const std::string &propertyName)
bool luaSetOrAddStateProperty(lua_State *L, DtScriptOwnshipObject &entity, const std::string &propertyName, luabind::object const &prop, bool addIfNotFound)
Sets the specified state property with the given value. If not found and addIfNotFound is true...
std::list< DtScriptVrfObject > luaGetContacts(lua_State *L, const DtScriptOwnshipObject &entity, luabind::object const &typeFilters, luabind::object const &flags)
Lua &quot;getContacts()&quot; Return a list of contacts matching the given table of entity type filters...
luabind::object luaGetParameterPropertyMapItem(lua_State *L, const DtScriptVrfObject &entity, const std::string &propertyName, luabind::object const &keyValue)
Returns an object containing the value of the of an item in the given parameter property. The property must be a map. The item returned will have values matching the specified key value. The result may be a table containing a number of fields that make up the item, or a single value, depending on the data type of the list items. If the property or map item could not be found, the returned table will be empty.
std::list< DtScriptVrfObject > luaGetHostileContactsWithFilterAliveOnly(lua_State *L, const DtScriptOwnshipObject &entity, luabind::object const &typeFilters, bool observedOnly, bool aliveOnly)
This function is the same as luaGetContactsWithFilterAliveOnly, but it returns only hostile contacts...
Definition: iffBasicModeSettings.h:66
virtual void invokeShutdown()=0
virtual void invokeUpdateDisplayGraph()=0
Called when graphs are enabled to get an immediate graph output.
A locally simulated VRF object.
Definition: localObject.h:98
Definition: scriptVrfObject.h:30
luabind::object luaGetIffModeData(lua_State *L, const DtScriptVrfObject &entity, const DtModeType mode)
Returns a table with the Iff Mode specific data of the specified entity using the given IFF mode...
A location3D is a point in space, i.e. a geocentric coordinate.
Definition: scriptGeometry.h:22

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)