more standard package stuff, plus package.alias

This commit is contained in:
Izaya 2020-07-01 14:31:00 +10:00
parent d40ce731ef
commit 5db20adefd

View File

@ -9,9 +9,11 @@ function runfile(p,...) -- string -- -- runs file *p* with arbitrary arguments i
end
_G.package = {}
package.path="./?;./?.lua;/boot/lib/?.lua;/pkg/lib/?.lua;/boot/lib/?/init.lua;/pkg/lib/?/init.lua"
package.loaded = {computer=computer,component=component,fs=fs,buffer=buffer}
package.path="/boot/lib/?.lua;/pkg/lib/?.lua;/boot/lib/?/init.lua;/pkg/lib/?/init.lua;./?;./?.lua;./?/init.lua"
package.loaded = {buffer=buffer, component=component, computer=computer, coroutine=coroutine, fs=fs, math=math, os=os, package=package, string=string, table=table}
package.alias = {filesystem="fs"}
function require(f,force) -- string boolean -- table -- 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
f=package.alias[f] or f
if not package.loaded[f] or force then
local ln = f:gsub("%.","/")
for d in package.path:gmatch("[^;]+") do