Added 'Safepoints' to the resetPlayer script.
This commit is contained in:
parent
bb30aee8d3
commit
79faa2edea
@ -15,7 +15,7 @@ function trigger(objectToChange)
|
|||||||
|
|
||||||
local strength = 100
|
local strength = 100
|
||||||
local xPos = 17.5
|
local xPos = 17.5
|
||||||
local yPos = 33
|
local yPos = 33.0
|
||||||
local zPos = 81.5
|
local zPos = 81.5
|
||||||
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ function triggerUndo(objectToChange)
|
|||||||
|
|
||||||
local strength = 100
|
local strength = 100
|
||||||
local xPos = 17.5
|
local xPos = 17.5
|
||||||
local yPos = 25
|
local yPos = 25.0
|
||||||
local zPos = 81.5
|
local zPos = 81.5
|
||||||
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
||||||
|
|
||||||
|
@ -22,16 +22,8 @@ function trigger(objectToChange)
|
|||||||
global.triggeredOpenSecondDoor1 = true
|
global.triggeredOpenSecondDoor1 = true
|
||||||
|
|
||||||
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
|
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
|
||||||
if(global.openSecondDoorCounter == 4) then
|
|
||||||
local strength = 100
|
|
||||||
local xPos = -81.5
|
|
||||||
local yPos = 33
|
|
||||||
local zPos = 4.5
|
|
||||||
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
|
||||||
else
|
|
||||||
global.triggeredOpenSecondDoor1Undo = false
|
global.triggeredOpenSecondDoor1Undo = false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
print("openSecondDoor1")
|
print("openSecondDoor1")
|
||||||
end
|
end
|
||||||
|
@ -22,16 +22,8 @@ function trigger(objectToChange)
|
|||||||
global.triggeredOpenSecondDoor2 = true
|
global.triggeredOpenSecondDoor2 = true
|
||||||
|
|
||||||
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
|
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
|
||||||
if(global.openSecondDoorCounter == 4) then
|
|
||||||
local strength = 100
|
|
||||||
local xPos = -81.5
|
|
||||||
local yPos = 33
|
|
||||||
local zPos = 4.5
|
|
||||||
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
|
||||||
else
|
|
||||||
global.triggeredOpenSecondDoor2Undo = false
|
global.triggeredOpenSecondDoor2Undo = false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
print("openSecondDoor2")
|
print("openSecondDoor2")
|
||||||
end
|
end
|
||||||
|
@ -22,16 +22,8 @@ function trigger(objectToChange)
|
|||||||
global.triggeredOpenSecondDoor3 = true
|
global.triggeredOpenSecondDoor3 = true
|
||||||
|
|
||||||
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
|
if(global.triggeredOpenSecondDoor1 == true and global.triggeredOpenSecondDoor2 == true and global.triggeredOpenSecondDoor3 == true and global.triggeredOpenSecondDoor4 == true) then
|
||||||
if(global.openSecondDoorCounter == 4) then
|
|
||||||
local strength = 100
|
|
||||||
local xPos = -81.5
|
|
||||||
local yPos = 33
|
|
||||||
local zPos = 4.5
|
|
||||||
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
|
||||||
else
|
|
||||||
global.triggeredOpenSecondDoor3Undo = false
|
global.triggeredOpenSecondDoor3Undo = false
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
print("openSecondDoor3")
|
print("openSecondDoor3")
|
||||||
end
|
end
|
||||||
|
@ -28,6 +28,7 @@ function trigger(objectToChange)
|
|||||||
local yPos = 33
|
local yPos = 33
|
||||||
local zPos = 4.5
|
local zPos = 4.5
|
||||||
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
||||||
|
global.openedSecondDoor = true
|
||||||
else
|
else
|
||||||
global.triggeredOpenSecondDoor4Undo = false
|
global.triggeredOpenSecondDoor4Undo = false
|
||||||
end
|
end
|
||||||
|
@ -8,8 +8,19 @@ function trigger(objectToChange)
|
|||||||
print("No level found in Lua!")
|
print("No level found in Lua!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
if(global.triggeredOpenFirstDoor == true) then
|
||||||
|
if(global.openedSecondDoor == true) then
|
||||||
|
if(global.triggeredOpenThirdDoor == true) then
|
||||||
|
level:movePlayer(-169.5,22.5,58.5)
|
||||||
|
else
|
||||||
|
level:movePlayer(-78.5,22.5,4.5)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
level:movePlayer(17.5,22.5,87.0)
|
||||||
|
end
|
||||||
|
else
|
||||||
level:resetPlayer()
|
level:resetPlayer()
|
||||||
|
end
|
||||||
|
|
||||||
--global.triggeredResetPlayer = true
|
--global.triggeredResetPlayer = true
|
||||||
print("reset player")
|
print("reset player")
|
||||||
|
9
level.cc
9
level.cc
@ -39,6 +39,7 @@ void Level::load() {
|
|||||||
.addFunction("getObjectCount", &Level::getPhysicsObjectsVectorSize)
|
.addFunction("getObjectCount", &Level::getPhysicsObjectsVectorSize)
|
||||||
.addFunction("moveObject", &Level::moveObject)
|
.addFunction("moveObject", &Level::moveObject)
|
||||||
.addFunction("resetPlayer", &Level::resetPlayer)
|
.addFunction("resetPlayer", &Level::resetPlayer)
|
||||||
|
.addFunction("movePlayer", &Level::movePlayer)
|
||||||
.endClass();
|
.endClass();
|
||||||
//Push the level to Lua as a global variable
|
//Push the level to Lua as a global variable
|
||||||
luabridge::push(luaState, this);
|
luabridge::push(luaState, this);
|
||||||
@ -188,8 +189,12 @@ void Level::deleteObject(int objectIndex){
|
|||||||
void Level::resetPlayer(){
|
void Level::resetPlayer(){
|
||||||
Loader loader = Loader();
|
Loader loader = Loader();
|
||||||
glm::vec3 newPosition = loader.reloadPlayerPosition(xmlFilePath, this);
|
glm::vec3 newPosition = loader.reloadPlayerPosition(xmlFilePath, this);
|
||||||
physics.forceMove(newPosition, playerIndex);
|
physics.forcePlayer(newPosition);
|
||||||
physics.forceMoveCamera(newPosition + glm::vec3(1,0,0));
|
}
|
||||||
|
|
||||||
|
void Level::movePlayer(float xPosition, float yPosition, float zPosition){
|
||||||
|
glm::vec3 newPosition = glm::vec3(xPosition, yPosition, zPosition);
|
||||||
|
physics.forcePlayer(newPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Level::setPlayerIndex(int index){
|
void Level::setPlayerIndex(int index){
|
||||||
|
1
level.hh
1
level.hh
@ -57,6 +57,7 @@ class Level {
|
|||||||
lua_State* getLuaState();
|
lua_State* getLuaState();
|
||||||
Terrain* getTerrain();
|
Terrain* getTerrain();
|
||||||
void resetPlayer();
|
void resetPlayer();
|
||||||
|
void movePlayer(float xPosition, float yPosition, float zPosition);
|
||||||
void setPlayerIndex(int index);
|
void setPlayerIndex(int index);
|
||||||
private:
|
private:
|
||||||
lua_State* luaState=nullptr;
|
lua_State* luaState=nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user