Ver código fonte

added the ability to reload libraries to the loadfile module

pull/1/head
XeonSquared 4 anos atrás
pai
commit
2327dc9c18
1 arquivos alterados com 5 adições e 2 exclusões
  1. +5
    -2
      module/loadfile.lua

+ 5
- 2
module/loadfile.lua Ver arquivo

@@ -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

Carregando…
Cancelar
Salvar