diff --git a/data/levels/Level1.xml b/data/levels/Level1.xml
index 76335e2..2b937a8 100644
--- a/data/levels/Level1.xml
+++ b/data/levels/Level1.xml
@@ -11776,18 +11776,19 @@
105
20
- -
+ resetPlayer
+ false
0
- 0
+ -100000
0
-
-
- 1.0
+ 100015
false
0
- -
+ resetPlayer.lua
0
- 0
+ 105
0
diff --git a/data/levels/scripts/resetPlayer.lua b/data/levels/scripts/resetPlayer.lua
new file mode 100644
index 0000000..4428ee6
--- /dev/null
+++ b/data/levels/scripts/resetPlayer.lua
@@ -0,0 +1,17 @@
+local global = require( "global" )
+if(global.triggeredResetPlayer == nil) then
+ global.triggeredResetPlayer = false
+end
+function trigger(objectToChange)
+ if(global.triggeredResetPlayer == false) then
+ if(not level) then
+ print("No level found in Lua!")
+ return
+ end
+
+ level:resetPlayer()
+
+ --global.triggeredResetPlayer = true
+ print("reset player")
+ end
+end
diff --git a/level.cc b/level.cc
index 394922b..d8ba583 100644
--- a/level.cc
+++ b/level.cc
@@ -38,6 +38,7 @@ void Level::load() {
.addFunction("deleteObject", &Level::deleteObject)
.addFunction("getObjectCount", &Level::getPhysicsObjectsVectorSize)
.addFunction("moveObject", &Level::moveObject)
+ .addFunction("resetPlayer", &Level::resetPlayer)
.endClass();
//Push the level to Lua as a global variable
luabridge::push(luaState, this);
@@ -180,7 +181,12 @@ void Level::deleteObject(int objectIndex){
void Level::resetPlayer(){
Loader loader = Loader();
glm::vec3 newPosition = loader.reloadPlayerPosition(xmlFilePath, this);
- //TODO cameraCenter.setPosition(newPosition);
+ physics.forceMove(newPosition, playerIndex);
+ physics.forceMoveCamera(newPosition + glm::vec3(1,0,0));
+}
+
+void Level::setPlayerIndex(int index){
+ playerIndex = index;
}
void Level::setStrength(float strength) {
diff --git a/level.hh b/level.hh
index 1062013..40f2976 100644
--- a/level.hh
+++ b/level.hh
@@ -56,6 +56,7 @@ class Level {
lua_State* getLuaState();
Terrain* getTerrain();
void resetPlayer();
+ void setPlayerIndex(int index);
private:
lua_State* luaState=nullptr;
std::vector