From 2327dc9c18d8a37af06c15dfc3af9befeed96022 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 12 Apr 2020 01:59:20 +1000 Subject: [PATCH] added the ability to reload libraries to the loadfile module --- module/loadfile.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/module/loadfile.lua b/module/loadfile.lua index 1551c3e..99a88f2 100644 --- a/module/loadfile.lua +++ b/module/loadfile.lua @@ -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