VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtScriptComponent Class Reference

Detailed Description

DtScriptComponent loads and executes Lua scripts within the player component lifecycle, allowing custom behavior implementation through scripts rather than C++ code. Scripts have access to the player attribute store and can implement initialize, postInitialize, tick, and shutdown callbacks that align with the component lifecycle methods.

Note
Based on implementation examination, this component may be deprecated or temporarily disabled in the current codebase.

#include <scriptComponent.h>

Inheritance diagram for makVre::DtScriptComponent:
[legend]

Public Member Functions

 DtScriptComponent ()
 
virtual ~DtScriptComponent () override
 
virtual bool initialize (makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
 
virtual bool postInitialize () override
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual const char * type () const override
 
virtual void reload ()
 
- Public Member Functions inherited from makVre::DtPlayerComponent
 DtPlayerComponent ()
 
virtual ~DtPlayerComponent ()
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStationplayer ()
 
virtual DtAttributeHandleplayerAttributeStore ()
 
virtual const DtAttributeHandleplayerAttributeStore () const
 

Protected Member Functions

virtual bool setupVm ()
 
virtual void shutdownVm ()
 
- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Protected Attributes

std::string myScriptFilename
 
std::string myScriptConfig
 
DtLuaStatemyVm
 
- Protected Attributes inherited from makVre::DtPlayerComponent
std::string myName
 
DtInitTable myConfig
 
DtPlayerStationmyPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolvermyResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 

Constructor & Destructor Documentation

◆ DtScriptComponent()

makVre::DtScriptComponent::DtScriptComponent ( )

Constructor for DtScriptComponent.

Initializes the component with the name "DtScriptedUpdater"

◆ ~DtScriptComponent()

virtual makVre::DtScriptComponent::~DtScriptComponent ( )
overridevirtual

Virtual destructor for DtScriptComponent.

Member Function Documentation

◆ initialize()

virtual bool makVre::DtScriptComponent::initialize ( makVre::DtPlayerStation * player,
makVre::DtInitTable & config )
overridevirtual

Initializes the script component.

Parameters
playerPointer to the player station this component belongs to
configConfiguration table containing script settings
Returns
True if initialization succeeded, false otherwise

Loads the script file specified in the config and initializes the Lua VM. Serializes any scriptConfig table for passing to the script's initialize function.

Reimplemented from makVre::DtPlayerComponent.

References makVre::DtPlayerComponent::player().

◆ postInitialize()

virtual bool makVre::DtScriptComponent::postInitialize ( )
overridevirtual

Performs post-initialization after all components are initialized.

Returns
True if post-initialization succeeded, false otherwise

Calls the script's postInitialize function if it exists

Reimplemented from makVre::DtPlayerComponent.

◆ tick()

virtual void makVre::DtScriptComponent::tick ( double dt)
overridevirtual

Called every frame to update the script state.

Parameters
dtDelta time since the last frame in seconds

Calls the script's tick function, passing the delta time

Implements makVre::DtPlayerComponent.

◆ shutdown()

virtual void makVre::DtScriptComponent::shutdown ( )
overridevirtual

Shuts down the script component.

Calls the script's shutdown function if it exists and cleans up the Lua VM

Reimplemented from makVre::DtPlayerComponent.

◆ type()

virtual const char * makVre::DtScriptComponent::type ( ) const
overridevirtual

Returns the type identifier for this component.

Returns
The type string for DtScriptComponent

Implements makVre::DtPlayerComponent.

◆ reload()

virtual void makVre::DtScriptComponent::reload ( )
virtual

Reloads the script file.

Reinitializes the Lua VM and reloads the script file

◆ setupVm()

virtual bool makVre::DtScriptComponent::setupVm ( )
protectedvirtual

Sets up the Lua virtual machine.

Returns
True if VM setup succeeded, false otherwise

Creates a new Lua VM, loads serialization library, installs VR bindings, loads the script file, and calls the script's initialize function

◆ shutdownVm()

virtual void makVre::DtScriptComponent::shutdownVm ( )
protectedvirtual

Shuts down and cleans up the Lua virtual machine.

Member Data Documentation

◆ myScriptFilename

std::string makVre::DtScriptComponent::myScriptFilename
protected

Path to the Lua script file to execute.

◆ myScriptConfig

std::string makVre::DtScriptComponent::myScriptConfig
protected

Serialized configuration table to pass to the script.

◆ myVm

DtLuaState* makVre::DtScriptComponent::myVm
protected

Pointer to the Lua virtual machine instance.


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