galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::components::Script Class Referencefinal

High level abstraction of a lua script. More...

#include <Script.hpp>

+ Inheritance diagram for galaxy::components::Script:
+ Collaboration diagram for galaxy::components::Script:

Public Member Functions

 Script ()
 Constructor.
 
 Script (const nlohmann::json &json)
 JSON constructor.
 
 Script (Script &&)
 Move constructor.
 
Scriptoperator= (Script &&)
 Move assignment operator.
 
virtual ~Script ()
 Destructor.
 
const std::string & file () const
 Get script file path.
 
nlohmann::json serialize () override
 Serializes object.
 
void deserialize (const nlohmann::json &json) override
 Deserializes from object.
 
- Public Member Functions inherited from galaxy::fs::Serializable
virtual ~Serializable ()
 Destructor.
 
virtual Serializableoperator= (Serializable &&)=default
 Move assignment operator.
 
virtual Serializableoperator= (const Serializable &)=default
 Copy assignment operator.
 

Public Attributes

sol::table m_self
 The script object (table) returned by a lua script.
 
sol::function m_update
 The update function belonging to the lua table.
 

Private Member Functions

void load (std::string_view file)
 Load a script.
 
Scriptoperator= (const Script &)=delete
 Copy assignment operator.
 
 Script (const Script &)=delete
 Copy constructor.
 

Private Attributes

std::string m_file
 Script file.
 
bool m_show_functions = false
 For editor. Show functions.
 
bool m_show_userdata = false
 For editor. Shows userdata types.
 
bool m_show_unknown = false
 For editor. Show unknown type data.
 

Additional Inherited Members

- Protected Member Functions inherited from galaxy::fs::Serializable
 Serializable ()
 Constructor.
 

Detailed Description

High level abstraction of a lua script.

Definition at line 30 of file Script.hpp.

Constructor & Destructor Documentation

◆ Script() [1/4]

galaxy::components::Script::Script ( )

Constructor.

Definition at line 19 of file Script.cpp.

◆ Script() [2/4]

galaxy::components::Script::Script ( const nlohmann::json & json)

JSON constructor.

Parameters
jsonJSON defining object.

Definition at line 24 of file Script.cpp.

+ Here is the call graph for this function:

◆ Script() [3/4]

galaxy::components::Script::Script ( Script && s)

Move constructor.

Definition at line 30 of file Script.cpp.

◆ ~Script()

galaxy::components::Script::~Script ( )
virtual

Destructor.

Definition at line 55 of file Script.cpp.

◆ Script() [4/4]

galaxy::components::Script::Script ( const Script & )
privatedelete

Copy constructor.

Member Function Documentation

◆ operator=() [1/2]

Script & galaxy::components::Script::operator= ( Script && s)

Move assignment operator.

Definition at line 40 of file Script.cpp.

◆ file()

const std::string & galaxy::components::Script::file ( ) const
nodiscard

Get script file path.

Returns
Const string reference.

Definition at line 81 of file Script.cpp.

+ Here is the caller graph for this function:

◆ serialize()

nlohmann::json galaxy::components::Script::serialize ( )
nodiscardoverridevirtual

Serializes object.

Returns
JSON object containing data to be serialized.

Implements galaxy::fs::Serializable.

Definition at line 86 of file Script.cpp.

◆ deserialize()

void galaxy::components::Script::deserialize ( const nlohmann::json & json)
overridevirtual

Deserializes from object.

Parameters
jsonJson object to retrieve data from.

Implements galaxy::fs::Serializable.

Definition at line 97 of file Script.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load()

void galaxy::components::Script::load ( std::string_view file)
private

Load a script.

Parameters
fileFile in VFS to load as a script.

Definition at line 59 of file Script.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [2/2]

Script & galaxy::components::Script::operator= ( const Script & )
privatedelete

Copy assignment operator.

Member Data Documentation

◆ m_self

sol::table galaxy::components::Script::m_self

The script object (table) returned by a lua script.

Definition at line 107 of file Script.hpp.

◆ m_update

sol::function galaxy::components::Script::m_update

The update function belonging to the lua table.

Definition at line 112 of file Script.hpp.

◆ m_file

std::string galaxy::components::Script::m_file
private

Script file.

Definition at line 118 of file Script.hpp.

◆ m_show_functions

bool galaxy::components::Script::m_show_functions = false
private

For editor. Show functions.

Definition at line 123 of file Script.hpp.

◆ m_show_userdata

bool galaxy::components::Script::m_show_userdata = false
private

For editor. Shows userdata types.

Definition at line 128 of file Script.hpp.

◆ m_show_unknown

bool galaxy::components::Script::m_show_unknown = false
private

For editor. Show unknown type data.

Definition at line 133 of file Script.hpp.


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