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
Script.hpp
Go to the documentation of this file.
1
7
8#ifndef GALAXY_COMPONENTS_SCRIPT_HPP_
9#define GALAXY_COMPONENTS_SCRIPT_HPP_
10
11#include <sol/sol.hpp>
12
14
15namespace sc
16{
17 namespace panel
18 {
19 class EntityEditor;
20 } // namespace panel
21} // namespace sc
22
23namespace galaxy
24{
25 namespace components
26 {
30 class Script final : public fs::Serializable
31 {
32 friend class sc::panel::EntityEditor;
33
34 public:
38 Script();
39
45 Script(const nlohmann::json& json);
46
50 Script(Script&&);
51
56
60 virtual ~Script();
61
67 [[nodiscard]]
68 const std::string& file() const;
69
75 [[nodiscard]]
76 nlohmann::json serialize() override;
77
83 void deserialize(const nlohmann::json& json) override;
84
85 private:
91 void load(std::string_view file);
92
96 Script& operator=(const Script&) = delete;
97
101 Script(const Script&) = delete;
102
103 public:
107 sol::table m_self;
108
112 sol::function m_update;
113
114 private:
118 std::string m_file;
119
123 bool m_show_functions = false;
124
128 bool m_show_userdata = false;
129
133 bool m_show_unknown = false;
134 };
135 } // namespace components
136} // namespace galaxy
137
138#endif
High level abstraction of a lua script.
Definition Script.hpp:31
virtual ~Script()
Destructor.
Definition Script.cpp:55
bool m_show_userdata
For editor. Shows userdata types.
Definition Script.hpp:128
bool m_show_unknown
For editor. Show unknown type data.
Definition Script.hpp:133
const std::string & file() const
Get script file path.
Definition Script.cpp:81
Script & operator=(Script &&)
Move assignment operator.
Definition Script.cpp:40
void deserialize(const nlohmann::json &json) override
Deserializes from object.
Definition Script.cpp:97
void load(std::string_view file)
Load a script.
Definition Script.cpp:59
bool m_show_functions
For editor. Show functions.
Definition Script.hpp:123
nlohmann::json serialize() override
Serializes object.
Definition Script.cpp:86
Script(const Script &)=delete
Copy constructor.
sol::table m_self
The script object (table) returned by a lua script.
Definition Script.hpp:107
Script & operator=(const Script &)=delete
Copy assignment operator.
std::string m_file
Script file.
Definition Script.hpp:118
sol::function m_update
The update function belonging to the lua table.
Definition Script.hpp:112
Allows a class to be serialized.
Timer.hpp galaxy.
Definition Async.hpp:17
Script.hpp galaxy.
Definition Script.hpp:16