4--! @brief search by
game in filesystem / lua modules
7 if type(game_file) ==
'table' then
12 local
application = type(game_file) ==
'function' and game_file
13 local game_title = game_file and game_file:gsub(
'%.lua$',
'') or '
game'
16 if not
application and game_file and game_file:find('\n') then
17 local ok, app = pcall(
load, game_file)
19 ok, app = pcall(loadstring, game_file)
23 if love and love.filesystem and love.filesystem.getSource then
24 cwd = love.filesystem.getSource()
30 local ok, app = pcall(
require, game_title)
42local function
package(self, module_name, module, custom)
43 local system = module_name:sub(1, 1) == '@'
44 local name = system and module_name:sub(2) or module_name
45 local should_install =
47 self.list_append(name)
50 self.stdlib_required[name] = true
53 self.pipeline[
#self.pipeline + 1] = function ()
54 if not self.list_exist(name) then
return end
55 if not system and not self.lib_required[name] then
return end
57 local try_install = function()
58 module.install(self.std, self.game, self.application, custom, module_name)
61 if not pcall(try_install) then
return end
64 self.stdlib_installed[name] =
true
66 self.lib_installed[name] =
true
75 local next_library = application_require:gmatch(
'%S+')
85 stdlib_installed = {},
88 pipe = zeebo_pipeline.pipe
91 self.list_exist = function (name)
92 return self.lib_optional[name] or self.lib_required[name] or self.stdlib_required[name]
94 self.list_append = function (name)
95 if not self.list_exist(name) then
96 self.list[#self.list + 1] = name
101 zeebo_pipeline.run(self)
102 while index <= #self.list do
103 local name = self.list[index]
104 if self.stdlib_required[name] and not self.stdlib_installed[name] then
105 error('system library not loaded: '..name)
107 if self.lib_required[name] and not self.lib_installed[name] then
108 error('library not loaded: '..name)
115 local lib = next_library()
117 local name, optional = lib:match('(%w+)([?]?)')
118 self.list_append(name)
119 if optional and #optional > 0 then
120 self.lib_optional[name] = true
122 self.lib_required[name] = true
130local function install(std, game, application, exit_func)
131 std.game = std.game or {}
132 std.game.load = loadgame
133 return {load=loadgame}
137 load={install=install},
local function require(std, game, application)
local function loadgame(game_file)
safe load game
local function package(self, module_name, module, custom)
local function install(std, game, application, exit_func)