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()
+1
View File
@@ -3,6 +3,7 @@ _G.cormgr.corList = {}
--local ocelot = component.proxy(component.list("ocelot")())
local component = import("component")
local filesystem = import("filesystem")
local gpu = component.proxy(component.list("gpu")())
+2
View File
@@ -2,6 +2,8 @@ _G.evmgr = {}
_G.evmgr.eventQueue = {}
local maxEventQueueLength = 10 -- increase if events start getting dropped
local computer = import("computer")
keyboard.ctrlDown = false
keyboard.altDown = false
+1
View File
@@ -2,6 +2,7 @@ local shellcfg = import("/halyde/config/shell.cfg")
import("/halyde/core/termlib.lua")
local event = import("event")
local filesystem = import("filesystem")
local component = import("component")
local gpu = component.proxy(component.list("gpu")())
_G.shell = {}
+1
View File
@@ -2,6 +2,7 @@ local event = import("event")
--local keyboard = import("keyboard")
--local ocelot = component.proxy(component.list("ocelot")())
local component = import("component")
local gpu = component.proxy(component.list("gpu")()) -- replace with component.gpu once implemented
_G.termlib = {}
termlib.cursorPosX = 1