Moved setting of package.path in lua to init.lua

This commit is contained in:
Faerbit 2015-02-15 19:32:19 +01:00
parent f6b2cc938f
commit 23fc196bea
6 changed files with 10 additions and 8 deletions

View File

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

View File

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

View 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

View File

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

View File

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

View File

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