Got scripts to work as intended, had to use an ugly hack for it.

This commit is contained in:
Steffen 2015-02-15 16:11:31 +01:00
parent de2ba0acb9
commit 0e550e52c6
5 changed files with 41 additions and 14 deletions

View File

@ -1337,6 +1337,21 @@
<toChangeIdBlue>133</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
<trigger>
<name>openFirstDoorUndo</name>
<xPosition>159.5</xPosition>
<yPosition>22</yPosition>
<zPosition>17.5</zPosition>
<targetIdGreen>-</targetIdGreen>
<targetIdBlue>-</targetIdBlue>
<distance>0.2</distance>
<isBiggerThan>false</isBiggerThan>
<objectNum>0</objectNum>
<luaScript>openFirstDoorUndo</luaScript>
<toChangeIdGreen>1</toChangeIdGreen>
<toChangeIdBlue>133</toChangeIdBlue>
<toChangeObjNum>0</toChangeObjNum>
</trigger>
</composition>
<composition>

View File

@ -1,8 +1,11 @@
if(triggeredSCRIPTNAME == nil) then
triggeredSCRIPTNAME = false
--I have no idea why this hack from the internet works, but it does...
package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path
local global = require( "global" )
if(global.triggeredSCRIPTNAME == nil) then
global.triggeredSCRIPTNAME = false
end
function trigger(objectToChange)
if(triggeredSCRIPTNAME == false) then
if(global.triggeredSCRIPTNAME == false) then
if(not level) then
print("No level found in Lua!")
return
@ -10,7 +13,7 @@ function trigger(objectToChange)
--enter the scripts code here and replace all occurences of SCRIPTNAME with the name of the script.
triggeredSCRIPTNAME = true
global.triggeredSCRIPTNAME = true
print("SCRIPTNAME")
end
end

View File

@ -0,0 +1,3 @@
--global variable space
local M = {}
return M

View File

@ -1,8 +1,11 @@
if(triggereOpenFirstDoor == nil) then
triggereOpenFirstDoor = false
--I have no idea why this hack from the internet works, but it does...
package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path
local global = require( "global" )
if(global.triggeredOpenFirstDoor == nil) then
global.triggeredOpenFirstDoor = false
end
function trigger(objectToChange)
if(triggereOpenFirstDoor == false) then
if(global.triggeredOpenFirstDoor == false) then
if(not level) then
print("No level found in Lua!")
return
@ -14,9 +17,9 @@ function trigger(objectToChange)
local zPos = 17.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
triggeredOpenFirstDoorUndo = false
global.triggeredOpenFirstDoorUndo = false
triggereOpenFirstDoor = true
global.triggeredOpenFirstDoor = true
print("openFirstDoor")
end
end

View File

@ -1,8 +1,11 @@
if(triggereOpenFirstDoorUndo == nil) then
triggereOpenFirstDoorUndo = false
--I have no idea why this hack from the internet works, but it does...
package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path
local global = require( "global" )
if(global.triggeredOpenFirstDoorUndo == nil) then
global.triggeredOpenFirstDoorUndo = true
end
function trigger(objectToChange)
if(triggereOpenFirstDoorUndo == false) then
if(global.triggeredOpenFirstDoorUndo == false) then
if(not level) then
print("No level found in Lua!")
return
@ -14,9 +17,9 @@ function trigger(objectToChange)
local zPos = 17.5
level:moveObject(objectToChange, strength, xPos, yPos, zPos)
triggeredOpenFirstDoor = false
global.triggeredOpenFirstDoor = false
triggereOpenFirstDoorUndo = true
global.triggeredOpenFirstDoorUndo = true
print("openFirstDoorUndo")
end
end