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) 2026 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 bool taskFailedDuringInit() const override { return myTaskFailedDuringInit; }
79  virtual void invokeSuspend() override;
80  virtual bool invokeResume() override;
81  virtual void invokeTick() override;
82  virtual bool invokeCheck() override;
83  virtual void invokeCheckInit() override;
84  virtual void invokeShutdown() override;
85  virtual void invokeUpdateDisplayGraph() override;
86 
89  virtual void invokeDisable() override;
90 
91  virtual bool loadScript(bool reload) override;
92 
93  virtual void setLuaState(lua_State* L);
94  virtual lua_State* getLuaState();
95 
96  virtual std::string dumpLuaStack() const;
97  virtual int luaStackSize() const;
98  virtual void collectGarbage();
99 
100  virtual DtReaderWriter* saveState() override;
101  virtual bool loadState(const DtReaderWriter* loadState) override;
102  virtual void processClearForReuse() override;
103 
108  static void addLuaScriptInterfaceExtension(DtLuaScriptInterfaceExtension::CreatorFcn extension, void* usr);
109 
114  static void addLuaScriptInterfaceExtension(DtLuaScriptInterfaceExtension::CreatorFcn extension,
115  const DtLocalObject* onlyForEntity, void* usr);
116 
118  static void removeLuaScriptInterfaceExtension(DtLuaScriptInterfaceExtension::CreatorFcn extension, void* usr);
119 
122  static void removeLuaScriptInterfaceExtension(DtLuaScriptInterfaceExtension::CreatorFcn extension,
123  const DtLocalObject* onlyForEntity, void* usr);
124 
128  static void invalidateLuaScriptInterfaceExtension(
129  DtLuaScriptInterfaceExtension::CreatorFcn creator, void* usr);
130 
131  virtual bool initializeVRFLuaExtensions(lua_State* L);
132  virtual bool importTaskParams(lua_State* L);
133 
135  virtual bool importSetParams(lua_State* L);
136 
138  virtual luabind::object createLuaTableFromRegistry(lua_State* L, const DtReaderWriterRegistry& rwRegistry, bool requireMetadata = true, bool hasParamMetaData = true,
139  bool converyKeysToUseUnderscore = true);
142  static luabind::object createLuaTableFromRwRegistry(lua_State* L, const DtReaderWriterRegistry& rwRegistry, DtSimulationServices* simServices);
143 
145  static void addKeyToIgnore(const std::string&);
146 
148  static void removeKeyToIgnore(const std::string&);
149 
151  void luaEndTask(bool success);
152  void luaEndSet();
153 
155  virtual void processEvents() override;
156 
158 
160 
161  virtual void luaPlayScenarioEvent(DtScriptVrfObject eventName);
162  virtual void luaStopScenarioEvent(DtScriptVrfObject eventName);
163  virtual void luaStopScenarioEventWithRewind(DtScriptVrfObject eventName, bool rewind);
164  virtual bool luaIsScenarioEventPlaying(DtScriptVrfObject eventName);
165  virtual void luaSetScenarioEventEnabled(DtScriptVrfObject eventName, bool);
166  virtual bool luaIsScenarioEventEnabled(DtScriptVrfObject eventName);
168 
170 
171 
175  virtual int taskIdNumber();
177  virtual int luaSendEmbeddedEntityTask(std::string eeName, std::string taskName, luabind::object const& parms);
178  virtual int luaSendEmbeddedEntityTaskActAsSubtask(std::string eeName, std::string taskName,
179  luabind::object const& parms, bool actAsSubtask);
181  virtual int luaSendEmbeddedEntitySet(std::string eeName, std::string setName, luabind::object const& parms);
183 
185 
186  int luaStartSubtask(const std::string taskName, luabind::object const& parameters);
188  void luaStopSubtask(int subtaskId);
190  void luaStopAllSubtasks();
192  bool luaIsSubtaskRunning(int subtaskId);
194  bool luaIsSubtaskComplete(int subtaskId);
196  bool luaIsSubtaskCanceled(int subtaskId);
198  bool luaSubtaskResult(int subtaskId);
202  void luaCleanupInactiveSubtaskStatus();
204 
207  virtual void luaSendChatMessage(const std::string& user, const std::string& channel, int force, const std::string& message);
208  virtual void luaSendChatMessageForceString(const std::string& user, const std::string& channel, const std::string& force, const std::string& message);
209 
211  void luaSendReportWithoutRecipients(const::std::string reportType,
212  luabind::object const& parameters);
213  void luaSendReport(const::std::string reportType,
214  luabind::object const& reciptients,
215  luabind::object const& parameters);
216 
218  int luaSendTask(DtScriptVrfObject& object, const::std::string taskName,
219  luabind::object const& parameters);
220  int luaSendTaskNotAsSubtask(DtScriptVrfObject& object, const::std::string taskName,
221  luabind::object const& parameters);
222  int luaSendTaskActAsSubtask(DtScriptVrfObject& object, const::std::string taskName,
223  luabind::object const& parameters, bool actAsSubtask);
224  int luaSendRadioTask(DtScriptVrfObject& object, const::std::string taskName,
225  luabind::object const& parameters);
226  int luaSendRadioTaskActAsSubtask(DtScriptVrfObject& object, const::std::string taskName,
227  luabind::object const& parameters, bool actAsSubtask);
228  int luaSendTaskActAsSubtaskWithRadio(DtScriptVrfObject& object, const::std::string taskName,
229  luabind::object const& parameters, bool actAsSubtask, bool sendWithRadio);
230 
232  void luaStopAllTasks();
233 
235  void luaSendSetDataToSelf(const::std::string setName,
236  luabind::object const& parameters);
237 
239  void luaSendSetData(DtScriptVrfObject& object, const::std::string setName,
240  luabind::object const& parameters);
241  void luaSendRadioSetData(DtScriptVrfObject& object, const::std::string setName,
242  luabind::object const& parameters);
243  void sendSetDataWithRadio(DtScriptVrfObject& object, const::std::string setName,
244  luabind::object const& parameters, bool useRadio);
245 
246  bool luaIsTaskAvailable(const::std::string taskName);
247  bool luaIsSetAvailable(const::std::string setName);
248 
250  luabind::object luaGetReactionStatus();
251 
260  luabind::object luaGetOrbatList();
261 
263  std::string luaGetScriptId();
264 
266  std::string luaGetSystemName();
267 
268  luabind::object luaGetObjectsNear(const DtLocation3D& loc, double distance);
269  luabind::object luaGetObjectsNearWithFilter(const DtLocation3D& loc, double distance, luabind::object const& parameters);
270 
271  luabind::object luaGetScriptAttribute(const std::string& attributeName, bool& error);
272 
274  luabind::object luaGetVrfObjects();
275 
277 
278  luabind::object luaGetDesignatorsNearWithFilter(const DtLocation3D& loc, double distance,
279  const luabind::object& params);
280 
281  luabind::object luaGetDesignatorsNear(const DtLocation3D& loc, double distance);
283 
285 
286  DtLuaFeatureSet luaGetFeaturesWithinArea(luabind::object const& points, luabind::object const& attributes);
289  DtLuaFeatureSet luaGetFeaturesWithinAreaNoAttributes(luabind::object const& points);
290 
293  DtLuaFeatureSet luaGetFeaturesWithinRange(const DtLocation3D&, double range, luabind::object const& attributes);
295  DtLuaFeatureSet luaGetFeaturesWithinRangeNoAttributes(const DtLocation3D&, double range);
296 
298  DtLuaFeatureSet luaGetFeaturesType(const std::string& type);
300  DtLuaFeatureSet luaGetFeatures();
302 
304 
305  DtLuaFeatureGeometry luaMakePointGeometry(const DtLocation3D&);
308  DtLuaFeatureGeometry luaMakePathGeometry(luabind::object const& table);
310  DtLuaFeatureGeometry luaMakeAreaGeometry(luabind::object const& table);
312 
315  bool isPointInNavigationArea(const DtLocation3D& point, std::string& navArea) const;
316 
319  std::shared_ptr<DtLuaAsyncJob> findNavigationAreaTransitionPoint(const DtLocation3D& insidePoint,
320  const DtLocation3D& outsidePoint) const;
321 
325  std::shared_ptr<DtLuaAsyncJob> findMultipleNavigationAreaTransitionPoints(
326  const luabind::object& pairsOfPoints) const;
327 
329  std::shared_ptr<DtLuaAsyncJob> generateRandomPoints(const luabind::object& parameters);
330 
332  std::shared_ptr<DtLuaAsyncJob> findNearbyPointOfInterest(const int type);
333 
335  std::shared_ptr<DtLuaAsyncJob> findCoverPoint(
336  const DtLocation3D& startLocation, const DtLocation3D& threatLocation,
337  double threatRadius, double distanceFromThreat, double range, unsigned numberOfPoints);
338 
340  luabind::object findLadders(lua_State* L, const DtLocation3D& startLocation, double range);
342  luabind::object findLaddersWithId(lua_State* L, const DtLocation3D& startLocation,
343  double range, const unsigned int id);
344 
346  std::shared_ptr<DtLuaAsyncJob> findPathToLocation(
347  const DtLocation3D& startLocation, const DtLocation3D& destinationLocation,
348  bool useAbstractGraphs, const DtLocation3D& avoidLocation, double avoidanceRadius);
349  std::shared_ptr<DtLuaAsyncJob> findPathToLocationWithParameters(const DtLocation3D& startLocation,
350  const DtLocation3D& destinationLocation, const luabind::object& parameters);
351 
352  std::shared_ptr<DtLuaAsyncJob> findPathToLocationWithParameterObject(const DtLocation3D& startLocation,
353  const DtLocation3D& destinationLocation, DtLuaNavFindPathParameters& parameters);
354 
357  std::shared_ptr<DtLuaAsyncJob> placeFormation(const luabind::object& parameters);
358  std::shared_ptr<DtLuaAsyncJob> placeFormationWithWidth(const luabind::object& parameters,
359  double entityWidth);
360 
366  luabind::object findNavSectors(lua_State* L, const DtLocation3D& location);
367 
369  DtTranslatableStream translateStringFromScript(const std::string& format);
370 
373  std::shared_ptr<DtLuaAsyncJob> luaNavigateThroughFeatures(const luabind::object& parameters);
374 
377  virtual std::shared_ptr<DtLuaAsyncJob> luaFindHighPoints(const luabind::object& corners, unsigned int nPoints);
378  virtual std::shared_ptr<DtLuaAsyncJob> luaFindHighPointsDebug(const luabind::object& corners, unsigned int nPoints, bool bDebug);
380 
382  /*
383  job = vrf:luaFindSinglePosition(taskParameters.targetArea:getLocations3D(),
384  taskParameters.battlePosition,
385  targetHeightMeters, -- 2/3 vehicle height, for example.
386  double viewHeightMeters, -- 2/3 vehicle height, for example.
387  double hideHeightMeters, -- 1.1x vehicle height, for example.
388  double forwardBackSearchLimitMeters, -- 50m forward + 50m backward = 100m
389  double forwardBackSearchIntervalMeters, -- half vehicle length, for example.
390  double maxSlopeDegrees, -- *todo add comments*
391  )
392  )
393 
394  */
395  virtual std::shared_ptr<DtLuaAsyncJob> luaFindSinglePosition(
396  const luabind::object& targetAreaCorners,
397  const DtLocation3D& pivotPoint,
398  double targetHeightMeters,
399  double viewHeightMeters,
400  double hideHeightMeters,
401  double forwardBackSearchLimitMeters,
402  double forwardBackSearchIntervalMeters,
403  double maxSlopeDegrees);
404 
406  /*
407  job = vrf:luaFindSinglePosition(taskParameters.targetArea:getLocations3D(),
408  taskParameters.battlePosition,
409  targetHeightMeters, -- 2/3 vehicle height, for example.
410  double viewHeightMeters, -- 2/3 vehicle height, for example.
411  double hideHeightMeters, -- 1.1x vehicle height, for example.
412  double forwardBackSearchLimitMeters, -- 50m forward + 50m backward = 100m
413  double forwardBackSearchIntervalMeters, -- half vehicle length, for example.
414  double maxSlopeDegrees, -- *todo add comments*
415  bool bDebug -- Log additional information)
416  )
417  */
418  virtual std::shared_ptr<DtLuaAsyncJob> luaFindSinglePositionDebug(
419  const luabind::object& targetAreaCorners,
420  const DtLocation3D& pivotPoint,
421  double targetHeightMeters,
422  double viewHeightMeters,
423  double hideHeightMeters,
424  double forwardBackSearchLimitMeters,
425  double forwardBackSearchIntervalMeters,
426  double maxSlopeDegrees,
427  bool bDebug);
428 
429 
431  /*
432  job = vrf:findVehicleFightingPositions(taskParameters.numberOfPoints,
433  taskParameters.targetArea:getLocations3D(),
434  taskParameters.battlePosition,
435  maxVolume, -- half dimensions of hide position
436  maxVolume:getUp() * 0.67, --67% of total height for shooting height
437  maxVolume:getUp() * 0.50, -- half height for target height
438  searchWidthForward, -- how much forward and back to search forward and back
439  searchWidthSide -- how much side to side to search
440  positionSpacing -- how many meters between positions, side to side
441  )
442  */
443  virtual std::shared_ptr<DtLuaAsyncJob> luaFindVehicleFightingPositions(
444  unsigned int nPositionPairs,
445  const luabind::object& targetAreaCorners,
446  const DtLocation3D& originPoint,
447  const DtVectorOffset3D& hideVolume,
448  double shootHeight,
449  double targetHeight,
450  double forwardBackSearchLimit,
451  double sideSideSearchLimit,
452  double maxSlopeDegrees,
453  double positionSpacing);
454 
456  virtual std::shared_ptr<DtLuaAsyncJob> luaFindVehicleFightingPositionsDebug(
457  unsigned int nPositionPairs,
458  const luabind::object& targetAreaCorners,
459  const DtLocation3D& originPoint,
460  const DtVectorOffset3D& hideVolume,
461  double shootHeight,
462  double targetHeight,
463  double forwardBackSearchLimit,
464  double sideSideSearchLimit,
465  double maxSlopeDegrees,
466  double positionSpacing,
467  bool useDebug);
468 
469  virtual std::shared_ptr<DtLuaAsyncJob> luaFindPositionGroupsInAreaHilltop(
470  unsigned int nPositionPairsPerGroup,
471  const luabind::object& searchAreaVertices,
472  const luabind::object& targetsAreaVertices,
473  double viewHeightMeters,
474  double coverHeightMeters,
475  unsigned int forwardBackRangeMeters,
476  unsigned int sideSideRangeMeters,
477  unsigned int searchIntervalMeters,
478  double maxSlopeDegrees,
479  unsigned int positionsLateralSpacingMeters);
480 
481  virtual std::shared_ptr<DtLuaAsyncJob> luaFindPositionGroupsInAreaHilltopDebug(
482  unsigned int nPositionPairsPerGroup,
483  const luabind::object& searchAreaVertices,
484  const luabind::object& targetsAreaVertices,
485  double viewHeightMeters,
486  double coverHeightMeters,
487  unsigned int forwardBackRangeMeters,
488  unsigned int sideSideRangeMeters,
489  unsigned int searchIntervalMeters,
490  double maxSlopeDegrees,
491  unsigned int positionsLateralSpacingMeters,
492  bool useDebug);
493 
494  virtual std::shared_ptr<DtLuaAsyncJob> luaFindPositionGroupsInAreaRidge(
495  unsigned int nPositionPairsPerGroup,
496  const luabind::object& searchAreaVertices,
497  const luabind::object& targetsAreaVertices,
498  unsigned int targetsAreaSampleRate,
499  const luabind::object& tableOfDoubles
500  );
501 
502  virtual std::shared_ptr<DtLuaAsyncJob> luaFindPositionGroupsInAreaRidgeDebug(
503  unsigned int nPositionPairsPerGroup,
504  const luabind::object& searchAreaVertices,
505  const luabind::object& targetsAreaVertices,
506  unsigned int targetsAreaSampleRate,
507  const luabind::object& tableOfDoubles
508  , bool useDebug);
509 
512  std::shared_ptr<DtLuaAsyncJob> getAllEmbarkationSlots(DtScriptVrfObject& object);
513 
516  std::shared_ptr<DtLuaAsyncJob> getEmbarkationSlots(DtScriptVrfObject& object);
517 
519  std::shared_ptr<DtLuaAsyncJob> getEmbarkationSlotsFiltered(DtScriptVrfObject& object,
520  bool bAllSlots);
521 
523  std::shared_ptr<DtLuaAsyncJob> reserveEmbarkationSlot(DtScriptVrfObject& object, int slotNumber);
524 
526  std::shared_ptr<DtLuaAsyncJob> getEmbarkationEgressPoints(DtScriptVrfObject& object);
527 
528  void luaSendMessage(const DtScriptVrfObject& receiver, const std::string& message);
529  void luaSendRadioMessage(const DtScriptVrfObject& receiver, const std::string& message);
530  void luaSendRadioMessageToUuid(const std::string& uuid, const std::string& message);
531  void luaDeleteObject(std::string const& receiver);
532  void luaDeleteScriptObject(const DtScriptVrfObject& receiver);
533  void luaSetInterest(const DtLocation3D& location, double range);
534 
535  void luaSendObjectMessage(const DtScriptVrfObject& receiver, const std::string& messageType, const luabind::object& messageContents);
536  void luaSendRadioObjectMessage(const DtScriptVrfObject& receiver, const std::string& messageType, const luabind::object& messageContents);
537  void luaRegisterForObjectMessage(const std::string& messageType);
538  void luaUnregisterForObjectMessage(const std::string& messageType);
539  void processObjectMessage(const DtVrfObjectMessage* msg);
540 
541  static void textReportCallback(const DtVrfObjectMessage* m, void* usr);
542  virtual void queueTextReport(const DtVrfObjectMessage* m);
543  virtual void processTextReport(const DtVrfObjectMessage* m);
544 
545  void luaSendInfluence(const DtScriptVrfObject& target,
546  const std::string& influenceName, luabind::object const& influenceParams);
547 
549  static void addReaderWriterToLuaTableFunction(const DtString&, ReaderWriterToLuaTableFcn);
550 
551  static void influenceEventCallback(std::shared_ptr<const makVrfEvents::DtInfluenceEvent> event, void* usr);
552  virtual void queueInfluence(std::shared_ptr<const makVrfEvents::DtInfluenceEvent> e);
553  virtual void processInfluence(std::shared_ptr<const makVrfEvents::DtInfluenceEvent> e);
554 
556  virtual void processEntityDestroyed() override;
557 
559  luabind::object luaGetCloudLayerDescriptionsAt(lua_State *L, const DtLocation3D& location);
562 
565 
566  virtual double luaGetIllumination(DtScriptVrfObject& object);
567  virtual double luaGetExpectedIllumination(DtScriptVrfObject& object, double dateAndTimeOfDay);
568  virtual double luaGetSnowAccumulationByLocation(const DtLocation3D& object);
569  virtual double luaGetSnowRoadAccumulationByLocation(const DtLocation3D& object);
570  virtual double luaGetRainAccumulationByLocation(const DtLocation3D& object);
571 
572  virtual double luaGetAirTemperatureByLocation(const DtLocation3D& object);
573  virtual double luaGetAirPressureByLocation(const DtLocation3D& object);
574  virtual unsigned int luaGetPrecipitationByLocation(const DtLocation3D& location, double*);
575  virtual double luaGetPrecipitationIntensityByLocation(const DtLocation3D& object);
576  virtual unsigned int luaGetPrecipitationTypeByLocation(const DtLocation3D& object);
577  virtual double luaGetVisibilityDistanceByLocation(const DtLocation3D& object);
578  virtual int luaGetVisibilityObscurantByLocation(const DtLocation3D& object);
579  virtual double luaGetWindDirectionByLocation(const DtLocation3D& object);
580  virtual double luaGetWindSpeedByLocation(const DtLocation3D& object);
581  virtual double luaGetUnderwaterVisibilityByLocation(const DtLocation3D& object);
582  virtual unsigned int luaGetSwellStateByLocation(const DtLocation3D& object);
583  virtual double luaGetSwellStateDirectionByLocation(const DtLocation3D& object);
584  virtual unsigned int luaGetSeaStateByLocation(const DtLocation3D& object);
585  virtual double luaGetSeaStateDirectionByLocation(const DtLocation3D& object);
586  virtual double luaGetSurgeDepthByLocation(const DtLocation3D& object);
587  virtual double luaGetIlluminationByLocation(const DtLocation3D& object);
588  virtual double luaGetExpectedIlluminationByLocation(const DtLocation3D& object, double dateAndTimeOfDay);
590 
593  virtual double luaRunUntilTime();
594  virtual void luaSetRunUntilTime(double);
595  virtual void luaStopSimulationUntilTimer();
597 
600  virtual void luaSetCheckpointMode(bool);
601  virtual void initializeCheckpointStateTable(lua_State* L);
602 
611  virtual int luaAskUserQuestion(const DtTranslatableStream& title, const DtTranslatableStream& message,
612  luabind::object const& options, int displayFlags);
613  virtual int luaAskUserQuestionST(const std::string& title, const DtTranslatableStream& message,
614  luabind::object const& options, int displayFlags);
615  virtual int luaAskUserQuestionTS(const DtTranslatableStream& title, const std::string& message,
616  luabind::object const& options, int displayFlags);
617  virtual int luaAskUserQuestionSS(const std::string& title, const std::string& message,
618  luabind::object const& options, int displayFlags);
619 
623  virtual int luaStatusOfUserQuestion(int questionId);
624 
626  virtual void luaCancelUserQuestion(int questionId);
627 
631 
633  DtScriptVrfObject luaCreateEntity(luabind::object const& parameters);
634  void luaCreateEntityParallel(luabind::object const& parameters);
635 
637  DtScriptVrfObject luaCreateFromOrbat(std::string orbatItem, const DtLocation3D& loc);
638 
640  DtScriptVrfObject luaCreateTacticalGraphic(luabind::object const& parameters);
641 
643  DtScriptVrfObject luaCreateObstacle(luabind::object const& parameters);
644 
646  DtScriptVrfObject luaCreateRoute(luabind::object const& parameters);
647 
649  DtScriptVrfObject luaCreateArea(luabind::object const& parameters);
650 
652  DtScriptVrfObject luaCreateWaypoint(luabind::object const& parameters);
653 
655  DtScriptVrfObject luaCreatePhaseLine(luabind::object const& parameters);
657 
664  std::vector<DtLocation3D> luaMakeOffsetPoints(
665  luabind::object const& fromPoints,
666  const DtVectorOffset3D& offset);
667  std::vector<DtLocation3D> luaMakeOffsetPointsWithRadius(luabind::object const& fromPoints,
668  const DtVectorOffset3D& offset, const double minimumTurnRadius);
669 
671  void luaCreateSelectionGroup(const std::string& name, luabind::object const& parameters);
672 
676  void luaFinishTest(const int status, const std::string message);
677 
679  bool luaUpdateTaskVisualization(const std::string& visualizationName,
680  const std::string& visualizationType, luabind::object const& parameters);
681 
683  void luaDeleteTaskVisualization(const std::string& visualizationName);
684 
686  void luaRequire(lua_State* L, const std::string& filename);
687 
690  unsigned luaBitwiseOr(unsigned val1, unsigned val2);
691  unsigned luaBitwiseAnd(unsigned val1, unsigned val2);
692  unsigned luaBitwiseXor(unsigned val1, unsigned val2);
693  unsigned luaBitwiseNot(unsigned val);
694  unsigned luaBitwiseLeftShift(unsigned val, unsigned shift);
695  unsigned luaBitwiseRightShift(unsigned val, unsigned shift);
697 
698  bool luaIntersectSegments2D(const DtLocation3D& p1, const DtLocation3D& p2,
699  const DtLocation3D& p3, const DtLocation3D& p4,
700  DtLocation3D& intersectPoint);
701 
703  virtual bool luaIsDatabaseLoggingEnabled();
704 
706  virtual void luaLogEventToDatabase(unsigned eventType, luabind::object const& parameters);
707 
712  {
713  public:
714  DtLuaScriptFunctionReference(const std::string& functionName)
716  , myFunctionName(functionName)
717  {
718 
719  }
720 
721  virtual ~DtLuaScriptFunctionReference() override {
722 
723  }
724 
725  std::string functionName() const
726  {
727  return myFunctionName;
728  }
729 
730  virtual bool operator<(const DtScriptFunctionReference& other) const override
731  {
732  try
733  {
734  const DtLuaScriptFunctionReference& rhs =
735  dynamic_cast<const DtLuaScriptFunctionReference&>(other);
736  return myFunctionName.compare(rhs.myFunctionName) < 0;
737  }
738  catch(...)
739  {
740  DtInfo << "DtLuaScriptFunctionReference::operator< attempt to compare with wrong type.\n";
741  return false;
742  }
743  }
744 
745  protected:
746  std::string myFunctionName;
747  };
748 
751  virtual void addPostSetDataCallback(const std::string& setDataType,
752  const std::string& functionName);
755  virtual void removePostSetDataCallback(const std::string& setDataType,
756  const std::string& functionName);
757 
760  virtual void invokePostSetDataCallback(
761  DtScriptFunctionReferencePtr functionReference,
762  DtSetDataRequestMessage* setDatRequest) override;
763 
769  virtual luabind::object luaGetParamPropertyFromType(
770  const std::string typeString, std::string const& paramName);
771 
772  virtual luabind::object luaGetApplicationSetting(
773  const std::string settingName);
774 
776  virtual void putObjectsFromTableIntoGlobalTable(lua_State* state, luabind::object& table);
777  virtual void putObjectsFromGlobalTableIntoTable(lua_State* state, luabind::object& table);
778 
780  virtual luabind::object luaGetSubordinateFunctionNames();
781 
783  virtual luabind::object luaGetParameterSubordinateFunctionsFromType(
784  const std::string typeString);
785 
786  virtual void connectForCallbacks();
787 
789  std::shared_ptr<DtLuaAsyncJob> luaGetWeaponSystemsInfo(DtScriptVrfObject& object);
790 
791  void clearExtensionBackingPointer(void* usr);
792 
793 protected:
797  virtual bool callLuaNoArgFunction(const std::string& functionName, bool* functionExists = nullptr);
798 
799  virtual void updateFuncCallCount();
800 
801  lua_State* myLState;
802  unsigned myFuncCallCount;
804 
805  typedef std::vector<DtLuaScriptInterfaceExtension*> LocalInterfaceExtensions;
807 
809  {
810  LuaExtension() : creator(nullptr), onlyForEntity(nullptr), usr(nullptr) {};
811  LuaExtension(const LuaExtension& orig) : creator(orig.creator), onlyForEntity(orig.onlyForEntity),
812  usr(orig.usr) {};
813 
816  void* usr;
817  };
818 
819  typedef std::vector<LuaExtension> GlobalInterfaceExtensions;
820 
822 
823  luabind::object myCheckpointStateTable;
824 
825  typedef std::map<DtString, ReaderWriterToLuaTableFcn> ReaderWriterToLuaTableMap;
829 
830  std::vector<DtVrfObjectMessage*> myTextReportCallbacks;
831  std::vector<std::shared_ptr<const makVrfEvents::DtInfluenceEvent> > myInfluenceEvents;
832 
833  bool myNeedsInvokeShutdown = true;
834  bool myTaskFailedDuringInit = false;
835 
836 
837 };
838 
840 
848 namespace luaScriptInterface
849 {
850  typedef luabind::object (*rwToLuaBindObjectFcn)(
851  const DtReaderWriter* rw, lua_State* L);
852 
853  luabind::object luaGetEntityParam(lua_State* L,
854  const DtScriptVrfObject& entity, std::string const& paramName);
855 
856  luabind::object luaGetSystemAttribute(
857  const DtScriptComponentSystem& system, const std::string& attributeName
858  , bool *error
859  , lua_State *L
860  );
861 
863  luabind::object luaGetContactInfo(lua_State* L, const DtScriptOwnshipObject& thisEntity,
864  const DtScriptVrfObject& otherEntity);
865 
869  luabind::object luaGetSubordinateFormation(lua_State* L,
870  const DtScriptOwnshipObject& entity,
871  DtScriptVrfObject& leadSubordinate);
872 
880  std::list<DtVectorOffset3D> luaGetOptionFormationPositions(lua_State* L,
881  const DtScriptVrfObject& unit,
882  const std::string& formationName, luabind::object const& options,
883  int* leaderIndex);
884 
886  std::list<DtVectorOffset3D> luaGetFormationPositions(lua_State* L,
887  const DtScriptVrfObject& unit,
888  const std::string& formationName,
889  int* leaderIndex);
890 
893  luabind::object luaGetParameterSubordinateFunctions(lua_State* L, const DtScriptVrfObject& entity);
894 
896  luabind::object luaGetSubordinateFunctions(lua_State* L, const DtScriptVrfObject& entity);
897 
901  bool luaSetSubordinateFunctions(lua_State* L, const DtScriptVrfObject& entity, luabind::object const& subsAndFunctions);
902 
904  std::string luaGetSubordinateFunction(lua_State* L, const DtScriptVrfObject& entity, const DtScriptVrfObject& subEntity);
905 
909  bool luaSetSubordinateFunction(lua_State* L, const DtScriptVrfObject& entity, const DtScriptVrfObject& subEntity, const std::string& subFunction);
910 
912  luabind::object luaGetAisData(lua_State* L, const DtScriptVrfObject& entity);
913 
915  luabind::object luaGetIffSystem(lua_State* L, const DtScriptVrfObject& entity);
916 
918  luabind::object luaGetIffModeData(lua_State* L, const DtScriptVrfObject& entity, const DtModeType mode);
919  void getMode1Data(lua_State* L, luabind::object& result, const DtIffMode1Settings* settings);
920  void getMode2Data(lua_State* L, luabind::object& result, const DtIffMode2Settings* settings);
921  void getMode3AData(lua_State* L, luabind::object& result, const DtIffMode3ASettings* settings);
922  void getMode3CData(lua_State* L, luabind::object& result, const DtIffMode3CSettings* settings);
923  void getMode5Data(lua_State* L, luabind::object& result, const DtIffMode5Settings* settings);
924  void getModeSData(lua_State* L, luabind::object& result, const DtIffModeSSettings* settings);
925  void getTCASData(lua_State* L, luabind::object& result, const DtIffTCASDataSettings* settings);
926 
928  bool luaGetIffModeIsOn(lua_State* L, const DtScriptVrfObject& entity, const DtModeType mode);
929 
930 
931 
933  luabind::object luaGetTargetPriorityList(lua_State* L, const DtScriptOwnshipObject& thisEntity);
934 
942  std::list<DtScriptVrfObject> luaGetContactsWithFilter(
943  lua_State* L, const DtScriptOwnshipObject& entity,
944  luabind::object const& typeFilters, bool observedOnly);
947  std::list<DtScriptVrfObject> luaGetContactsWithFilterAliveOnly(
948  lua_State* L, const DtScriptOwnshipObject& entity,
949  luabind::object const& typeFilters, bool observedOnly,
950  bool aliveOnly);
951 
954  std::list<DtScriptVrfObject> luaGetHostileContactsWithFilterAliveOnly(
955  lua_State* L, const DtScriptOwnshipObject& entity,
956  luabind::object const& typeFilters, bool observedOnly,
957  bool aliveOnly);
958 
963  std::list<DtScriptVrfObject> luaGetContacts(
964  lua_State* L, const DtScriptOwnshipObject& entity,
965  luabind::object const& typeFilters,
966  luabind::object const& flags);
967 
968  std::vector<DtScriptVrfObject> luaGetAllHostileContacts(
969  lua_State* L, const DtScriptOwnshipObject& entity,
970  luabind::object const& options);
971 
974  luabind::object luaGetWeaponInfoList(lua_State* L, const DtScriptOwnshipObject& thisEntity);
975 
976  luabind::object luaGetWeaponInfo(lua_State* L, const DtScriptOwnshipObject& thisEntity, const std::string& weaponId);
977 
981  bool luaSetStateProperty(lua_State* L, DtScriptOwnshipObject& entity,
982  const std::string& propertyName, luabind::object const& prop);
983 
988  bool luaSetOrAddStateProperty(lua_State* L, DtScriptOwnshipObject& entity,
989  const std::string& propertyName, luabind::object const& prop, bool addIfNotFound);
990 
998  bool luaSetStatePropertyListItem(lua_State* L,
999  DtScriptOwnshipObject& entity, const std::string& propertyName,
1000  luabind::object const& keyValues, luabind::object const& itemValue);
1001 
1009  lua_State* L, DtScriptOwnshipObject& entity, const std::string& propertyName,
1010  int index, luabind::object const& itemValue);
1011 
1019  bool luaSetStatePropertyMapItem(lua_State* L,
1020  DtScriptOwnshipObject& entity, const std::string& propertyName,
1021  luabind::object const& keyValue, luabind::object const& itemValue);
1022 
1025  bool luaSetInternalStateProperty(lua_State* L, DtScriptOwnshipObject& entity,
1026  const std::string& context, const std::string& propertyName, luabind::object const& prop);
1027 
1031  bool luaSetOrAddInternalStateProperty(lua_State* L, DtScriptOwnshipObject& entity,
1032  const std::string& context, const std::string& propertyName, luabind::object const& prop, bool addIfNotFound);
1033 
1041  const std::string& context, const std::string& propertyName,
1042  luabind::object const& keyValues, luabind::object const& itemValue);
1043 
1050  const std::string& context, const std::string& propertyName,
1051  int index, luabind::object const& itemValue);
1052 
1059  bool luaSetInternalStatePropertyMapItem(lua_State* L, DtScriptOwnshipObject& entity,
1060  const std::string& context, const std::string& propertyName,
1061  luabind::object const& keyValue, luabind::object const& itemValue);
1062 
1068  luabind::object luaGetStateProperty(lua_State* L,
1069  const DtScriptVrfObject& entity, const std::string& propertyName);
1070  luabind::object luaGetStateOwnshipProperty(lua_State* L,
1071  const DtScriptOwnshipObject& entity, const std::string& propertyName);
1072 
1082  luabind::object luaGetStatePropertyListItem(lua_State* L,
1083  const DtScriptVrfObject& entity, const std::string& propertyName,
1084  luabind::object const& keyValues, int& index);
1085  luabind::object luaGetStateOwnshipPropertyListItem(lua_State* L,
1086  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1087  luabind::object const& keyValues, int& index);
1088 
1097  luabind::object luaGetStatePropertyListItemByIndex(lua_State* L,
1098  const DtScriptVrfObject& entity, const std::string& propertyName,
1099  int index);
1100  luabind::object luaGetStateOwnshipPropertyListItemByIndex(lua_State* L,
1101  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1102  int index);
1103 
1112  luabind::object luaGetStatePropertyMapItem(lua_State* L,
1113  const DtScriptVrfObject& entity, const std::string& propertyName,
1114  luabind::object const& keyValue);
1115  luabind::object luaGetStateOwnshipPropertyMapItem(lua_State* L,
1116  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1117  luabind::object const& keyValue);
1118 
1123  luabind::object luaGetInternalStateProperty(lua_State* L, const DtScriptOwnshipObject& entity,
1124  const std::string& context, const std::string& propertyName);
1125 
1134  luabind::object luaGetInternalStatePropertyListItem(lua_State* L, const DtScriptOwnshipObject& entity,
1135  const std::string& context, const std::string& propertyName,
1136  luabind::object const& keyValues, int& index);
1137 
1145  luabind::object luaGetInternalStatePropertyListItemByIndex(lua_State* L, const DtScriptOwnshipObject& entity,
1146  const std::string& context, const std::string& propertyName, int index);
1147 
1155  luabind::object luaGetInternalStatePropertyMapItem(lua_State* L, const DtScriptOwnshipObject& entity,
1156  const std::string& context, const std::string& propertyName, luabind::object const& keyValue);
1157 
1162  luabind::object luaGetParamProperty(lua_State* L,
1163  const DtScriptVrfObject& entity, std::string const& paramName);
1164  luabind::object luaGetOwnshipParamProperty(lua_State* L,
1165  const DtScriptOwnshipObject& entity, std::string const& paramName);
1166 
1175  luabind::object luaGetParameterPropertyListItem(lua_State* L,
1176  const DtScriptVrfObject& entity, const std::string& propertyName,
1177  luabind::object const& keyValues, int& index);
1178  luabind::object luaGetOwnshipParameterPropertyListItem(lua_State* L,
1179  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1180  luabind::object const& keyValues, int& index);
1181 
1189  luabind::object luaGetParameterPropertyListItemByIndex(lua_State* L,
1190  const DtScriptVrfObject& entity, const std::string& propertyName,
1191  int index);
1192  luabind::object luaGetOwnshipParameterPropertyListItemByIndex(lua_State* L,
1193  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1194  int index);
1195 
1203  luabind::object luaGetParameterPropertyMapItem(lua_State* L,
1204  const DtScriptVrfObject& entity, const std::string& propertyName,
1205  luabind::object const& keyValue);
1206  luabind::object luaGetOwnshipParameterPropertyMapItem(lua_State* L,
1207  const DtScriptOwnshipObject& entity, const std::string& propertyName,
1208  luabind::object const& keyValue);
1209 
1210  bool luaSetSystemAttribute(
1211  DtScriptComponentSystem& system, const std::string& attributeName,
1212  const luabind::object & value,
1213  lua_State *L);
1214 
1215  static const std::map<DtString, rwToLuaBindObjectFcn>& rwToLuaBindObjectMap();
1216 };
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:211
General settings that apply to all modes.
Definition: iffMode5Settings.h:12
std::vector< DtVrfObjectMessage * > myTextReportCallbacks
Definition: luaScriptInterfaceImpl.h:830
virtual bool operator<(const DtScriptFunctionReference &other) const override
Required for std::set.
Definition: luaScriptInterfaceImpl.h:730
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:24
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
virtual bool taskFailedDuringInit() const override
Returns true if the script deliberately ended its own task with a failure status while init was runni...
Definition: luaScriptInterfaceImpl.h:78
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:821
std::vector< LuaExtension > GlobalInterfaceExtensions
Definition: luaScriptInterfaceImpl.h:819
lua_State * myLState
Definition: luaScriptInterfaceImpl.h:801
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:802
static ReaderWriterToLuaTableMap & theReaderWriterToLuaTableMap
Never-destroyed (leaky) singleton: avoids a cross-TU static-destruction-order double-free at exit...
Definition: luaScriptInterfaceImpl.h:827
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:320
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
virtual void processEvents()=0
Process any enqueued events like text or influence.
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:806
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:803
Definition: iffBasicModeSettings.h:100
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:725
DtLuaScriptFunctionReference(const std::string &functionName)
Definition: luaScriptInterfaceImpl.h:714
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:811
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:815
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:721
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:850
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:711
std::vector< DtLuaScriptInterfaceExtension * > LocalInterfaceExtensions
Definition: luaScriptInterfaceImpl.h:805
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:831
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:97
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:810
std::map< DtString, ReaderWriterToLuaTableFcn > ReaderWriterToLuaTableMap
Definition: luaScriptInterfaceImpl.h:825
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:823
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:816
const char ContactHostileOnly[]
Definition: luaScriptInterfaceImpl.h:50
Definition: luaScriptInterfaceImpl.h:808
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:828
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:746
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:28
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 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)