From 290d39bcd52697dfdeeb7b87b2167b192876ef33 Mon Sep 17 00:00:00 2001 From: Guard13007 Date: Mon, 27 Oct 2014 12:16:21 -0700 Subject: [PATCH 1/2] load from anywhere --- examples/complex.lua | 2 +- examples/short.lua | 2 +- lib/{light_world.lua => init.lua} | 27 +++++++++++++++------------ main.lua | 2 +- 4 files changed, 18 insertions(+), 15 deletions(-) rename lib/{light_world.lua => init.lua} (95%) diff --git a/examples/complex.lua b/examples/complex.lua index cfc4824..90e356d 100644 --- a/examples/complex.lua +++ b/examples/complex.lua @@ -1,5 +1,5 @@ -- Example: Complex Example -local LightWorld = require "lib/light_world" +local LightWorld = require "lib" function initScene() -- physic world diff --git a/examples/short.lua b/examples/short.lua index 1fd0800..9e3ad8d 100644 --- a/examples/short.lua +++ b/examples/short.lua @@ -1,5 +1,5 @@ -- Example: Short Example -local LightWorld = require "lib/light_world" +local LightWorld = require "lib" function love.load() testShader = 0 diff --git a/lib/light_world.lua b/lib/init.lua similarity index 95% rename from lib/light_world.lua rename to lib/init.lua index de44e5f..1fb4cd5 100644 --- a/lib/light_world.lua +++ b/lib/init.lua @@ -21,21 +21,24 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ]] -local _PACKAGE = (...):match("^(.+)[%./][^%./]+") or "" -local class = require(_PACKAGE..'/class') -local Light = require(_PACKAGE..'/light') -local Body = require(_PACKAGE..'/body') -local util = require(_PACKAGE..'/util') -local normal_map = require(_PACKAGE..'/normal_map') -local PostShader = require(_PACKAGE..'/postshader') -require(_PACKAGE..'/postshader') +local _PACKAGE = string.gsub(...,"%.","/") or "" +if string.len(_PACKAGE) > 0 then + _PACKAGE = _PACKAGE .. "/" +end +local class = require(_PACKAGE..'class') +local Light = require(_PACKAGE..'light') +local Body = require(_PACKAGE..'body') +local util = require(_PACKAGE..'util') +local normal_map = require(_PACKAGE..'normal_map') +local PostShader = require(_PACKAGE..'postshader') +require(_PACKAGE..'postshader') local light_world = class() -light_world.blurv = love.graphics.newShader(_PACKAGE.."/shaders/blurv.glsl") -light_world.blurh = love.graphics.newShader(_PACKAGE.."/shaders/blurh.glsl") -light_world.refractionShader = love.graphics.newShader(_PACKAGE.."/shaders/refraction.glsl") -light_world.reflectionShader = love.graphics.newShader(_PACKAGE.."/shaders/reflection.glsl") +light_world.blurv = love.graphics.newShader(_PACKAGE.."shaders/blurv.glsl") +light_world.blurh = love.graphics.newShader(_PACKAGE.."shaders/blurh.glsl") +light_world.refractionShader = love.graphics.newShader(_PACKAGE.."shaders/refraction.glsl") +light_world.reflectionShader = love.graphics.newShader(_PACKAGE.."shaders/reflection.glsl") function light_world:init(options) self.lights = {} diff --git a/main.lua b/main.lua index 50e1420..701c400 100644 --- a/main.lua +++ b/main.lua @@ -7,7 +7,7 @@ -- Updated by Dresenpai require "lib/postshader" -local LightWorld = require "lib/light_world" +local LightWorld = require "lib" exf = {} exf.current = nil From 2063472fe268d23c765c07d06cc36e37a7bd0e0c Mon Sep 17 00:00:00 2001 From: Guard13007 Date: Mon, 27 Oct 2014 12:24:28 -0700 Subject: [PATCH 2/2] fixed normalMap require --- examples/normalMap.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/normalMap.lua b/examples/normalMap.lua index d4cc948..6d249a6 100644 --- a/examples/normalMap.lua +++ b/examples/normalMap.lua @@ -1,5 +1,5 @@ -- Example: Normal map Example -local LightWorld = require "lib/light_world" +local LightWorld = require "lib" function love.load() x = 0