1
0
mirror of https://github.com/Adorable-Catgirl/Zorya-NEO.git synced 2024-11-27 12:48:07 +11:00
Zorya-NEO/mods/util_searchpaths/init.lua

35 lines
1.0 KiB
Lua
Raw Normal View History

2020-03-12 09:19:08 +11:00
local zy = krequire("zorya")
local sys = krequire("sys")
local utils = krequire("utils")
local computer, component = computer, component
local sp = {}
function sp.add_mod_path(drive, path)
local px = component.proxy(drive)
zy.add_mod_search(function(mod)
if (px.exists(path.."/"..mod..".zy2m")) then
local h = px.open(path.."/"..mod..".zy2m", "r")
2020-04-11 01:38:52 +10:00
return utils.load_lua(utils.readfile(drive, h))()
2020-03-12 09:19:08 +11:00
elseif (px.exists(path.."/"..mod.."/init.zy2m")) then
local h = px.open(path.."/"..mod.."/init.zy2m", "r")
2020-04-11 01:38:52 +10:00
return utils.load_lua(utils.readfile(drive, h))()
2020-03-12 09:19:08 +11:00
end
end)
end
function sp.add_lib_path(drive, path)
local px = component.proxy(drive)
sys.add_search(function(mod)
if (px.exists(path.."/"..mod..".zy2l")) then
local h = px.open(path.."/"..mod..".zy2l", "r")
return utils.load_lua(utils.readfile(drive, h))
elseif (px.exists(path.."/"..mod.."/init.zy2l")) then
local h = px.open(path.."/"..mod.."/init.zy2l", "r")
return utils.load_lua(utils.readfile(drive, h))
end
end)
end
return sp