Added a trigger that resets the player when his z value is below 15.
This commit is contained in:
parent
f3520639c9
commit
47bd2d29df
@ -11776,18 +11776,19 @@
|
||||
<idBlue>105</idBlue>
|
||||
<typeID>20</typeID>
|
||||
<trigger>
|
||||
<name>-</name>
|
||||
<name>resetPlayer</name>
|
||||
<undo>false</undo>
|
||||
<xPosition>0</xPosition>
|
||||
<yPosition>0</yPosition>
|
||||
<yPosition>-100000</yPosition>
|
||||
<zPosition>0</zPosition>
|
||||
<targetIdGreen>-</targetIdGreen>
|
||||
<targetIdBlue>-</targetIdBlue>
|
||||
<distance>1.0</distance>
|
||||
<distance>100015</distance>
|
||||
<isBiggerThan>false</isBiggerThan>
|
||||
<objectNum>0</objectNum>
|
||||
<luaScript>-</luaScript>
|
||||
<luaScript>resetPlayer.lua</luaScript>
|
||||
<toChangeIdGreen>0</toChangeIdGreen>
|
||||
<toChangeIdBlue>0</toChangeIdBlue>
|
||||
<toChangeIdBlue>105</toChangeIdBlue>
|
||||
<toChangeObjNum>0</toChangeObjNum>
|
||||
</trigger>
|
||||
</composition>
|
||||
|
17
data/levels/scripts/resetPlayer.lua
Normal file
17
data/levels/scripts/resetPlayer.lua
Normal file
@ -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
|
8
level.cc
8
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) {
|
||||
|
2
level.hh
2
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<Object*> objects;
|
||||
@ -66,6 +67,7 @@ class Level {
|
||||
glm::vec4 fogColour;
|
||||
Light directionalLight;
|
||||
Object* cameraCenter;
|
||||
int playerIndex;
|
||||
Object* skydome;
|
||||
Physics physics;
|
||||
Camera camera;
|
||||
|
Loading…
Reference in New Issue
Block a user