Moved setting of package.path in lua to init.lua
This commit is contained in:
parent
ae1d04b5ee
commit
fb028a899f
@ -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" )
|
||||
if(global.triggeredSCRIPTNAME == nil) then
|
||||
global.triggeredSCRIPTNAME = false
|
||||
|
@ -1,3 +1,3 @@
|
||||
--global variable space
|
||||
local M = {}
|
||||
return M
|
||||
local global = {}
|
||||
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" )
|
||||
if(global.triggeredOpenFirstDoor == nil) then
|
||||
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" )
|
||||
if(global.triggeredOpenFirstDoorUndo == nil) then
|
||||
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
|
||||
|
||||
//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");
|
||||
for(; composition; composition=composition->NextSiblingElement("composition")){
|
||||
XMLElement* xmlTrigger = composition->FirstChildElement("trigger");
|
||||
|
Loading…
Reference in New Issue
Block a user