From bc06ec457d0de77256a9fee5918d8a41b1115683 Mon Sep 17 00:00:00 2001 From: TheWahlolly Date: Sat, 14 Jun 2025 18:37:51 +0300 Subject: [PATCH] Revert "Nonfunctional virtual component support" This reverts commit f425e0d6906d615a0a040babdca2bb20b79e379e. --- halyde/core/datatools.lua | 4 +- halyde/lib/component.lua | 85 +++++---------------------------------- init.lua | 4 +- 3 files changed, 12 insertions(+), 81 deletions(-) diff --git a/halyde/core/datatools.lua b/halyde/core/datatools.lua index b7b80e5..e56d591 100644 --- a/halyde/core/datatools.lua +++ b/halyde/core/datatools.lua @@ -12,8 +12,8 @@ local conversionTables = { } } -function table.find(tab, item) - for k, v in pairs(tab) do +function table.find(table, item) + for k, v in pairs(table) do if v == item then return k end diff --git a/halyde/lib/component.lua b/halyde/lib/component.lua index 4d25161..54b5058 100644 --- a/halyde/lib/component.lua +++ b/halyde/lib/component.lua @@ -1,82 +1,15 @@ -local compLib -local LLcomponent +local componentlib if table.copy then - compLib = table.copy(component) - LLcomponent = table.copy(component) + componentlib = table.copy(component) else - compLib = {} - LLcomponent = component + componentlib = {} end -local ocelot = LLcomponent.proxy(LLcomponent.list("ocelot")()) -ocelot.log("loaded") - -_G.componentlib = {["additions"] = {}, ["removals"] = {}} -compLib.virtual = {} - -function compLib.virtual.add(address, componentType, proxy) +function componentlib.get(address) checkArg(1, address, "string") - checkArg(2, componentType, "string") - checkArg(3, proxy, "table") - componentlib.additions[address] = {["componentType"] = componentType, ["proxy"] = proxy} - if componentlib.removals[address] then - componentlib.removals[address] = nil - end -end - -function compLib.virtual.remove(address) - checkArg(1, address, "string") - if componentlib.additions[address] then - componentlib.additions[address] = nil - else - table.insert(componentlib.removals, address) - end -end - -function compLib.list(componentType) - checkArg(1, componentType, "string", "nil") - local componentList = table.copy(LLcomponent.list(componentType)) - for address, dataTable in pairs(componentlib.additions) do - if dataTable.componentType == componentType or not componentType then - componentList[address] = dataTable.componentType - end - end - for _, address in pairs(componentlib.removals) do - componentList[address] = nil - end - local i, value - setmetatable(componentList, {__call = function(self) - i, value = next(self, i) - return i, value - end}) - return componentList -end - -function compLib.proxy(address) - if componentlib.additions[address] then - ocelot.log("vcomponent") - return componentlib.additions[address].proxy - else - return LLcomponent.proxy(address) - end -end - -function compLib.invoke(address, funcName, ...) - ocelot.log("Invoking " .. funcName .. " from " .. address) - if componentlib.additions[address] then - ocelot.log("vcomponent") - return componentlib.additions[address].proxy[funcName](...) - else - return LLcomponent.invoke(address, funcName, ...) - end -end - -function compLib.get(address) - checkArg(1, address, "string") - if #address < 3 then - return nil, "abbreviated address must be at least 3 characters long" - end - for currentAddress, name in compLib.list() do + assert(#address >= 3, "abbreviated address must be at least 3 characters long") + local components = component.list() + for currentAddress, name in pairs(components) do if currentAddress:find("^" .. address) then return(currentAddress) end @@ -84,6 +17,6 @@ function compLib.get(address) return nil, "full address not found" end -compLib.invoke = component.invoke -- trust me, this is needed +componentlib.invoke = component.invoke -return compLib +return componentlib diff --git a/init.lua b/init.lua index 93e15e1..0e623ad 100644 --- a/init.lua +++ b/init.lua @@ -25,9 +25,7 @@ gpu.setBackground(0x000000) gpu.fill(1, 1, resx, resy, " ") local result, reason = xpcall(loadthething, handleError) if not result then - if import then - local computer = import("computer") - end + local computer = import("computer") or computer gpu.setBackground(0x000000) gpu.fill(1, 1, resx, resy, " ") gpu.setBackground(0x800000)