diff options
author | Andy Belle-Isle <drumsetmonkey@gmail.com> | 2019-09-07 01:14:51 -0400 |
---|---|---|
committer | Andy Belle-Isle <drumsetmonkey@gmail.com> | 2019-09-07 01:14:51 -0400 |
commit | dfb62a419e0c283131f9627f23b6eb42aa28290c (patch) | |
tree | 73959755e4c9d291232e3d0fdefb9804a4c7cb83 /src | |
parent | 25256900e7c228ff2216cfc515599d5541844d2b (diff) |
Added physics to the script system
Diffstat (limited to 'src')
-rw-r--r-- | src/script.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/script.cpp b/src/script.cpp index d8f23ec..e1dea6a 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -86,6 +86,7 @@ void ScriptSystem::doFile(void) #include <components/Script.hpp> #include <components/Velocity.hpp> #include <components/Light.hpp> +#include <components/Physics.hpp> void ScriptSystem::scriptExport(void) { @@ -122,6 +123,10 @@ void ScriptSystem::scriptExport(void) "b", &Light::b, "strength", &Light::strength); + lua.new_usertype<Physics>("Physics", + sol::constructors<Physics(void), Physics()>(), + "standing", &Physics::standing); + auto gamespace = lua["game"].get_or_create<sol::table>(); gamespace.set_function("spawn", func); } @@ -176,6 +181,15 @@ sol::table ScriptSystem::spawn(sol::object param) (*toRet)["Player"] = e.assign<Player>().get(); } + if (tab["Physics"] != nullptr) { + if (!e.has_component<Position>()) // Position must exist for phys. + (*toRet)["Position"] = e.assign<Position>().get(); + if (!e.has_component<Velocity>()) // Velocity must exist for phys. + (*toRet)["Velocity"] = e.assign<Velocity>().get(); + + (*toRet)["Physics"] = e.assign<Physics>().get(); + } + if (tab["Light"] != nullptr) { if (!e.has_component<Position>()) // Position must exist for vel. (*toRet)["Position"] = e.assign<Position>().get(); |