aboutsummaryrefslogtreecommitdiffstats
path: root/src/script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script.cpp')
-rw-r--r--src/script.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/script.cpp b/src/script.cpp
index 80ac538..30328ab 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -80,6 +80,7 @@ void ScriptSystem::doFile(void)
#include <components/Render.hpp>
#include <components/Script.hpp>
#include <components/Velocity.hpp>
+#include <components/Light.hpp>
void ScriptSystem::scriptExport(void)
{
@@ -108,6 +109,13 @@ void ScriptSystem::scriptExport(void)
lua.new_usertype<Player>("Player",
sol::constructors<Player(void), Player()>());
+ lua.new_usertype<Light>("Light",
+ sol::constructors<Light(float, float, float, float)>(),
+ "r", &Light::r,
+ "g", &Light::g,
+ "b", &Light::b,
+ "strength", &Light::strength);
+
auto gamespace = lua["game"].get_or_create<sol::table>();
gamespace.set_function("spawn", func);
}
@@ -162,6 +170,11 @@ sol::table ScriptSystem::spawn(sol::object param)
(*toRet)["Player"] = e.assign<Player>().get();
}
+ if (tab["Light"] != nullptr) {
+ (*toRet)["Light"] =
+ e.assign<Light>(Light().FromLua(tab["Light"])).get();
+ }
+
} else {
// TODO better logging
std::cerr << "Parameter to spawn() must be a table!" << std::endl;