Page 1 of 1

A loader for the full "package.subpackage" notation.

Posted: Tue May 18, 2010 1:10 pm
by pygy
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.

Code: Select all

local MLL = require "MagnaLuvLoader.lua"
MLL.addPath "Library"
require "what.ever.you.want" -- :-D
MagnaLuvLoader.lua
The Magna Luv Loader
(1.42 KiB) Downloaded 140 times

Re: A loader for the full "package.subpackage" notation.

Posted: Tue May 18, 2010 6:13 pm
by Luiji
Cool idea!