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 xPos = 17.5
|
||||
local yPos = 33
|
||||
local yPos = 33.0
|
||||
local zPos = 81.5
|
||||
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
||||
|
||||
@ -35,7 +35,7 @@ function triggerUndo(objectToChange)
|
||||
|
||||
local strength = 100
|
||||
local xPos = 17.5
|
||||
local yPos = 25
|
||||
local yPos = 25.0
|
||||
local zPos = 81.5
|
||||
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
||||
|
||||
|
@ -22,16 +22,8 @@ function trigger(objectToChange)
|
||||
global.triggeredOpenSecondDoor1 = true
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
print("openSecondDoor1")
|
||||
end
|
||||
|
@ -22,16 +22,8 @@ function trigger(objectToChange)
|
||||
global.triggeredOpenSecondDoor2 = true
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
print("openSecondDoor2")
|
||||
end
|
||||
|
@ -22,16 +22,8 @@ function trigger(objectToChange)
|
||||
global.triggeredOpenSecondDoor3 = true
|
||||
|
||||
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
|
||||
end
|
||||
end
|
||||
|
||||
print("openSecondDoor3")
|
||||
end
|
||||
|
@ -28,6 +28,7 @@ function trigger(objectToChange)
|
||||
local yPos = 33
|
||||
local zPos = 4.5
|
||||
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
|
||||
global.openedSecondDoor = true
|
||||
else
|
||||
global.triggeredOpenSecondDoor4Undo = false
|
||||
end
|
||||
|
@ -8,8 +8,19 @@ function trigger(objectToChange)
|
||||
print("No level found in Lua!")
|
||||
return
|
||||
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()
|
||||
end
|
||||
|
||||
--global.triggeredResetPlayer = true
|
||||
print("reset player")
|
||||
|
9
level.cc
9
level.cc
@ -39,6 +39,7 @@ void Level::load() {
|
||||
.addFunction("getObjectCount", &Level::getPhysicsObjectsVectorSize)
|
||||
.addFunction("moveObject", &Level::moveObject)
|
||||
.addFunction("resetPlayer", &Level::resetPlayer)
|
||||
.addFunction("movePlayer", &Level::movePlayer)
|
||||
.endClass();
|
||||
//Push the level to Lua as a global variable
|
||||
luabridge::push(luaState, this);
|
||||
@ -188,8 +189,12 @@ void Level::deleteObject(int objectIndex){
|
||||
void Level::resetPlayer(){
|
||||
Loader loader = Loader();
|
||||
glm::vec3 newPosition = loader.reloadPlayerPosition(xmlFilePath, this);
|
||||
physics.forceMove(newPosition, playerIndex);
|
||||
physics.forceMoveCamera(newPosition + glm::vec3(1,0,0));
|
||||
physics.forcePlayer(newPosition);
|
||||
}
|
||||
|
||||
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){
|
||||
|
Loading…
Reference in New Issue
Block a user