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
2020-04-10 10:38:52 -05:00

35 lines
1.0 KiB
Lua

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")
return utils.load_lua(utils.readfile(drive, h))()
elseif (px.exists(path.."/"..mod.."/init.zy2m")) then
local h = px.open(path.."/"..mod.."/init.zy2m", "r")
return utils.load_lua(utils.readfile(drive, h))()
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