Moved setting of package.path in lua to init.lua
This commit is contained in:
parent
f6b2cc938f
commit
23fc196bea
@ -1,5 +1,3 @@
|
|||||||
--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" )
|
local global = require( "global" )
|
||||||
if(global.triggeredSCRIPTNAME == nil) then
|
if(global.triggeredSCRIPTNAME == nil) then
|
||||||
global.triggeredSCRIPTNAME = false
|
global.triggeredSCRIPTNAME = false
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
--global variable space
|
--global variable space
|
||||||
local M = {}
|
local global = {}
|
||||||
return M
|
return global
|
||||||
|
4
data/levels/scripts/init.lua
Normal file
4
data/levels/scripts/init.lua
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
-- Inits search path for require.
|
||||||
|
-- This file needs to stay next to the other scripts.
|
||||||
|
|
||||||
|
package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .."?.lua;".. package.path
|
@ -1,5 +1,3 @@
|
|||||||
--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" )
|
local global = require( "global" )
|
||||||
if(global.triggeredOpenFirstDoor == nil) then
|
if(global.triggeredOpenFirstDoor == nil) then
|
||||||
global.triggeredOpenFirstDoor = false
|
global.triggeredOpenFirstDoor = false
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
--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" )
|
local global = require( "global" )
|
||||||
if(global.triggeredOpenFirstDoorUndo == nil) then
|
if(global.triggeredOpenFirstDoorUndo == nil) then
|
||||||
global.triggeredOpenFirstDoorUndo = true
|
global.triggeredOpenFirstDoorUndo = true
|
||||||
|
@ -380,6 +380,10 @@ void Loader::load(std::string filePath, Level* level, std::string compositionsPa
|
|||||||
}//iterating over all compositions in Level.xml
|
}//iterating over all compositions in Level.xml
|
||||||
|
|
||||||
//load triggers
|
//load triggers
|
||||||
|
|
||||||
|
// call init.lua to init the module load path in Lua
|
||||||
|
std::string initLuaPath = scriptPath + "init.lua";
|
||||||
|
luaL_dofile(level->getLuaState(), initLuaPath.c_str());
|
||||||
XMLElement* composition = doc->FirstChildElement("composition");
|
XMLElement* composition = doc->FirstChildElement("composition");
|
||||||
for(; composition; composition=composition->NextSiblingElement("composition")){
|
for(; composition; composition=composition->NextSiblingElement("composition")){
|
||||||
XMLElement* xmlTrigger = composition->FirstChildElement("trigger");
|
XMLElement* xmlTrigger = composition->FirstChildElement("trigger");
|
||||||
|
Loading…
Reference in New Issue
Block a user