Added setting of custom package.path to boot.lua
This commit is contained in:
@@ -1,14 +1,18 @@
|
|||||||
|
|
||||||
-- Add filesystem-compatible package loader
|
|
||||||
table.insert(package.loaders, 1, function(modname)
|
function love.boot()
|
||||||
modname = modname:gsub("%.", "/")
|
-- Init package.path and add filesystem-compatible package loader
|
||||||
for x in package.path:gmatch("[^;]+") do
|
package.path = "?.lua;?/init.lua"
|
||||||
local filename = x:gsub("?", modname)
|
table.insert(package.loaders, 1, function(modname)
|
||||||
if love.filesystem.exists(filename) then
|
modname = modname:gsub("%.", "/")
|
||||||
return assert(loadstring(love.filesystem.read(filename), "=" .. filename))
|
for x in package.path:gmatch("[^;]+") do
|
||||||
|
local file = x:gsub("?", modname)
|
||||||
|
if love.filesystem.exists(file) then
|
||||||
|
return assert(loadstring(love.filesystem.read(file), "=" .. file))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end)
|
||||||
end)
|
end
|
||||||
|
|
||||||
|
|
||||||
function love.run()
|
function love.run()
|
||||||
@@ -17,9 +21,11 @@ function love.run()
|
|||||||
for i = 2, #love.argv do
|
for i = 2, #love.argv do
|
||||||
args[i - 1] = love.argv[i]
|
args[i - 1] = love.argv[i]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Do load callback
|
-- Do load callback
|
||||||
if love.load then love.load(args) end
|
if love.load then love.load(args) end
|
||||||
love.timer.step()
|
love.timer.step()
|
||||||
|
|
||||||
while true do
|
while true do
|
||||||
-- Handle mouse events
|
-- Handle mouse events
|
||||||
for _, e in ipairs(love.mouse.poll()) do
|
for _, e in ipairs(love.mouse.poll()) do
|
||||||
@@ -61,9 +67,11 @@ function love.errhand(msg)
|
|||||||
table.insert(err, line)
|
table.insert(err, line)
|
||||||
end
|
end
|
||||||
local str = table.concat(err, "\n")
|
local str = table.concat(err, "\n")
|
||||||
|
|
||||||
-- Init error state
|
-- Init error state
|
||||||
love.graphics.reset()
|
love.graphics.reset()
|
||||||
pcall(love.graphics.setBackgroundColor, 89, 157, 220)
|
pcall(love.graphics.setBackgroundColor, 89, 157, 220)
|
||||||
|
|
||||||
-- Do error main loop
|
-- Do error main loop
|
||||||
while true do
|
while true do
|
||||||
for _, e in ipairs(love.keyboard.poll()) do
|
for _, e in ipairs(love.keyboard.poll()) do
|
||||||
@@ -78,5 +86,6 @@ function love.errhand(msg)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
xpcall(love.boot, love.errhand)
|
||||||
xpcall(function() require("main") end, love.errhand)
|
xpcall(function() require("main") end, love.errhand)
|
||||||
xpcall(love.run, love.errhand)
|
xpcall(love.run, love.errhand)
|
||||||
|
|||||||
Reference in New Issue
Block a user