Renaming global variables

Removing unnecessary `require(...)`s
This commit is contained in:
Gabriel Moreira Minossi 2021-01-06 11:39:50 -03:00
parent 03d355dfe6
commit 8fdf6b73e8
24 changed files with 131 additions and 188 deletions

View File

@ -1,8 +1,3 @@
component = require("component")
term = require("term")
computer = require("computer")
event = require("event")
local AR = {} local AR = {}
local terminal = {x = 8257, y = 199, z = -2731} local terminal = {x = 8257, y = 199, z = -2731}

View File

@ -1,8 +1,6 @@
component = require("component") component = require("component")
term = require("term")
computer = require("computer") computer = require("computer")
event = require("event") event = require("event")
thread = require("thread")
get = require("easy") get = require("easy")
ARG = require("ARGraphics") ARG = require("ARGraphics")
colors = require("colors") colors = require("colors")

View File

@ -1,5 +1,3 @@
component = require("component")
colors = require("colors")
local graphics = {} local graphics = {}
function graphics.pixel(GPU, x, y, color) function graphics.pixel(GPU, x, y, color)
@ -66,10 +64,10 @@ function graphics.centeredText(GPU, x, y, color, string)
end end
function graphics.border(GPU, w, h, color) function graphics.border(GPU, w, h, color)
draw.rectangle(GPU, 1, 1, w, 1, color) graphics.rectangle(GPU, 1, 1, w, 1, color)
draw.rectangle(GPU, 1, h * 2, w, 1, color) graphics.rectangle(GPU, 1, h * 2, w, 1, color)
draw.rectangle(GPU, 1, 1, 1, h * 2, color) graphics.rectangle(GPU, 1, 1, 1, h * 2, color)
draw.rectangle(GPU, w, 1, 1, h * 2, color) graphics.rectangle(GPU, w, 1, 1, h * 2, color)
end end
graphics.currentWindows = {} graphics.currentWindows = {}
function graphics.checkCollision(GPU, x, y) function graphics.checkCollision(GPU, x, y)

View File

