aboutsummaryrefslogtreecommitdiffstats
path: root/src/script.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2019-09-02 15:15:26 -0400
committerClyne Sullivan <clyne@bitgloo.com>2019-09-02 15:15:26 -0400
commit46393662672f2510a40eb6cd5291f99a7ae14e3c (patch)
tree8b11793b474ebc6e7359289bd9e9704d58a7f58a /src/script.cpp
parentc1161dc0d8939814abf7da48d03b887c0aead0ff (diff)
parent062a7e2baad74f49f2548793a25f0cf5e4ae6f86 (diff)
Merge branch 'master' of https://github.com/tcsullivan/gamedev2 into save-load
Diffstat (limited to 'src/script.cpp')
-rw-r--r--src/script.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/script.cpp b/src/script.cpp
index 80ac538..fa485bc 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -36,10 +36,14 @@ void ScriptSystem::configure(entityx::EntityManager& entities,
//init();
}
-void ScriptSystem::update([[maybe_unused]] entityx::EntityManager& entites,
+#include <components/Script.hpp>
+void ScriptSystem::update([[maybe_unused]] entityx::EntityManager& entities,
[[maybe_unused]] entityx::EventManager& events,
[[maybe_unused]] entityx::TimeDelta dt)
{
+ entities.each<Scripted>([](entityx::Entity, Scripted &s){
+ s.updatePhysics();
+ });
}
@@ -80,6 +84,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)
{
@@ -98,7 +103,8 @@ void ScriptSystem::scriptExport(void)
lua.new_usertype<Render>("Render",
sol::constructors<Render(std::string), Render()>(),
"visible", &Render::visible,
- "texture", &Render::texture);
+ "texture", &Render::texture,
+ "flipx", &Render::flipX);
lua.new_usertype<Velocity>("Velocity",
sol::constructors<Velocity(double, double), Velocity()>(),
@@ -108,6 +114,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 +175,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;