1
1
mirror of https://git.shadowkat.net/izaya/OC-PsychOS2.git synced 2024-11-25 12:42:10 -05:00

added the ability to reload libraries to the loadfile module

This commit is contained in:
XeonSquared 2020-04-12 01:59:20 +10:00
parent 0cdd70e917
commit 2327dc9c18

View File

@ -13,8 +13,8 @@ function os.spawnfile(p,n,...) -- spawns a new process from file *p* with name *
end
_G.package = {}
package.loaded = {computer=computer,component=component,fs=fs,buffer=buffer}
function require(f) -- searches for a library with name *f* and returns what the library returns, if possible
if not package.loaded[f] then
function require(f,force) -- searches for a library with name *f* and returns what the library returns, if possible. if *force* is set, loads the library even if it is cached
if not package.loaded[f] or force then
local lib = os.getenv("LIB") or "/boot/lib"
for d in lib:gmatch("[^\n]+") do
if fs.exists(d.."/"..f) then
@ -29,3 +29,6 @@ function require(f) -- searches for a library with name *f* and returns what the
end
error("library not found: "..f)
end
function reload(f)
return require(f,true)
end