@ -1,10 +1,9 @@
local draw = require("graphics") graphics = require("graphics")
event = require("event") event = require("event")
local thread = require("thread")
local uc = require("unicode") local uc = require("unicode")
component = require("component") component = require("component")
GPU = component.proxy(component.get("f26678f4")) GPU = component.proxy(component.get("f26678f4"))
local colors = require("colors") colors = require("colors")
local gui, quit, editing = {}, false, false local gui, quit, editing = {}, false, false
local currentWindows = {} local currentWindows = {}
@ -38,9 +37,9 @@ gui.contextMenu = function(GPU, x, y, data)
end end
local contextWindow = gui.createWindow(GPU, longestData, #data * 2, "ContextMenu" .. contextMenus) local contextWindow = gui.createWindow(GPU, longestData, #data * 2, "ContextMenu" .. contextMenus)
GPU.setActiveBuffer(contextWindow) 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 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 end
currentWindows["ContextMenu" .. contextMenus].x = x currentWindows["ContextMenu" .. contextMenus].x = x
currentWindows["ContextMenu" .. contextMenus].y = y currentWindows["ContextMenu" .. contextMenus].y = y
@ -73,13 +72,13 @@ gui.processCommand = function(GPU, window, option)
end end
GPU.setActiveBuffer(currentWindows["ColorBox"].page) GPU.setActiveBuffer(currentWindows["ColorBox"].page)
if option == 1 then if option == 1 then
draw.rectangle(GPU, 1, 1, 10, 10, colors.red) graphics.rectangle(GPU, 1, 1, 10, 10, colors.red)
end end
if option == 2 then if option == 2 then
draw.rectangle(GPU, 1, 1, 10, 10, colors.blue) graphics.rectangle(GPU, 1, 1, 10, 10, colors.blue)
end end
if option == 3 then if option == 3 then
draw.rectangle(GPU, 1, 1, 10, 10, colors.green) graphics.rectangle(GPU, 1, 1, 10, 10, colors.green)
end end
GPU.setActiveBuffer(0) GPU.setActiveBuffer(0)
end end
@ -88,7 +87,7 @@ local i, xOffset, yOffset = 1, 0, 0
gui.mouseListener = function() gui.mouseListener = function()
local function processClick(event, address, x, y, key, player) local function processClick(event, address, x, y, key, player)
activeWindow = gui.checkCollision(x, y) 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 key == 1.0 and editing then
if inContextMenu then if inContextMenu then
contextMenus = 0 contextMenus = 0
@ -172,13 +171,13 @@ GPU.freeAllBuffers()
keyInput, mouseInput, drag = gui.keyboardListener(), gui.mouseListener(), gui.dragListener() keyInput, mouseInput, drag = gui.keyboardListener(), gui.mouseListener(), gui.dragListener()
gui.createWindow(GPU, 160, 100, "Black") gui.createWindow(GPU, 160, 100, "Black")
GPU.setActiveBuffer(currentWindows["Black"].page) 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"].w = 0
currentWindows["Black"].h = 0 currentWindows["Black"].h = 0
GPU.setActiveBuffer(0) GPU.setActiveBuffer(0)
gui.createWindow(GPU, 160, 100, "State") gui.createWindow(GPU, 160, 100, "State")
GPU.setActiveBuffer(currentWindows["State"].page) 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"].w = 0
currentWindows["State"].h = 0 currentWindows["State"].h = 0
GPU.setActiveBuffer(0) GPU.setActiveBuffer(0)

View File

@ -1,7 +1,3 @@
component = require("component")
term = require("term")
computer = require("computer")
event = require("event")
graphics = require("graphics") graphics = require("graphics")
util = require("utility") util = require("utility")
colors = require("colors") colors = require("colors")

View File

@ -1,7 +1,6 @@
local comp = require("component") component = require("component")
local event = require("event") event = require("event")
local modem = comp.modem local modem = component.modem
local screen = require("term")
local util = require("utility") local util = require("utility")
AR = require("AR") AR = require("AR")
glasses = util.machine("3770e3f9") glasses = util.machine("3770e3f9")

View File

@ -1,14 +1,13 @@
local comp = require("component") component = require("component")
local event = require("event") event = require("event")
local thread = require("thread")
local uc = require("unicode") local uc = require("unicode")
local utility = {} local utility = {}
local modem = comp.modem local modem = component.modem
function utility.machine(address) function utility.machine(address)
machineAddress = comp.get(address) machineAddress = component.get(address)
if (machineAddress ~= nil) then if (machineAddress ~= nil) then
return comp.proxy(machineAddress) return component.proxy(machineAddress)
else else
return nil return nil
end end

View File

@ -1,14 +1,10 @@
comp = require("component")
event = require("event") event = require("event")
screen = require("term") term = require("term")
computer = require("computer")
thread = require("thread")
local AU = require("util") local AU = require("util")
local AT = require("transport") local AT = require("transport")
local S = require("serialization") local S = require("serialization")
local uc = require("unicode") local uc = require("unicode")
local D = require("dictionary") local network = component.modem
local network = comp.modem
local id, AD local id, AD
local function requestID() local function requestID()
network.broadcast(100, "requestID") network.broadcast(100, "requestID")
@ -103,10 +99,10 @@ local function processRecipe(recipe)
os.sleep(0.2) os.sleep(0.2)
end end
if not AD.controller.hasWork() then if not AD.controller.hasWork() then
screen.write(" ... Error with starting assembly!") term.write(" ... Error with starting assembly!")
network.broadcast(id, "jammed") network.broadcast(id, "jammed")
else else
screen.write(" ... Assembly Started") term.write(" ... Assembly Started")
while AD.controller.hasWork() do while AD.controller.hasWork() do
os.sleep(0.1) os.sleep(0.1)
end end
@ -115,14 +111,14 @@ local function processRecipe(recipe)
end end
end end
AT.clearAll(AD) AT.clearAll(AD)
screen.write(" ... finished task!\n") term.write(" ... finished task!\n")
network.broadcast(id, "complete") network.broadcast(id, "complete")
end end
local function processMessage(localAddress, remoteAddress, port, distance, type, eventType, value2, value3) local function processMessage(localAddress, remoteAddress, port, distance, type, eventType, value2, value3)
if eventType == "startAssembly" then if eventType == "startAssembly" then
local recipe = S.unserialize(value2) local recipe = S.unserialize(value2)
screen.write("Starting assembly of " .. recipe.label) term.write("Starting assembly of " .. recipe.label)
processRecipe(recipe) processRecipe(recipe)
elseif eventType == "clear" then elseif eventType == "clear" then
AT.clearAll(AD) AT.clearAll(AD)
@ -130,7 +126,7 @@ local function processMessage(localAddress, remoteAddress, port, distance, type,
end end
local function quit() local function quit()
screen.write("Quitting...") term.write("Quitting...")
event.ignore("modem_message", processMessage) event.ignore("modem_message", processMessage)
event.ignore("key_up", processKey) event.ignore("key_up", processKey)
os.exit() os.exit()

View File

@ -1,13 +1,10 @@
comp = require("component") component = require("component")
event = require("event") event = require("event")
screen = require("term") term = require("term")
computer = require("computer")
thread = require("thread")
uc = require("unicode")
AU = require("util") AU = require("util")
local uc = require("unicode")
local S = require("serialization") local S = require("serialization")
local D = require("dictionary") local network = component.modem
local network = comp.modem
local mainChannel = 100 local mainChannel = 100
-- mainChannel = Main channel for bi-directional communication -- mainChannel = Main channel for bi-directional communication
@ -58,7 +55,7 @@ local function processMessage(type, localAddress, remoteAddress, port, distance,
end end
local function quit() local function quit()
screen.write("Quitting...") term.write("Quitting...")
event.ignore("modem_message", processMessage) event.ignore("modem_message", processMessage)
event.ignore("key_up", processKey) event.ignore("key_up", processKey)
run = false run = false
@ -101,7 +98,7 @@ local function spairs(t, order)
end end
end end
function matchRecipe(recipes) function matchRecipe(recipes)
local items = comp.me_interface.getItemsInNetwork() local items = component.me_interface.getItemsInNetwork()
local foundItems = {} local foundItems = {}
if #items > 0 then if #items > 0 then
for i = 1, #items, 1 do for i = 1, #items, 1 do
@ -164,10 +161,10 @@ local function scheduleTasks()
if not contains(assemblyStatus, recipe.label) then if not contains(assemblyStatus, recipe.label) then
local taskid = getFree() local taskid = getFree()
if taskid ~= nil then 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) startAssembly(taskid, recipe)
else else
screen.write("No free assembly lines.\n") term.write("No free assembly lines.\n")
end end
end end
return true return true
@ -176,9 +173,9 @@ local function scheduleTasks()
local taskid = getFree() local taskid = getFree()
if taskid ~= nil then if taskid ~= nil then
startAssembly(taskid, recipe) 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 else
screen.write("No free assembly lines.\n") term.write("No free assembly lines.\n")
end end
craftable = craftable - 8 craftable = craftable - 8
end end

View File

@ -1,8 +1,4 @@
comp = require("component") component = require("component")
event = require("event")
screen = require("term")
computer = require("computer")
thread = require("thread")
local transport = {} local transport = {}
@ -16,7 +12,7 @@ function transport.empty(transposer)
transposer.transferItem(1, 0, 64, 2, 9) transposer.transferItem(1, 0, 64, 2, 9)
end end
function transport.clear(interface) function transport.clear(interface)
interface.setInterfaceConfiguration(1, comp.database.address, 1, 0) interface.setInterfaceConfiguration(1, component.database.address, 1, 0)
end end
function transport.check(transposer, item, amount) function transport.check(transposer, item, amount)
local itemstack = transposer.getStackInSlot(0, 1) local itemstack = transposer.getStackInSlot(0, 1)

View File

@ -1,27 +1,25 @@
comp = require("component") component = require("component")
event = require("event") event = require("event")
screen = require("term") term = require("term")
computer = require("computer")
thread = require("thread")
local assemblyUtil = {} local assemblyUtil = {}
local function addEntries(file, prompt, amount, type) local function addEntries(file, prompt, amount, type)
local a, b, c local a, b, c
for i = 1, amount, 1 do for i = 1, amount, 1 do
screen.write(prompt .. " " .. i .. " ") term.write(prompt .. " " .. i .. " ")
a, b, c = event.pull() a, b, c = event.pull()
while a ~= "component_added" do while a ~= "component_added" do
a, b, c = event.pull() a, b, c = event.pull()
os.sleep() os.sleep()
end end
file:write(type .. i .. "," .. b .. "\n") file:write(type .. i .. "," .. b .. "\n")
screen.write(b .. "\n") term.write(b .. "\n")
end end
end end
local function addAuxilary(file, proxy, type) local function addAuxilary(file, proxy, type)
if proxy == nil then if proxy == nil then
screen.write("Cant find a valid " .. type .. "! Exiting...\n") term.write("Cant find a valid " .. type .. "! Exiting...\n")
os.exit() os.exit()
else else
file:write(type .. "," .. proxy.address .. "\n") file:write(type .. "," .. proxy.address .. "\n")
@ -41,9 +39,9 @@ local function split(s, sep)
return fields return fields
end end
local function proxy(address) local function proxy(address)
machineAddress = comp.get(address) machineAddress = component.get(address)
if (machineAddress ~= nil) then if (machineAddress ~= nil) then
return comp.proxy(machineAddress) return component.proxy(machineAddress)
else else
return nil return nil
end end
@ -54,27 +52,27 @@ local function configureClient()
addEntries(file, "Add fluid interface", 4, "fluid") addEntries(file, "Add fluid interface", 4, "fluid")
addEntries(file, "Add item transposer", 15, "inputTransposer") addEntries(file, "Add item transposer", 15, "inputTransposer")
addEntries(file, "Add fluid transposer", 4, "fluidTransposer") addEntries(file, "Add fluid transposer", 4, "fluidTransposer")
addAuxilary(file, comp.me_interface, "items") addAuxilary(file, component.me_interface, "items")
addAuxilary(file, comp.database, "database") addAuxilary(file, component.database, "database")
addAuxilary(file, comp.gt_machine, "controller") addAuxilary(file, component.gt_machine, "controller")
end end
function assemblyUtil.buildClient() function assemblyUtil.buildClient()
screen.write("Starting Assembly Line initalization...") term.write("Starting Assembly Line initalization...")
local assemblyStructure = {} local assemblyStructure = {}
local file = io.open("addresses", "r") local file = io.open("addresses", "r")
if file == nil then if file == nil then
screen.write(" no address configuration found, configuring:\n") term.write(" no address configuration found, configuring:\n")
configureClient() configureClient()
file = io.lines("addresses") file = io.lines("addresses")
else else
file = io.lines("addresses") file = io.lines("addresses")
end end
for line in file do for line in file do
screen.write(".") term.write(".")
local tokens = split(line, ",") local tokens = split(line, ",")
assemblyStructure[tokens[1]] = proxy(tokens[2]) assemblyStructure[tokens[1]] = proxy(tokens[2])
end end
screen.write("\n") term.write("\n")
return assemblyStructure return assemblyStructure
end end
local function voltageToTier(voltage) local function voltageToTier(voltage)
@ -142,7 +140,7 @@ local function addRecipe(recipelist, slot, source, sourceSide)
end end
end end
function assemblyUtil.getRecipes(recipelist) function assemblyUtil.getRecipes(recipelist)
for address, type in pairs(comp.list()) do for address, type in pairs(component.list()) do
if type == "transposer" then if type == "transposer" then
local dataSource = proxy(address) local dataSource = proxy(address)
for side = 0, 5 do for side = 0, 5 do

View File

@ -2,9 +2,7 @@ component = require("component")
term = require("term") term = require("term")
computer = require("computer") computer = require("computer")
event = require("event") event = require("event")
thread = require("thread")
local sides = require("sides") local sides = require("sides")
ARG = require("ARGraphics")
graphics = require("graphics") graphics = require("graphics")
S = require("stockerUtil") S = require("stockerUtil")
local uc = require("unicode") local uc = require("unicode")

View File

@ -1,7 +1,4 @@
component = require("component") component = require("component")
term = require("term")
computer = require("computer")
ARG = require("ARGraphics")
graphics = require("graphics") graphics = require("graphics")
local tx = require("transforms") local tx = require("transforms")
GPU = component.gpu GPU = component.gpu

View File

@ -1,18 +1,16 @@
comp = require("component") component = require("component")
event = require("event")
AR = require("ARWidgets") AR = require("ARWidgets")
ARG = require("ARGraphics")
local wSampsa, hSampsa = 853, 473 local wSampsa, hSampsa = 853, 473
local powerHudX, powerHudY, powerHudW, powerHudH = 0, hSampsa - 24, wSampsa * 0.39 + 3, 14 local powerHudX, powerHudY, powerHudW, powerHudH = 0, hSampsa - 24, wSampsa * 0.39 + 3, 14
local glasses = comp.glasses local glasses = component.glasses
glasses.removeAll() glasses.removeAll()
AR.minimapOverlay(glasses) AR.minimapOverlay(glasses)
AR.hudOverlayBase(glasses, 335, 449) AR.hudOverlayBase(glasses, 335, 449)
AR.clear() AR.clear()
AR.crossHair(glasses, 422, 231) AR.crossHair(glasses, 422, 231)
screen.clear() term.clear()
while true do 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( AR.fluidMonitor(
glasses, glasses,
795, 795,

View File

@ -1,7 +1,6 @@
comp = require("component") component = require("component")
event = require("event")
AR = require("ARWidgets") AR = require("ARWidgets")
while true do while true do
AR.itemTicker(comp.glasses, 348, 0, 380) AR.itemTicker(component.glasses, 348, 0, 380)
end end

View File

@ -1,8 +1,7 @@
comp = require("component") component = require("component")
event = require("event")
AR = require("ARWidgets") AR = require("ARWidgets")
while true do while true do
AR.displayTPS(comp.glasses, 0, 0) AR.displayTPS(component.glasses, 0, 0)
AR.cpuMonitor(comp.glasses, 520, 449) AR.cpuMonitor(component.glasses, 520, 449)
end end

View File

@ -1,50 +1,47 @@
comp = require("component") component = require("component")
event = require("event") term = require("term")
screen = require("term")
computer = require("computer")
thread = require("thread")
local GPU = comp.gpu local GPU = component.gpu
GPU.setResolution(54, 26) GPU.setResolution(54, 26)
function enableReactors() local function enableReactors()
comp.redstone.setOutput(1, 15) component.redstone.setOutput(1, 15)
end end
function disableReactors() local function disableReactors()
comp.redstone.setOutput(1, 0) component.redstone.setOutput(1, 0)
end end
function checkHeatLevels() local function checkHeatLevels()
screen.setCursor(1, 1) term.setCursor(1, 1)
local i = 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 if type == "reactor_chamber" then
screen.write("Reactor " .. i) term.write("Reactor " .. i)
if i < 10 then if i < 10 then
screen.write(" ") term.write(" ")
end end
local reactor = comp.proxy(address) local reactor = component.proxy(address)
if reactor.getHeat() > 0 then if reactor.getHeat() > 0 then
GPU.setForeground(0xFF0000) GPU.setForeground(0xFF0000)
screen.write(" REACTOR HEATING! SHUTTING DOWN") term.write(" REACTOR HEATING! SHUTTING DOWN")
disableReactors() disableReactors()
GPU.setForeground(0xFFFFFF) GPU.setForeground(0xFFFFFF)
os.sleep(1) os.sleep(1)
os.exit() os.exit()
else else
if reactor.getReactorEUOutput() > 0 then if reactor.getReactorEUOutput() > 0 then
screen.write(" status: ") term.write(" status: ")
GPU.setForeground(0x00FF00) GPU.setForeground(0x00FF00)
screen.write("NOMINAL") term.write("NOMINAL")
GPU.setForeground(0xFFFFFF) GPU.setForeground(0xFFFFFF)
screen.write(" - Producing ") term.write(" - Producing ")
GPU.setForeground(0xFF00FF) GPU.setForeground(0xFF00FF)
screen.write(math.floor(reactor.getReactorEUOutput())) term.write(math.floor(reactor.getReactorEUOutput()))
GPU.setForeground(0xFFFFFF) GPU.setForeground(0xFFFFFF)
screen.write(" EU/t\n") term.write(" EU/t\n")
else else
screen.write(" status: ") term.write(" status: ")
GPU.setForeground(0xFFFF00) GPU.setForeground(0xFFFF00)
screen.write("INACTIVE\n") term.write("INACTIVE\n")
end end
end end
i = i + 1 i = i + 1
@ -53,7 +50,7 @@ function checkHeatLevels()
end end
enableReactors() enableReactors()
screen.clear() term.clear()
while true do while true do
checkHeatLevels() checkHeatLevels()
os.sleep(1) os.sleep(1)

View File

@ -7,13 +7,9 @@ destinations = {
[6] = {name = "Test", id = 3004} [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 util = require("utility")
local draw = require("graphics") graphics = require("graphics")
local GPU = comp.gpu local GPU = component.gpu
GPU.setResolution(80, 25) GPU.setResolution(80, 25)
local boundingBoxes = {} local boundingBoxes = {}
@ -21,15 +17,15 @@ function createDestination(x, y, index)
local width, height = 18, 6 local width, height = 18, 6
local page = GPU.allocateBuffer(width, math.ceil(height / 2)) local page = GPU.allocateBuffer(width, math.ceil(height / 2))
GPU.setActiveBuffer(page) 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 local destinationColor = destinations[index].color or 0x0055FF
draw.rect(GPU, 3, 3, 14, 2, 0x000000) graphics.rectangle(GPU, 3, 3, 14, 2, 0x000000)
draw.centeredText(GPU, 10, 3, destinationColor, destinations[index].name) graphics.centeredText(GPU, 10, 3, destinationColor, destinations[index].name)
windows[index] = {GPU = GPU, page = page, address = "", x = x, y = y, w = width, h = height} windows[index] = {GPU = GPU, page = page, address = "", x = x, y = y, w = width, h = height}
GPU.setActiveBuffer(0) GPU.setActiveBuffer(0)
end end
function setDestination(code) function setDestination(code)
for address, type in pairs(comp.list()) do for address, type in pairs(component.list()) do
if type == "ender_chest" then if type == "ender_chest" then
util.machine(address).setFrequency(code) util.machine(address).setFrequency(code)
end end
@ -39,12 +35,12 @@ function checkClick(_, address, x, y, button, name)
for i = 1, #boundingBoxes, 1 do for i = 1, #boundingBoxes, 1 do
local xb, yb = boundingBoxes[i].x, math.ceil(boundingBoxes[i].y / 2) 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 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 local destinationColor = destinations[i].color or 0x0055FF
setDestination(destinations[i].id) setDestination(destinations[i].id)
draw.rect(GPU, 30, 43, 22, 2, 0x000000) graphics.rectangle(GPU, 30, 43, 22, 2, 0x000000)
draw.centeredText(GPU, 40, 43, destinationColor, destinations[i].name) graphics.centeredText(GPU, 40, 43, destinationColor, destinations[i].name)
event.timer(0.2, draw.update) event.timer(0.2, graphics.update)
return i return i
end end
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} boundingBoxes[index] = {x = 2 + ((index - 1) % 5) * 20, y = 3 + math.floor((index - 1) / 4) * 8}
end end
function getDestination() function getDestination()
for address, type in pairs(comp.list()) do for address, type in pairs(component.list()) do
if type == "ender_chest" then if type == "ender_chest" then
return util.machine(address).getFrequency() return util.machine(address).getFrequency()
end end
@ -62,13 +58,13 @@ end
event.listen("touch", checkClick) event.listen("touch", checkClick)
GPU.freeAllBuffers() GPU.freeAllBuffers()
GPU.fill(0, 0, 100, 100, " ") GPU.fill(0, 0, 100, 100, " ")
draw.rect(GPU, 28, 41, 26, 6, 0x111111) graphics.rectangle(GPU, 28, 41, 26, 6, 0x111111)
draw.rect(GPU, 30, 43, 22, 2, 0x000000) graphics.rectangle(GPU, 30, 43, 22, 2, 0x000000)
draw.text(GPU, 31, 39, 0xFFFFFF, "Current Destination") graphics.text(GPU, 31, 39, 0xFFFFFF, "Current Destination")
for i = 1, #destinations, 1 do for i = 1, #destinations, 1 do
addBoundingBox(i) addBoundingBox(i)
createDestination(boundingBoxes[i].x, boundingBoxes[i].y, i) createDestination(boundingBoxes[i].x, boundingBoxes[i].y, i)
draw.update() graphics.update()
end end
while true do while true do
os.sleep() os.sleep()

View File

@ -1,15 +1,13 @@
local comp = require("component") component = require("component")
local event = require("event") computer = require("computer")
local screen = require("term")
local computer = require("computer")
function cycle() function cycle()
comp.redstone.setOutput(2, 15) component.redstone.setOutput(2, 15)
os.sleep(1) os.sleep(1)
comp.redstone.setOutput(2, 0) component.redstone.setOutput(2, 0)
end end
comp.gpu.setResolution(80, 40) component.gpu.setResolution(80, 40)
local incoming = 4 local incoming = 4
local sending = 3 local sending = 3
@ -26,7 +24,7 @@ function setDestination(destination)
end end
function unload(index) function unload(index)
local transposer = comp.transposer local transposer = component.transposer
if transposer.getStackInSlot(controller, 1) ~= nil then if transposer.getStackInSlot(controller, 1) ~= nil then
--Using a return ticket --Using a return ticket
cycle() cycle()
@ -55,11 +53,11 @@ function copyWindow(GPU, x, y, page, destination)
end end
windows = {} windows = {}
function doStartupSequence() function doStartupSequence()
local gpu = comp.gpu local gpu = component.gpu
gpu.freeAllBuffers() gpu.freeAllBuffers()
local colors = { local colors = {
[0] = 0x00a6ff, [0] = colors.steelBlue,
[1] = 0x000000 [1] = colors.black
} }
local buffer = gpu.allocateBuffer() local buffer = gpu.allocateBuffer()
gpu.setActiveBuffer(buffer) gpu.setActiveBuffer(buffer)
@ -68,7 +66,7 @@ function doStartupSequence()
copyWindow(gpu, 0, 0, buffer, 0) copyWindow(gpu, 0, 0, buffer, 0)
end end
gpu.setForeground(colors[i % 2]) 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) os.sleep(0.1)
end end
gpu.setActiveBuffer(0) gpu.setActiveBuffer(0)
@ -79,7 +77,7 @@ function doStartupSequence()
end end
local starting = false local starting = false
function send() function send()
local transposer = comp.transposer local transposer = component.transposer
if transposer.getStackInSlot(controller, 1) == nil then if transposer.getStackInSlot(controller, 1) == nil then
--screen.write("The operating cell is missing!\n") --screen.write("The operating cell is missing!\n")
else else
@ -90,7 +88,7 @@ function send()
end end
end end
function checkArrivals() function checkArrivals()
local transposer = comp.transposer local transposer = component.transposer
for i = 1, 26 do for i = 1, 26 do
if transposer.getStackInSlot(incoming, i) ~= nil then if transposer.getStackInSlot(incoming, i) ~= nil then
return i return i
@ -111,7 +109,7 @@ function activateTeleporter()
lastActivation = computer.uptime() lastActivation = computer.uptime()
end end
event.listen("walk", activateTeleporter) event.listen("walk", activateTeleporter)
comp.gpu.fill(0, 0, 100, 50, " ") component.gpu.fill(0, 0, 100, 50, " ")
while true do while true do
local arrival = checkArrivals() local arrival = checkArrivals()
if arrival ~= 0 then if arrival ~= 0 then

View File

@ -1,7 +1,6 @@
comp = require("component") component = require("component")
event = require("event")
local transposer = comp.transposer local transposer = component.transposer
local dark = 2 local dark = 2
local charger = 3 local charger = 3
function swap() function swap()

View File

@ -1,5 +1,5 @@
Comp = require("component") component = require("component")
local transposer = Comp.transposer local transposer = component.transposer
local players = {["Sampsa"] = 3, ["Dark"] = 2} local players = {["Sampsa"] = 3, ["Dark"] = 2}
local function findEmptyCans(player) local function findEmptyCans(player)
local allItems = transposer.getAllStacks(players[player]).getAll() local allItems = transposer.getAllStacks(players[player]).getAll()

View File

@ -1,13 +1,11 @@
local comp = require("component") component = require("component")
local event = require("event") term = require("term")
local screen = require("term")
local computer = require("computer")
local transposers = {} local transposers = {}
function configureTransposers() function configureTransposers()
for address, type in pairs(comp.list()) do for address, type in pairs(component.list()) do
if type == "transposer" then if type == "transposer" then
local transposer = comp.proxy(comp.get(address)) local transposer = component.proxy(component.get(address))
local foundTanks = {} local foundTanks = {}
for side = 0, 5, 1 do for side = 0, 5, 1 do
if transposer.getTankCapacity(side) > 0 then if transposer.getTankCapacity(side) > 0 then
@ -21,15 +19,15 @@ function configureTransposers()
transposers[address] = {source = foundTanks[1].side, sink = foundTanks[2].side} transposers[address] = {source = foundTanks[1].side, sink = foundTanks[2].side}
end end
else 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 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 end
function countTransposers() function countTransposers()
local count = 0 local count = 0
for address, type in pairs(comp.list()) do for address, type in pairs(component.list()) do
if type == "transposer" then if type == "transposer" then
count = count + 1 count = count + 1
end end
@ -38,7 +36,7 @@ function countTransposers()
end end
function tick() function tick()
for address, sides in pairs(transposers) do 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) local sourceCurrent, sourceMax = transposer.getTankLevel(sides.source), transposer.getTankCapacity(sides.source)
if sourceCurrent / sourceMax > 0.5 then if sourceCurrent / sourceMax > 0.5 then
local fluidToRemove = sourceCurrent - sourceMax / 2 local fluidToRemove = sourceCurrent - sourceMax / 2

View File

@ -1,16 +1,11 @@
comp = require("component") component = require("component")
event = require("event")
screen = require("term")
computer = require("computer")
thread = require("thread")
uc = require("unicode")
local LSC = comp.gt_machine local LSC = component.gt_machine
local engaged = false local engaged = false
local function machine(address) local function machine(address)
machineAddress = comp.get(address) machineAddress = component.get(address)
if (machineAddress ~= nil) then if (machineAddress ~= nil) then
return comp.proxy(machineAddress) return component.proxy(machineAddress)
else else
return nil return nil
end end

View File

@ -1,6 +1,4 @@
-- Import section -- Import section
computer = require("computer")
comp = require("component")
MultiBlock = require("data.datasource.multi-block") MultiBlock = require("data.datasource.multi-block")
SingleBlock = require("data.datasource.single-block") SingleBlock = require("data.datasource.single-block")
EnergyProvider = require("data.datasource.energy-provider") EnergyProvider = require("data.datasource.energy-provider")