From 8fdf6b73e80e30dd79f56d06d29d2742b3adcac2 Mon Sep 17 00:00:00 2001 From: Gabriel Moreira Minossi Date: Wed, 6 Jan 2021 11:39:50 -0300 Subject: [PATCH] Renaming global variables Removing unnecessary `require(...)`s --- Libraries/graphics/ARGraphics.lua | 5 --- Libraries/graphics/ARWidgets.lua | 2 - Libraries/graphics/graphics.lua | 10 ++--- Libraries/graphics/gui.lua | 21 +++++---- Libraries/graphics/widgets.lua | 4 -- Libraries/network/network.lua | 7 ++- Libraries/utils/utility.lua | 11 +++-- Programs/Assembly Line/assemblyClient.lua | 18 +++----- Programs/Assembly Line/recipeServer.lua | 23 +++++----- Programs/Assembly Line/transport.lua | 8 +--- Programs/Assembly Line/util.lua | 32 +++++++------- Programs/Autostocker/stocker.lua | 2 - Programs/Autostocker/stockerUtil.lua | 3 -- Programs/HUD/main.lua | 10 ++--- Programs/HUD/ticker.lua | 5 +-- Programs/HUD/tps.lua | 7 ++- Programs/Nuclear Control/control.lua | 47 ++++++++++----------- Programs/Spatial Teleporter/destination.lua | 34 +++++++-------- Programs/Spatial Teleporter/spatial.lua | 28 ++++++------ Programs/armorCharger.lua | 5 +-- Programs/autofeeder.lua | 4 +- Programs/biovat.lua | 18 ++++---- Programs/energyControl.lua | 13 ++---- Programs/monitor-system/init.lua | 2 - 24 files changed, 131 insertions(+), 188 deletions(-) diff --git a/Libraries/graphics/ARGraphics.lua b/Libraries/graphics/ARGraphics.lua index ecc1662..a756037 100644 --- a/Libraries/graphics/ARGraphics.lua +++ b/Libraries/graphics/ARGraphics.lua @@ -1,8 +1,3 @@ -component = require("component") -term = require("term") -computer = require("computer") -event = require("event") - local AR = {} local terminal = {x = 8257, y = 199, z = -2731} diff --git a/Libraries/graphics/ARWidgets.lua b/Libraries/graphics/ARWidgets.lua index aaa5353..3d54c3a 100644 --- a/Libraries/graphics/ARWidgets.lua +++ b/Libraries/graphics/ARWidgets.lua @@ -1,8 +1,6 @@ component = require("component") -term = require("term") computer = require("computer") event = require("event") -thread = require("thread") get = require("easy") ARG = require("ARGraphics") colors = require("colors") diff --git a/Libraries/graphics/graphics.lua b/Libraries/graphics/graphics.lua index 88a434b..4209060 100644 --- a/Libraries/graphics/graphics.lua +++ b/Libraries/graphics/graphics.lua @@ -1,5 +1,3 @@ -component = require("component") -colors = require("colors") local graphics = {} function graphics.pixel(GPU, x, y, color) @@ -66,10 +64,10 @@ function graphics.centeredText(GPU, x, y, color, string) end function graphics.border(GPU, w, h, color) - draw.rectangle(GPU, 1, 1, w, 1, color) - draw.rectangle(GPU, 1, h * 2, w, 1, color) - draw.rectangle(GPU, 1, 1, 1, h * 2, color) - draw.rectangle(GPU, w, 1, 1, h * 2, color) + graphics.rectangle(GPU, 1, 1, w, 1, color) + graphics.rectangle(GPU, 1, h * 2, w, 1, color) + graphics.rectangle(GPU, 1, 1, 1, h * 2, color) + graphics.rectangle(GPU, w, 1, 1, h * 2, color) end graphics.currentWindows = {} function graphics.checkCollision(GPU, x, y) diff --git a/Libraries/graphics/gui.lua b/Libraries/graphics/gui.lua index 4bb2734..1667ef9 100644 --- a/Libraries/graphics/gui.lua +++ b/Libraries/graphics/gui.lua @@ -1,10 +1,9 @@ -local draw = require("graphics") +graphics = require("graphics") event = require("event") -local thread = require("thread") local uc = require("unicode") component = require("component") GPU = component.proxy(component.get("f26678f4")) -local colors = require("colors") +colors = require("colors") local gui, quit, editing = {}, false, false local currentWindows = {} @@ -38,9 +37,9 @@ gui.contextMenu = function(GPU, x, y, data) end local contextWindow = gui.createWindow(GPU, longestData, #data * 2, "ContextMenu" .. contextMenus) GPU.setActiveBuffer(contextWindow) - draw.rectangle(GPU, 1, 1, longestData, #data * 2, colors.lightGray) + graphics.rectangle(GPU, 1, 1, longestData, #data * 2, colors.lightGray) for i = 1, #data do - draw.text(GPU, 1, 1 + i * 2 - 2, colors.cyan, data[i]) + graphics.text(GPU, 1, 1 + i * 2 - 2, colors.cyan, data[i]) end currentWindows["ContextMenu" .. contextMenus].x = x currentWindows["ContextMenu" .. contextMenus].y = y @@ -73,13 +72,13 @@ gui.processCommand = function(GPU, window, option) end GPU.setActiveBuffer(currentWindows["ColorBox"].page) if option == 1 then - draw.rectangle(GPU, 1, 1, 10, 10, colors.red) + graphics.rectangle(GPU, 1, 1, 10, 10, colors.red) end if option == 2 then - draw.rectangle(GPU, 1, 1, 10, 10, colors.blue) + graphics.rectangle(GPU, 1, 1, 10, 10, colors.blue) end if option == 3 then - draw.rectangle(GPU, 1, 1, 10, 10, colors.green) + graphics.rectangle(GPU, 1, 1, 10, 10, colors.green) end GPU.setActiveBuffer(0) end @@ -88,7 +87,7 @@ local i, xOffset, yOffset = 1, 0, 0 gui.mouseListener = function() local function processClick(event, address, x, y, key, player) activeWindow = gui.checkCollision(x, y) - draw.text(GPU, 1, 1, colors.cyan, "Active window: " .. activeWindow) + graphics.text(GPU, 1, 1, colors.cyan, "Active window: " .. activeWindow) if key == 1.0 and editing then if inContextMenu then contextMenus = 0 @@ -172,13 +171,13 @@ GPU.freeAllBuffers() keyInput, mouseInput, drag = gui.keyboardListener(), gui.mouseListener(), gui.dragListener() gui.createWindow(GPU, 160, 100, "Black") GPU.setActiveBuffer(currentWindows["Black"].page) -draw.rectangle(GPU, 1, 1, 160, 100, 0x000000) +graphics.rectangle(GPU, 1, 1, 160, 100, 0x000000) currentWindows["Black"].w = 0 currentWindows["Black"].h = 0 GPU.setActiveBuffer(0) gui.createWindow(GPU, 160, 100, "State") GPU.setActiveBuffer(currentWindows["State"].page) -draw.rectangle(GPU, 1, 1, 160, 100, 0x000000) +graphics.rectangle(GPU, 1, 1, 160, 100, 0x000000) currentWindows["State"].w = 0 currentWindows["State"].h = 0 GPU.setActiveBuffer(0) diff --git a/Libraries/graphics/widgets.lua b/Libraries/graphics/widgets.lua index f3265e3..e8c90b0 100644 --- a/Libraries/graphics/widgets.lua +++ b/Libraries/graphics/widgets.lua @@ -1,7 +1,3 @@ -component = require("component") -term = require("term") -computer = require("computer") -event = require("event") graphics = require("graphics") util = require("utility") colors = require("colors") diff --git a/Libraries/network/network.lua b/Libraries/network/network.lua index 2fc69b4..90d1be4 100644 --- a/Libraries/network/network.lua +++ b/Libraries/network/network.lua @@ -1,7 +1,6 @@ -local comp = require("component") -local event = require("event") -local modem = comp.modem -local screen = require("term") +component = require("component") +event = require("event") +local modem = component.modem local util = require("utility") AR = require("AR") glasses = util.machine("3770e3f9") diff --git a/Libraries/utils/utility.lua b/Libraries/utils/utility.lua index e36ae35..a298aa7 100644 --- a/Libraries/utils/utility.lua +++ b/Libraries/utils/utility.lua @@ -1,14 +1,13 @@ -local comp = require("component") -local event = require("event") -local thread = require("thread") +component = require("component") +event = require("event") local uc = require("unicode") local utility = {} -local modem = comp.modem +local modem = component.modem function utility.machine(address) - machineAddress = comp.get(address) + machineAddress = component.get(address) if (machineAddress ~= nil) then - return comp.proxy(machineAddress) + return component.proxy(machineAddress) else return nil end diff --git a/Programs/Assembly Line/assemblyClient.lua b/Programs/Assembly Line/assemblyClient.lua index 7322036..63c6d2d 100644 --- a/Programs/Assembly Line/assemblyClient.lua +++ b/Programs/Assembly Line/assemblyClient.lua @@ -1,14 +1,10 @@ -comp = require("component") event = require("event") -screen = require("term") -computer = require("computer") -thread = require("thread") +term = require("term") local AU = require("util") local AT = require("transport") local S = require("serialization") local uc = require("unicode") -local D = require("dictionary") -local network = comp.modem +local network = component.modem local id, AD local function requestID() network.broadcast(100, "requestID") @@ -103,10 +99,10 @@ local function processRecipe(recipe) os.sleep(0.2) end if not AD.controller.hasWork() then - screen.write(" ... Error with starting assembly!") + term.write(" ... Error with starting assembly!") network.broadcast(id, "jammed") else - screen.write(" ... Assembly Started") + term.write(" ... Assembly Started") while AD.controller.hasWork() do os.sleep(0.1) end @@ -115,14 +111,14 @@ local function processRecipe(recipe) end end AT.clearAll(AD) - screen.write(" ... finished task!\n") + term.write(" ... finished task!\n") network.broadcast(id, "complete") end local function processMessage(localAddress, remoteAddress, port, distance, type, eventType, value2, value3) if eventType == "startAssembly" then local recipe = S.unserialize(value2) - screen.write("Starting assembly of " .. recipe.label) + term.write("Starting assembly of " .. recipe.label) processRecipe(recipe) elseif eventType == "clear" then AT.clearAll(AD) @@ -130,7 +126,7 @@ local function processMessage(localAddress, remoteAddress, port, distance, type, end local function quit() - screen.write("Quitting...") + term.write("Quitting...") event.ignore("modem_message", processMessage) event.ignore("key_up", processKey) os.exit() diff --git a/Programs/Assembly Line/recipeServer.lua b/Programs/Assembly Line/recipeServer.lua index ae36693..5611ae2 100644 --- a/Programs/Assembly Line/recipeServer.lua +++ b/Programs/Assembly Line/recipeServer.lua @@ -1,13 +1,10 @@ -comp = require("component") +component = require("component") event = require("event") -screen = require("term") -computer = require("computer") -thread = require("thread") -uc = require("unicode") +term = require("term") AU = require("util") +local uc = require("unicode") local S = require("serialization") -local D = require("dictionary") -local network = comp.modem +local network = component.modem local mainChannel = 100 -- mainChannel = Main channel for bi-directional communication @@ -58,7 +55,7 @@ local function processMessage(type, localAddress, remoteAddress, port, distance, end local function quit() - screen.write("Quitting...") + term.write("Quitting...") event.ignore("modem_message", processMessage) event.ignore("key_up", processKey) run = false @@ -101,7 +98,7 @@ local function spairs(t, order) end end function matchRecipe(recipes) - local items = comp.me_interface.getItemsInNetwork() + local items = component.me_interface.getItemsInNetwork() local foundItems = {} if #items > 0 then for i = 1, #items, 1 do @@ -164,10 +161,10 @@ local function scheduleTasks() if not contains(assemblyStatus, recipe.label) then local taskid = getFree() if taskid ~= nil then - screen.write("Started assembly of " .. recipe.label .. " with AL #" .. taskid .. "\n") + term.write("Started assembly of " .. recipe.label .. " with AL #" .. taskid .. "\n") startAssembly(taskid, recipe) else - screen.write("No free assembly lines.\n") + term.write("No free assembly lines.\n") end end return true @@ -176,9 +173,9 @@ local function scheduleTasks() local taskid = getFree() if taskid ~= nil then startAssembly(taskid, recipe) - screen.write("Started assembly of " .. recipe.label .. " with AL #" .. taskid .. "\n") + term.write("Started assembly of " .. recipe.label .. " with AL #" .. taskid .. "\n") else - screen.write("No free assembly lines.\n") + term.write("No free assembly lines.\n") end craftable = craftable - 8 end diff --git a/Programs/Assembly Line/transport.lua b/Programs/Assembly Line/transport.lua index 9b43472..ac13a94 100644 --- a/Programs/Assembly Line/transport.lua +++ b/Programs/Assembly Line/transport.lua @@ -1,8 +1,4 @@ -comp = require("component") -event = require("event") -screen = require("term") -computer = require("computer") -thread = require("thread") +component = require("component") local transport = {} @@ -16,7 +12,7 @@ function transport.empty(transposer) transposer.transferItem(1, 0, 64, 2, 9) end function transport.clear(interface) - interface.setInterfaceConfiguration(1, comp.database.address, 1, 0) + interface.setInterfaceConfiguration(1, component.database.address, 1, 0) end function transport.check(transposer, item, amount) local itemstack = transposer.getStackInSlot(0, 1) diff --git a/Programs/Assembly Line/util.lua b/Programs/Assembly Line/util.lua index bb403c0..71b8569 100644 --- a/Programs/Assembly Line/util.lua +++ b/Programs/Assembly Line/util.lua @@ -1,27 +1,25 @@ -comp = require("component") +component = require("component") event = require("event") -screen = require("term") -computer = require("computer") -thread = require("thread") +term = require("term") local assemblyUtil = {} local function addEntries(file, prompt, amount, type) local a, b, c for i = 1, amount, 1 do - screen.write(prompt .. " " .. i .. " ") + term.write(prompt .. " " .. i .. " ") a, b, c = event.pull() while a ~= "component_added" do a, b, c = event.pull() os.sleep() end file:write(type .. i .. "," .. b .. "\n") - screen.write(b .. "\n") + term.write(b .. "\n") end end local function addAuxilary(file, proxy, type) if proxy == nil then - screen.write("Cant find a valid " .. type .. "! Exiting...\n") + term.write("Cant find a valid " .. type .. "! Exiting...\n") os.exit() else file:write(type .. "," .. proxy.address .. "\n") @@ -41,9 +39,9 @@ local function split(s, sep) return fields end local function proxy(address) - machineAddress = comp.get(address) + machineAddress = component.get(address) if (machineAddress ~= nil) then - return comp.proxy(machineAddress) + return component.proxy(machineAddress) else return nil end @@ -54,27 +52,27 @@ local function configureClient() addEntries(file, "Add fluid interface", 4, "fluid") addEntries(file, "Add item transposer", 15, "inputTransposer") addEntries(file, "Add fluid transposer", 4, "fluidTransposer") - addAuxilary(file, comp.me_interface, "items") - addAuxilary(file, comp.database, "database") - addAuxilary(file, comp.gt_machine, "controller") + addAuxilary(file, component.me_interface, "items") + addAuxilary(file, component.database, "database") + addAuxilary(file, component.gt_machine, "controller") end function assemblyUtil.buildClient() - screen.write("Starting Assembly Line initalization...") + term.write("Starting Assembly Line initalization...") local assemblyStructure = {} local file = io.open("addresses", "r") if file == nil then - screen.write(" no address configuration found, configuring:\n") + term.write(" no address configuration found, configuring:\n") configureClient() file = io.lines("addresses") else file = io.lines("addresses") end for line in file do - screen.write(".") + term.write(".") local tokens = split(line, ",") assemblyStructure[tokens[1]] = proxy(tokens[2]) end - screen.write("\n") + term.write("\n") return assemblyStructure end local function voltageToTier(voltage) @@ -142,7 +140,7 @@ local function addRecipe(recipelist, slot, source, sourceSide) end end function assemblyUtil.getRecipes(recipelist) - for address, type in pairs(comp.list()) do + for address, type in pairs(component.list()) do if type == "transposer" then local dataSource = proxy(address) for side = 0, 5 do diff --git a/Programs/Autostocker/stocker.lua b/Programs/Autostocker/stocker.lua index 2bb8be9..a40f809 100644 --- a/Programs/Autostocker/stocker.lua +++ b/Programs/Autostocker/stocker.lua @@ -2,9 +2,7 @@ component = require("component") term = require("term") computer = require("computer") event = require("event") -thread = require("thread") local sides = require("sides") -ARG = require("ARGraphics") graphics = require("graphics") S = require("stockerUtil") local uc = require("unicode") diff --git a/Programs/Autostocker/stockerUtil.lua b/Programs/Autostocker/stockerUtil.lua index daa9328..62033df 100644 --- a/Programs/Autostocker/stockerUtil.lua +++ b/Programs/Autostocker/stockerUtil.lua @@ -1,7 +1,4 @@ component = require("component") -term = require("term") -computer = require("computer") -ARG = require("ARGraphics") graphics = require("graphics") local tx = require("transforms") GPU = component.gpu diff --git a/Programs/HUD/main.lua b/Programs/HUD/main.lua index ca2a860..857c3a5 100644 --- a/Programs/HUD/main.lua +++ b/Programs/HUD/main.lua @@ -1,18 +1,16 @@ -comp = require("component") -event = require("event") +component = require("component") AR = require("ARWidgets") -ARG = require("ARGraphics") local wSampsa, hSampsa = 853, 473 local powerHudX, powerHudY, powerHudW, powerHudH = 0, hSampsa - 24, wSampsa * 0.39 + 3, 14 -local glasses = comp.glasses +local glasses = component.glasses glasses.removeAll() AR.minimapOverlay(glasses) AR.hudOverlayBase(glasses, 335, 449) AR.clear() AR.crossHair(glasses, 422, 231) -screen.clear() +term.clear() while true do - AR.powerDisplay(glasses, comp.gt_machine, powerHudX, powerHudY, powerHudW, powerHudH) + AR.powerDisplay(glasses, component.gt_machine, powerHudX, powerHudY, powerHudW, powerHudH) AR.fluidMonitor( glasses, 795, diff --git a/Programs/HUD/ticker.lua b/Programs/HUD/ticker.lua index 40498f9..cd0cdb1 100644 --- a/Programs/HUD/ticker.lua +++ b/Programs/HUD/ticker.lua @@ -1,7 +1,6 @@ -comp = require("component") -event = require("event") +component = require("component") AR = require("ARWidgets") while true do - AR.itemTicker(comp.glasses, 348, 0, 380) + AR.itemTicker(component.glasses, 348, 0, 380) end diff --git a/Programs/HUD/tps.lua b/Programs/HUD/tps.lua index 683fa46..104577b 100644 --- a/Programs/HUD/tps.lua +++ b/Programs/HUD/tps.lua @@ -1,8 +1,7 @@ -comp = require("component") -event = require("event") +component = require("component") AR = require("ARWidgets") while true do - AR.displayTPS(comp.glasses, 0, 0) - AR.cpuMonitor(comp.glasses, 520, 449) + AR.displayTPS(component.glasses, 0, 0) + AR.cpuMonitor(component.glasses, 520, 449) end diff --git a/Programs/Nuclear Control/control.lua b/Programs/Nuclear Control/control.lua index 3145f33..76670d7 100644 --- a/Programs/Nuclear Control/control.lua +++ b/Programs/Nuclear Control/control.lua @@ -1,50 +1,47 @@ -comp = require("component") -event = require("event") -screen = require("term") -computer = require("computer") -thread = require("thread") +component = require("component") +term = require("term") -local GPU = comp.gpu +local GPU = component.gpu GPU.setResolution(54, 26) -function enableReactors() - comp.redstone.setOutput(1, 15) +local function enableReactors() + component.redstone.setOutput(1, 15) end -function disableReactors() - comp.redstone.setOutput(1, 0) +local function disableReactors() + component.redstone.setOutput(1, 0) end -function checkHeatLevels() - screen.setCursor(1, 1) +local function checkHeatLevels() + term.setCursor(1, 1) local i = 1 - for address, type in pairs(comp.list()) do + for address, type in pairs(component.list()) do if type == "reactor_chamber" then - screen.write("Reactor " .. i) + term.write("Reactor " .. i) if i < 10 then - screen.write(" ") + term.write(" ") end - local reactor = comp.proxy(address) + local reactor = component.proxy(address) if reactor.getHeat() > 0 then GPU.setForeground(0xFF0000) - screen.write(" REACTOR HEATING! SHUTTING DOWN") + term.write(" REACTOR HEATING! SHUTTING DOWN") disableReactors() GPU.setForeground(0xFFFFFF) os.sleep(1) os.exit() else if reactor.getReactorEUOutput() > 0 then - screen.write(" status: ") + term.write(" status: ") GPU.setForeground(0x00FF00) - screen.write("NOMINAL") + term.write("NOMINAL") GPU.setForeground(0xFFFFFF) - screen.write(" - Producing ") + term.write(" - Producing ") GPU.setForeground(0xFF00FF) - screen.write(math.floor(reactor.getReactorEUOutput())) + term.write(math.floor(reactor.getReactorEUOutput())) GPU.setForeground(0xFFFFFF) - screen.write(" EU/t\n") + term.write(" EU/t\n") else - screen.write(" status: ") + term.write(" status: ") GPU.setForeground(0xFFFF00) - screen.write("INACTIVE\n") + term.write("INACTIVE\n") end end i = i + 1 @@ -53,7 +50,7 @@ function checkHeatLevels() end enableReactors() -screen.clear() +term.clear() while true do checkHeatLevels() os.sleep(1) diff --git a/Programs/Spatial Teleporter/destination.lua b/Programs/Spatial Teleporter/destination.lua index 7b7d463..5d0262c 100644 --- a/Programs/Spatial Teleporter/destination.lua +++ b/Programs/Spatial Teleporter/destination.lua @@ -7,13 +7,9 @@ destinations = { [6] = {name = "Test", id = 3004} } -local comp = require("component") -local event = require("event") -local screen = require("term") -local computer = require("computer") local util = require("utility") -local draw = require("graphics") -local GPU = comp.gpu +graphics = require("graphics") +local GPU = component.gpu GPU.setResolution(80, 25) local boundingBoxes = {} @@ -21,15 +17,15 @@ function createDestination(x, y, index) local width, height = 18, 6 local page = GPU.allocateBuffer(width, math.ceil(height / 2)) GPU.setActiveBuffer(page) - draw.rect(GPU, 1, 1, 18, 6, 0x111111) + graphics.rectangle(GPU, 1, 1, 18, 6, 0x111111) local destinationColor = destinations[index].color or 0x0055FF - draw.rect(GPU, 3, 3, 14, 2, 0x000000) - draw.centeredText(GPU, 10, 3, destinationColor, destinations[index].name) + graphics.rectangle(GPU, 3, 3, 14, 2, 0x000000) + graphics.centeredText(GPU, 10, 3, destinationColor, destinations[index].name) windows[index] = {GPU = GPU, page = page, address = "", x = x, y = y, w = width, h = height} GPU.setActiveBuffer(0) end function setDestination(code) - for address, type in pairs(comp.list()) do + for address, type in pairs(component.list()) do if type == "ender_chest" then util.machine(address).setFrequency(code) end @@ -39,12 +35,12 @@ function checkClick(_, address, x, y, button, name) for i = 1, #boundingBoxes, 1 do local xb, yb = boundingBoxes[i].x, math.ceil(boundingBoxes[i].y / 2) if x >= xb and x < xb + 21 and y >= yb and y < yb + 3 then - draw.rect(GPU, boundingBoxes[i].x + 2, boundingBoxes[i].y + 2, 14, 2, 0x00CC00) + graphics.rectangle(GPU, boundingBoxes[i].x + 2, boundingBoxes[i].y + 2, 14, 2, 0x00CC00) local destinationColor = destinations[i].color or 0x0055FF setDestination(destinations[i].id) - draw.rect(GPU, 30, 43, 22, 2, 0x000000) - draw.centeredText(GPU, 40, 43, destinationColor, destinations[i].name) - event.timer(0.2, draw.update) + graphics.rectangle(GPU, 30, 43, 22, 2, 0x000000) + graphics.centeredText(GPU, 40, 43, destinationColor, destinations[i].name) + event.timer(0.2, graphics.update) return i end end @@ -53,7 +49,7 @@ function addBoundingBox(index) boundingBoxes[index] = {x = 2 + ((index - 1) % 5) * 20, y = 3 + math.floor((index - 1) / 4) * 8} end function getDestination() - for address, type in pairs(comp.list()) do + for address, type in pairs(component.list()) do if type == "ender_chest" then return util.machine(address).getFrequency() end @@ -62,13 +58,13 @@ end event.listen("touch", checkClick) GPU.freeAllBuffers() GPU.fill(0, 0, 100, 100, " ") -draw.rect(GPU, 28, 41, 26, 6, 0x111111) -draw.rect(GPU, 30, 43, 22, 2, 0x000000) -draw.text(GPU, 31, 39, 0xFFFFFF, "Current Destination") +graphics.rectangle(GPU, 28, 41, 26, 6, 0x111111) +graphics.rectangle(GPU, 30, 43, 22, 2, 0x000000) +graphics.text(GPU, 31, 39, 0xFFFFFF, "Current Destination") for i = 1, #destinations, 1 do addBoundingBox(i) createDestination(boundingBoxes[i].x, boundingBoxes[i].y, i) - draw.update() + graphics.update() end while true do os.sleep() diff --git a/Programs/Spatial Teleporter/spatial.lua b/Programs/Spatial Teleporter/spatial.lua index 8540495..0c380c6 100644 --- a/Programs/Spatial Teleporter/spatial.lua +++ b/Programs/Spatial Teleporter/spatial.lua @@ -1,15 +1,13 @@ -local comp = require("component") -local event = require("event") -local screen = require("term") -local computer = require("computer") +component = require("component") +computer = require("computer") function cycle() - comp.redstone.setOutput(2, 15) + component.redstone.setOutput(2, 15) os.sleep(1) - comp.redstone.setOutput(2, 0) + component.redstone.setOutput(2, 0) end -comp.gpu.setResolution(80, 40) +component.gpu.setResolution(80, 40) local incoming = 4 local sending = 3 @@ -26,7 +24,7 @@ function setDestination(destination) end function unload(index) - local transposer = comp.transposer + local transposer = component.transposer if transposer.getStackInSlot(controller, 1) ~= nil then --Using a return ticket cycle() @@ -55,11 +53,11 @@ function copyWindow(GPU, x, y, page, destination) end windows = {} function doStartupSequence() - local gpu = comp.gpu + local gpu = component.gpu gpu.freeAllBuffers() local colors = { - [0] = 0x00a6ff, - [1] = 0x000000 + [0] = colors.steelBlue, + [1] = colors.black } local buffer = gpu.allocateBuffer() gpu.setActiveBuffer(buffer) @@ -68,7 +66,7 @@ function doStartupSequence() copyWindow(gpu, 0, 0, buffer, 0) end gpu.setForeground(colors[i % 2]) - comp.gpu.fill(2 + i * 2, 1 + i, 80 - i * 4, 40 - i * 2, "█") + component.gpu.fill(2 + i * 2, 1 + i, 80 - i * 4, 40 - i * 2, "█") os.sleep(0.1) end gpu.setActiveBuffer(0) @@ -79,7 +77,7 @@ function doStartupSequence() end local starting = false function send() - local transposer = comp.transposer + local transposer = component.transposer if transposer.getStackInSlot(controller, 1) == nil then --screen.write("The operating cell is missing!\n") else @@ -90,7 +88,7 @@ function send() end end function checkArrivals() - local transposer = comp.transposer + local transposer = component.transposer for i = 1, 26 do if transposer.getStackInSlot(incoming, i) ~= nil then return i @@ -111,7 +109,7 @@ function activateTeleporter() lastActivation = computer.uptime() end event.listen("walk", activateTeleporter) -comp.gpu.fill(0, 0, 100, 50, " ") +component.gpu.fill(0, 0, 100, 50, " ") while true do local arrival = checkArrivals() if arrival ~= 0 then diff --git a/Programs/armorCharger.lua b/Programs/armorCharger.lua index 53f913c..f3ba60f 100644 --- a/Programs/armorCharger.lua +++ b/Programs/armorCharger.lua @@ -1,7 +1,6 @@ -comp = require("component") -event = require("event") +component = require("component") -local transposer = comp.transposer +local transposer = component.transposer local dark = 2 local charger = 3 function swap() diff --git a/Programs/autofeeder.lua b/Programs/autofeeder.lua index 683e805..aa2eab0 100644 --- a/Programs/autofeeder.lua +++ b/Programs/autofeeder.lua @@ -1,5 +1,5 @@ -Comp = require("component") -local transposer = Comp.transposer +component = require("component") +local transposer = component.transposer local players = {["Sampsa"] = 3, ["Dark"] = 2} local function findEmptyCans(player) local allItems = transposer.getAllStacks(players[player]).getAll() diff --git a/Programs/biovat.lua b/Programs/biovat.lua index 2423cc0..5d100b7 100644 --- a/Programs/biovat.lua +++ b/Programs/biovat.lua @@ -1,13 +1,11 @@ -local comp = require("component") -local event = require("event") -local screen = require("term") -local computer = require("computer") +component = require("component") +term = require("term") local transposers = {} function configureTransposers() - for address, type in pairs(comp.list()) do + for address, type in pairs(component.list()) do if type == "transposer" then - local transposer = comp.proxy(comp.get(address)) + local transposer = component.proxy(component.get(address)) local foundTanks = {} for side = 0, 5, 1 do if transposer.getTankCapacity(side) > 0 then @@ -21,15 +19,15 @@ function configureTransposers() transposers[address] = {source = foundTanks[1].side, sink = foundTanks[2].side} end else - screen.write("Some transposers have more than two tanks! FIX IT!\n") + term.write("Some transposers have more than two tanks! FIX IT!\n") end end end - screen.write("Found " .. countTransposers() .. " output hatches to keep at 50%\n") + term.write("Found " .. countTransposers() .. " output hatches to keep at 50%\n") end function countTransposers() local count = 0 - for address, type in pairs(comp.list()) do + for address, type in pairs(component.list()) do if type == "transposer" then count = count + 1 end @@ -38,7 +36,7 @@ function countTransposers() end function tick() for address, sides in pairs(transposers) do - local transposer = comp.proxy(comp.get(address)) + local transposer = component.proxy(component.get(address)) local sourceCurrent, sourceMax = transposer.getTankLevel(sides.source), transposer.getTankCapacity(sides.source) if sourceCurrent / sourceMax > 0.5 then local fluidToRemove = sourceCurrent - sourceMax / 2 diff --git a/Programs/energyControl.lua b/Programs/energyControl.lua index c722cf2..63917aa 100644 --- a/Programs/energyControl.lua +++ b/Programs/energyControl.lua @@ -1,16 +1,11 @@ -comp = require("component") -event = require("event") -screen = require("term") -computer = require("computer") -thread = require("thread") -uc = require("unicode") +component = require("component") -local LSC = comp.gt_machine +local LSC = component.gt_machine local engaged = false local function machine(address) - machineAddress = comp.get(address) + machineAddress = component.get(address) if (machineAddress ~= nil) then - return comp.proxy(machineAddress) + return component.proxy(machineAddress) else return nil end diff --git a/Programs/monitor-system/init.lua b/Programs/monitor-system/init.lua index 547c519..3483d70 100755 --- a/Programs/monitor-system/init.lua +++ b/Programs/monitor-system/init.lua @@ -1,6 +1,4 @@ -- Import section -computer = require("computer") -comp = require("component") MultiBlock = require("data.datasource.multi-block") SingleBlock = require("data.datasource.single-block") EnergyProvider = require("data.datasource.energy-provider")