v1.6.0 - Removed low level libraries computer and component. They must now be imported.

This commit is contained in:
TheWahlolly
2025-05-23 15:34:50 +03:00
parent 5552657dbd
commit 91d9ebecb1
16 changed files with 75 additions and 40 deletions
+22 -4
View File
@@ -1,7 +1,7 @@
local loadfile = ...
local filesystem = loadfile("/halyde/lib/filesystem.lua")(loadfile)
_G._OSVERSION = "Halyde 1.5.0"
_G._OSVERSION = "Halyde 1.6.0"
_G._OSLOGO = ""
local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil
repeat
@@ -40,8 +40,15 @@ gpu.bind(screenAddress)
--gpu.setResolution(targetWidth, targetHeight)
gpu.setResolution(gpu.maxResolution())
_G.package = {["preloaded"] = {}}
loadfile("/halyde/core/datatools.lua")()
function _G.import(module, ...)
local args = table.pack(...)
if package.preloaded[module] then
return package.preloaded[module]
end
local modulepath
if module:find("^/") then
if filesystem.exists(module) then
@@ -53,9 +60,7 @@ function _G.import(module, ...)
modulepath = shell.workingDirectory..module
end
assert(modulepath, "module not found\npossible locations:\n/halyde/lib/"..module..".lua")
local handle = filesystem.open(modulepath)
local data = ""
local tmpdata = ""
local handle, data, tmpdata = filesystem.open(modulepath), "", nil
repeat
tmpdata = handle:read(math.huge or math.maxinteger)
data = data .. (tmpdata or "")
@@ -63,6 +68,19 @@ function _G.import(module, ...)
return(assert(load(data, "="..modulepath))(table.unpack(args)))
end
local function preload(module)
local handle, data, tmpdata = assert(filesystem.open("/halyde/lib/" .. module .. ".lua", "r")), "", nil
repeat
tmpdata = handle:read(math.huge or math.maxinteger)
data = data .. (tmpdata or "")
until not tmpdata
package.preloaded[module] = assert(load(data, "="..module))()
_G[module] = nil
end
preload("component")
preload("computer")
--local handle = assert(filesystem.open("/bazinga.txt", "w"))
--assert(handle:write("Bazinga!"))
--handle:close()