A loader for the full "package.subpackage" notation.
Posted: Tue May 18, 2010 1:10 pm
O HAÏ
Here's a short piece of code that makes require work in LÖVE as it does in Lua for packages and subpackages... With a corny name as usual...
require "pack.subpack"
will look for pack/subpack/init.lua then for pack/subpack.lua in all folders registered using
MLL.addPath("directory name")
It uses a search function copied verbatim from the PiL book, and uses love.filesystem.load() to load the file if it's ever found.
Here's a short piece of code that makes require work in LÖVE as it does in Lua for packages and subpackages... With a corny name as usual...
require "pack.subpack"
will look for pack/subpack/init.lua then for pack/subpack.lua in all folders registered using
MLL.addPath("directory name")
It uses a search function copied verbatim from the PiL book, and uses love.filesystem.load() to load the file if it's ever found.
Code: Select all
local MLL = require "MagnaLuvLoader.lua"
MLL.addPath "Library"
require "what.ever.you.want" -- :-D