From: Andy Belle-Isle Date: Sat, 7 Sep 2019 05:14:51 +0000 (-0400) Subject: Added physics to the script system X-Git-Tag: v0.2-alpha~32 X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=dfb62a419e0c283131f9627f23b6eb42aa28290c;p=clyne%2Fgamedev2.git Added physics to the script system --- 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 #include #include +#include void ScriptSystem::scriptExport(void) { @@ -122,6 +123,10 @@ void ScriptSystem::scriptExport(void) "b", &Light::b, "strength", &Light::strength); + lua.new_usertype("Physics", + sol::constructors(), + "standing", &Physics::standing); + auto gamespace = lua["game"].get_or_create(); gamespace.set_function("spawn", func); } @@ -176,6 +181,15 @@ sol::table ScriptSystem::spawn(sol::object param) (*toRet)["Player"] = e.assign().get(); } + if (tab["Physics"] != nullptr) { + if (!e.has_component()) // Position must exist for phys. + (*toRet)["Position"] = e.assign().get(); + if (!e.has_component()) // Velocity must exist for phys. + (*toRet)["Velocity"] = e.assign().get(); + + (*toRet)["Physics"] = e.assign().get(); + } + if (tab["Light"] != nullptr) { if (!e.has_component()) // Position must exist for vel. (*toRet)["Position"] = e.assign().get();