Added a reset for the second moveable box.

This commit is contained in:
Steffen Fündgens 2015-03-06 17:44:34 +01:00
parent 9a4cb335a0
commit 5778696d29
4 changed files with 32 additions and 5 deletions

View File

@ -4782,18 +4782,19 @@
<idBlue>2</idBlue>
<typeID>240</typeID>
<trigger>
<name>-</name>
<name>resetBox</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>resetBox.lua</luaScript>
<toChangeIdGreen>0</toChangeIdGreen>
<toChangeIdBlue>0</toChangeIdBlue>
<toChangeIdBlue>2</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
</composition>

View File

@ -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

View File

@ -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);
}

View File

@ -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<Object*> objects;