diff --git a/data/levels/Level1.xml b/data/levels/Level1.xml index 5e5b277..82d3e92 100644 --- a/data/levels/Level1.xml +++ b/data/levels/Level1.xml @@ -4782,18 +4782,19 @@ 2 240 - - + resetBox + false 0 - 0 + -100000 0 - - - 1.0 + 100015 false 0 - - + resetBox.lua 0 - 0 + 2 0 diff --git a/data/levels/scripts/resetBox.lua b/data/levels/scripts/resetBox.lua new file mode 100644 index 0000000..6fb37ef --- /dev/null +++ b/data/levels/scripts/resetBox.lua @@ -0,0 +1,19 @@ +local global = require( "global" ) +if(global.triggeredResetBox == nil) then + global.triggeredResetBox = false +end + +function trigger(objectToChange) + if(global.triggeredResetBox == false) then + if(not level) then + print("No level found in Lua!") + return + end + local x = -101.5 + local y = 22.5 + local z =8.5 + level:forceMove(x, y, z, objectToChange) + + print("reset box") + end +end diff --git a/level.cc b/level.cc index 6ac2f8f..6dee656 100644 --- a/level.cc +++ b/level.cc @@ -41,6 +41,7 @@ void Level::load() { .addFunction("resetPlayer", &Level::resetPlayer) .addFunction("movePlayer", &Level::movePlayer) .addFunction("setSunDirection", &Level::setSunDirection) + .addFunction("forceMove", &Level::forceMove) .endClass(); //Push the level to Lua as a global variable luabridge::push(luaState, this); @@ -272,3 +273,8 @@ Terrain* Level::getTerrain() { Skydome* Level::getSkydome() { return &skydome; } + +void Level::forceMove(float x, float y, float z, unsigned indice){ + glm::vec3 position = glm::vec3(x,y,z); + physics.forceMove(position, indice); +} diff --git a/level.hh b/level.hh index e18db48..4c4b382 100644 --- a/level.hh +++ b/level.hh @@ -61,6 +61,7 @@ class Level { void resetPlayer(); void movePlayer(float xPosition, float yPosition, float zPosition); void setPlayerIndex(int index); + void forceMove(float x, float y, float z, unsigned indice); private: lua_State* luaState=nullptr; std::vector objects;