Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package.loaded["autocompressor/gui"] = nil
- package.loaded["autocompressor/crafting_unit"] = nil
- local crafting_unit = require("autocompressor/crafting_unit")
- local checkTime = crafting_unit.checkTime
- local sides = require("sides")
- local component = require("component")
- local gpu = component.gpu
- local originalResX, originalResY = gpu.getResolution()
- gpu.setResolution(80, 25)
- local gui = require("autocompressor/gui")
- local event = require("event")
- local beep = require("computer").beep
- local unicode = require("unicode")
- local serialization = require("serialization")
- local fs = require("filesystem")
- gui.checkVersion(2, 5)
- local save = function() end
- ---@type table<string, autocompressor.crafting_unit>
- local unities = {}
- local nameGui = gui.newGui("center", "center", 40, 10, true, "Adicionando Transpositor")
- local nameLabel1 = gui.newLabel(nameGui, "center", 2, "Dê um nome para o transpositor")
- local nameLabel2 = gui.newLabel(nameGui, "center", 3, "")
- local nameLabel3 = gui.newLabel(nameGui, 10, 5, "Nome:")
- local nameText = gui.newText(nameGui, 16, 5, 12, "")
- local nameRendering = false
- local nameAdd = gui.newButton(nameGui, 7, 8, " Adicionar ", function () end)
- local nameClose = gui.newButton(nameGui, 21, 8, " Cancelar ", function ()
- nameRendering = false
- gui.closeGui(nameGui)
- end)
- local addPatternGui = gui.newGui("center", 3, 41, 21, true, "Adicionando Nova Receita")
- local addPatternRendering = false
- gui.newLabel(addPatternGui, 1, 2, "Produto criado:")
- local addPatternProductName = gui.newText(addPatternGui, 16, 2, 32, "", nil, 16)
- gui.newLabel(addPatternGui, 32, 2,"Qntd:")
- local function numberOnly (window, field, text)
- if text == nil then text = "1" else text = tostring(text) end
- local changed = text:gsub("%D", ""):gsub("0(%d)", "%1")
- if #changed == 0 or changed == "0" then
- changed = "1"
- end
- if changed ~= text then
- gui.setText(window, field, changed)
- end
- end
- local addPatternAmount = gui.newText(addPatternGui, 37, 2, 3, "1", numberOnly, 3)
- local addPatternGridFrames = {}
- for y = 0, 2 do
- for x = 0, 2 do
- table.insert(addPatternGridFrames,
- gui.newFrame(addPatternGui, 1 + x*13, 4 + y*5, 13, 5)
- )
- end
- end
- local addPatternGrid = {}
- for y = 0, 2 do
- for x = 0, 2 do
- table.insert(addPatternGrid,
- gui.newMultiLineLabel(addPatternGui, 1 + x*13 + 1, 4 + y*5 + 1, 11, 3, "")
- )
- end
- end
- ---@class autocompressor.gui.addpattern.modify
- ---@field quantityField
- local addPatternModify = {}
- for y = 0, 2 do
- for x = 0, 2 do
- table.insert(addPatternModify,
- gui.newText(addPatternGui, 1 + x*13 + 5, 4 + y*5, 3, "0", numberOnly)
- )
- end
- end
- local addPatternAdd = gui.newButton(addPatternGui, 7, 19, " Adicionar ", function () end)
- gui.newButton(addPatternGui, 21, 19, " Cancelar ", function ()
- addPatternRendering = false
- gui.closeGui(addPatternGui)
- end)
- local changeTransposerGui = gui.newGui("center", 3, 41, 20, true, "Alterando...")
- local changeTransposerNameLabel = gui.newLabel(changeTransposerGui, 2, 2, "Nome do transpositor: ")
- local changeTransposerName = gui.newText(changeTransposerGui, 24, 2, 12, "", nil, 15)
- --local changeTransposerRecipesLabel = gui.newLabel(changeTransposerGui, 2, 4, "Receitas")
- local changeTransposerList = gui.newList(changeTransposerGui, 2, 4, 22, 15, {}, nil, "Receitas")
- local changeTransposerRunning = false
- local changeTransposerClose = gui.newButton(changeTransposerGui, 26, 18, " Fechar ", function ()
- changeTransposerRunning = false
- end)
- local changeTransposerAdd = gui.newButton(changeTransposerGui, 26, 4, " Adicionar ")
- local changeTransposerModify = gui.newButton(changeTransposerGui, 26, 6, " Alterar ")
- local changeTransposerRemove = gui.newButton(changeTransposerGui, 26, 8, " Remover ")
- -- Begin: Menu definitions
- local function createWindow()
- ---@class autocompressor.gui.main.window
- ---@field transposers table<string,autocompressor.gui.main.transposer>
- ---@field scrollBar number
- local window = { transposers = {} }
- local function recreateGui()
- window.transposers = {}
- window.mainGui = gui.newGui(1, 2, 79, 23, false)
- window.exitButton = gui.newButton(window.mainGui, 73, 23, "sair", function(guiID, id)
- local result = gui.getYesNo("", "Você tem certeza que deseja sair?", "")
- if result == true then
- gpu.setResolution(originalResX, originalResY)
- gpu.setBackground(0x000000)
- gpu.setForeground(0xFFFFFF)
- gpu.fill(1, 1, originalResX, originalResY, " ")
- require("term").clear()
- os.exit()
- end
- end)
- window.col = 0
- window.lin = 1
- end
- recreateGui()
- function window.nextBlock()
- local col = window.col
- local lin = window.lin
- if col >= 4 then
- if lin >= 2 then
- return false
- else
- lin = lin + 1
- col = 1
- end
- else
- col = col + 1
- end
- window.col = col
- window.lin = lin
- return true
- end
- function window.createHorizontalScroll()
- window.scrollBar = gui.newVSlider(window.mainGui, 1, 21, 74, 1, 1, 1, function(guiID, vSliderID, value)
- end)
- return window.scrollBar
- end
- ---@param amount number
- ---@param name string
- ---@return boolean
- local function validateProductName(name, amount)
- if unicode.len(name) < 3 or unicode.len(name) > 32 then
- gui.showError("O nome do produto digitado", "tem que ter", "de 3 letras a 32 caractéres", true)
- return true
- end
- if amount == 0 or amount > 999 then
- gui.showError("", "Invalid amount", true)
- return true
- end
- return false
- end
- ---@param unit autocompressor.crafting_unit
- function window.createTransposerBlock(line, col, unit)
- local mainGui = window.mainGui
- ---@class autocompressor.gui.main.transposer
- local block = {}
- local frameX = (col - 1) * 20
- local frameY = 1 + (line - 1) * 10
- block.frame = gui.newFrame(mainGui, frameX, frameY, 20, 10, unit.name:sub(1,12))
- block.btn_learn = gui.newButton(mainGui, frameX + 1, frameY + 1, "+", function(guiID, buttonID)
- local inputs = unit:getInputs()
- ---@class autocompressor.grid.result
- ---@field chest autocompressor.chest
- ---@field grid table<number, _item_stack>
- ---@type autocompressor.grid.result[]
- local gridsFound = {}
- for side, chest in pairs(inputs) do
- local grid = chest:getGridStacks()
- for slot, stack in pairs(grid) do
- if stack.name == "minecraft:stick" or stack.size <= 0 then
- grid[slot] = nil
- end
- end
- if next(grid) ~= nil then
- table.insert(gridsFound, {chest=chest, grid=grid})
- end
- end
- if not next(gridsFound) then
- gui.showError("Nenhum padrão foi encontrado", "em nenhum baú conectado ao", "transpositor "..unit.name, true)
- return
- end
- local selection
- if #gridsFound > 1 then
- gui.showError("", "Não implementado", "", true)
- return
- else
- selection = gridsFound[1]
- end
- local minStack = math.huge
- for i = 1, 9 do
- ---@type _item_stack
- local stack = selection.grid[i]
- local label
- local title
- if not stack then
- title = nil
- label = ""
- else
- title = stack.size.."x"
- if stack.size < minStack then
- minStack = stack.size
- end
- if string.len(stack.label) > 0 then
- label = stack.label
- else
- label = stack.name
- end
- end
- addPatternGui[addPatternAmount].text = minStack
- addPatternGui[addPatternProductName].text = ""
- addPatternGui[addPatternGridFrames[i]].text = title
- addPatternGui[addPatternAdd].text = "[ Adicionar ]"
- addPatternGui.text = "|Adicionando Nova Receita|"
- addPatternGui[addPatternGrid[i]].text = label
- for i, fieldId in ipairs(addPatternModify) do
- addPatternGui[fieldId].visible = false
- end
- end
- addPatternGui[addPatternAdd].func = function()
- local name = addPatternGui[addPatternProductName].text
- local amount = tonumber(addPatternGui[addPatternAmount].text)
- if validateProductName(name, amount) then
- return
- end
- ---@type autocompressor.chest
- local chest = selection.chest
- if chest:createGrid(selection.grid, name, amount) then
- save()
- gui.showMsg("A receita para criar", name:sub(1,30), "foi salva com sucesso.")
- end
- addPatternRendering = false
- end
- addPatternGui[addPatternProductName].func = nil
- addPatternRendering = true
- gui.displayGui(addPatternGui)
- while addPatternRendering do
- gui.runGui(addPatternGui)
- end
- gui.closeGui(addPatternGui)
- end)
- block.btn_modify = gui.newButton(mainGui, frameX + 5, frameY + 1, "Mudar", function(guiID, buttonID)
- changeTransposerGui.text = "Alterando o transpositor "..unit.name
- changeTransposerGui[changeTransposerName].text = unit.name
- local reverse = {}
- local function updateList(refresh)
- ---@type string[]
- local list = {}
- reverse = {}
- for side, chest in pairs(unit:getInputs()) do
- for k, grid in pairs(chest.grids) do
- local label = grid.amount.."x"..grid.product
- table.insert(list, label)
- table.insert(reverse, {grid=grid, chest=chest, index=k})
- end
- end
- changeTransposerGui[changeTransposerList].entries = list
- if refresh then
- gui.displayWidget(changeTransposerGui, changeTransposerList)
- end
- end
- updateList()
- changeTransposerGui[changeTransposerAdd].func = function(...)
- mainGui[block.btn_learn].func(...)
- updateList(true)
- end
- changeTransposerGui[changeTransposerModify].func = function()
- local selection = gui.getSelected(changeTransposerGui, changeTransposerList)
- if not selection then
- gui.showError("", "Nenhuma receita selecionada", true)
- return
- end
- selection = reverse[selection]
- ---@type autocompressor.grid
- local grid = selection.grid
- addPatternGui.text = "|Modificando a Receita "..grid.product.."|"
- -- "[ Adicionar ]"
- addPatternGui[addPatternAdd].text = "[ Modificar ]"
- for k, index in pairs(addPatternGridFrames) do
- local item = grid.matrix[k]
- if item then
- addPatternGui[index].text = " "
- addPatternGui[addPatternModify[k]].text = tostring(item.amount)
- addPatternGui[addPatternModify[k]].visible = true
- addPatternGui[addPatternGrid[k]].text = item.name
- else
- addPatternGui[index].text = nil
- addPatternGui[addPatternModify[k]].visible = false
- addPatternGui[addPatternGrid[k]].text = ""
- end
- end
- addPatternGui[addPatternProductName].text = grid.product
- addPatternGui[addPatternAmount].text = tostring(grid.amount)
- addPatternGui[addPatternAdd].func = function ()
- local name = addPatternGui[addPatternProductName].text
- local amount = tonumber(addPatternGui[addPatternAmount].text)
- if validateProductName(name, amount) then
- return
- end
- local oldName = grid.product
- grid.product = name
- grid.amount = tonumber(amount)
- for k, index in pairs(addPatternModify) do
- local value = tonumber(addPatternGui[index].text)
- local item = grid.matrix[k]
- if item then
- item.amount = value
- end
- end
- save()
- gui.showMsg("A receita de ", oldName, "foi alterada com sucesso.")
- addPatternRendering = false
- end
- addPatternRendering = true
- gui.displayGui(addPatternGui)
- while addPatternRendering do
- gui.runGui(addPatternGui)
- end
- gui.closeGui(addPatternGui)
- updateList(true)
- end
- changeTransposerGui[changeTransposerName].func = function(frame,widget,value)
- value = tostring(value)
- if value:len() < 3 then
- gui.showMsg("O nome não foi alterado", "porque ele precisa ter",
- "no mínimo 3 letras")
- frame[widget].text = unit.name
- else
- unit.name = value
- save()
- local transposer = window.transposers[unit.address]
- if transposer then
- mainGui[transposer.frame].text = value
- end
- end
- end
- changeTransposerGui[changeTransposerRemove].func = function()
- local selection = gui.getSelected(changeTransposerGui, changeTransposerList)
- if not selection then
- gui.showError("", "Nenhuma receita selecionada", true)
- return
- end
- selection = reverse[selection]
- ---@type autocompressor.grid
- local grid = selection.grid
- ---@type autocompressor.chest
- local chest = selection.chest
- if gui.getYesNo("Você está prestes a remover a receita", grid.product, "Tem certeza?") then
- table.remove(chest.grids, selection.index)
- save()
- gui.showMsg("Você removeu a receita de", grid.product, "com sucesso")
- updateList(true)
- return
- end
- end
- gui.displayGui(changeTransposerGui)
- changeTransposerRunning = true
- while changeTransposerRunning do
- gui.runGui(changeTransposerGui)
- end
- end)
- block.btn_del = gui.newButton(mainGui, frameX + 14, frameY + 1, "Del", function(guiID, buttonID)
- if gui.getYesNo("Você tem certeza que quer apagar", "o transpositor "..unit.name.."?", "") then
- unities[unit.address] = nil
- save()
- window.recreateGui()
- end
- end)
- block.lbl_status = gui.newLabel(mainGui, frameX + 1, frameY + 3, "Esperando...", 0xc0c0c0, 0x0)
- block.lbl_processing = {
- gui.newLabel(mainGui, frameX + 1, frameY + 4, "", 0xc0c0c0, 0xffffff),
- gui.newLabel(mainGui, frameX + 1, frameY + 5, "", 0xc0c0c0, 0xffffff),
- gui.newLabel(mainGui, frameX + 1, frameY + 6, "", 0xc0c0c0, 0xffffff),
- gui.newLabel(mainGui, frameX + 1, frameY + 7, "", 0xc0c0c0, 0xffffff),
- gui.newLabel(mainGui, frameX + 1, frameY + 8, "", 0xc0c0c0, 0xffffff),
- }
- function block.update()
- mainGui[block.frame].text = unit.name:sub(1,12)
- local status = unit.status
- local success, compressors = pcall(function () return unit:getCompressors() end)
- if not success then
- status = "Offline"
- compressors = {}
- elseif status == "init" then
- status = "Online"
- end
- local tbl = mainGui[block.lbl_status]
- tbl.text = string.format("%-16s", status)
- gui.displayWidget(mainGui, block.lbl_status)
- local len = crafting_unit.tablelength(compressors)
- for i = len + 1, 5 do
- mainGui[block.lbl_processing[i]].text = ""
- gui.displayWidget(mainGui, block.lbl_processing[i])
- end
- local i = 0
- for k, compressor in pairs(compressors) do
- i = i + 1
- if i >= 5 then break end
- status = compressor.status
- if status == "waiting" then
- status = "Disponível"
- end
- block.setProcessingLabel(i, status)
- end
- end
- function block.setProcessingLabel(index, text)
- mainGui[block.lbl_processing[index]].text = text:sub(1, 18)
- gui.displayWidget(mainGui, block.lbl_processing[index])
- end
- window.transposers[unit.address] = block
- return block
- end
- ---@param window autocompressor.gui.main.window
- function window.createInsertionBlock(line, column)
- line = line or window.lin
- column = column or window.col
- local mainGui = window.mainGui
- local frameX = (column - 1) * 20
- local frameY = 1 + (line - 1) * 10
- local block = {}
- block.frame = gui.newFrame(mainGui, frameX, frameY, 20, 10, "Criar Novo")
- block.lbl_err = gui.newMultiLineLabel(mainGui, frameX + 1, frameY + 2, 18, 5, "Nenhum transpositor novo que seja válido foi encontrado", nil, 0xAA0000)
- local unused = {}
- local inserted = {}
- --block.lbl_name = gui.newLabel(mainGui, frameX+2, frameY+7, "[ Nome: ", 0x0000FF, 0xFFFFFF)
- --block.txt_name = gui.newText(mainGui, frameX+9, frameY+7, 10, "")
- --block.lbl_name2 = gui.newLabel(mainGui, frameX+19, frameY+7, "]", 0x0000FF, 0xFFFFFF)
- local function isValid(addr)
- ---@type component.transposer
- local proxy = component.proxy(addr)
- if not proxy then
- return false
- end
- local hasCompressor = false
- local hasInv = false
- for i, v in ipairs(sides) do
- local n = sides[v]
- local size = proxy.getInventorySize(n)
- if size == 12 or size == 11 or size == 7 then
- hasCompressor = true
- elseif size ~= nil then
- hasInv = true
- end
- if hasCompressor and hasInv then
- return true
- end
- end
- return false
- end
- block.create = gui.newButton(mainGui, frameX+1, frameY+8, " Registrar Novo ", function ()
- local selected = mainGui[block.list].selected
- local short = unused[selected]
- local addr = component.get(short, "transposer")
- if not addr then
- beep()
- for k, v in pairs(inserted) do
- if v == short then
- addr = k
- break
- end
- end
- if not addr then addr = short end
- gui.showError("O transpositor não é válido!", addr, "Ele não está conectado ao computador", true)
- elseif not isValid(addr) then
- beep()
- gui.showError("O transpositor não é válido!", addr, "Ele não tem uma prensa ou um baú", true)
- else
- nameGui[nameLabel2].text = addr
- nameGui[nameText].text = ""
- nameRendering = true
- nameGui[nameAdd].func = function()
- local name = nameGui[nameText].text
- if unicode.len(name) < 3 then
- gui.showError("O nome digitado é muito pequeno",name,"Digite um nome com mais de 3 letras", true)
- elseif unicode.len(name) > 12 then
- gui.showError("O nome digitado é muito grande",name,"Digite um nome com até 12 letras", true)
- else
- --gui.showError("Não implementado","","", true)
- nameRendering = false
- gui.closeGui(nameGui)
- if not isValid(addr) then
- gui.showError("O transpositor não é válido!", addr, "Ele foi invalidado ao ser adicionado")
- else
- local unit = crafting_unit.wrap(addr, name)
- unities[addr] = unit
- save()
- mainGui[block.lbl_err].visible = false
- mainGui[block.list].visible = false
- mainGui[block.create].visible = false
- mainGui[block.frame].visible = false
- window.createTransposerBlock(line, column, unit)
- if window.nextBlock() then
- window.createInsertionBlock()
- end
- end
- end
- end
- gui.displayGui(nameGui)
- while nameRendering do
- gui.runGui(nameGui)
- end
- end
- end)
- local possible = component.list("transposer")
- local lastPossible
- local lastUnusedIndex
- function block.findUnused()
- local index = next(unused, lastUnusedIndex)
- if not index then
- lastUnusedIndex = nil
- else
- local fullAddr = component.get(unused[index], "transposer")
- if not fullAddr or window.transposers[fullAddr] or not isValid(fullAddr) then
- for addr, short in pairs(inserted) do
- if short == unused[index] then
- inserted[addr] = nil
- break
- end
- end
- table.remove(unused, index)
- else
- lastUnusedIndex = index
- end
- end
- local success, addr = pcall(next, possible, lastPossible)
- if not addr then
- lastPossible = nil
- possible = component.list("transposer")
- else
- lastPossible = addr
- local online = component.get(addr, "transposer")
- if online and not inserted[addr] and not window.transposers[addr] and isValid(addr) then
- local short = addr:sub(1,17)
- inserted[addr] = short
- table.insert(unused, short)
- end
- end
- return unused
- end
- block.list = gui.newList(mainGui, frameX + 1, frameY + 1, 18, 7, unused, function ()
- end, "Transpositor")
- function block.setListVisible(visible)
- mainGui[block.list].visible = visible
- --mainGui[block.lbl_name].visible = visible
- --mainGui[block.lbl_name2].visible = visible
- --mainGui[block.txt_name].visible = visible
- mainGui[block.create].visible = visible
- mainGui[block.lbl_err].visible = not visible
- end
- function block.renderList()
- if mainGui[block.list].visible then
- gui.displayWidget(mainGui, block.list)
- --gui.displayWidget(mainGui, block.lbl_name)
- --gui.displayWidget(mainGui, block.lbl_name2)
- --gui.displayWidget(mainGui, block.txt_name)
- gui.displayWidget(mainGui, block.create)
- else
- gui.displayGui(mainGui)
- end
- end
- function block.update()
- block.findUnused()
- mainGui[block.list].entries = unused
- block.setListVisible(next(unused) ~= nil)
- block.renderList()
- end
- window.insertionBlock = block
- return block
- end
- function window.recreateGui()
- recreateGui()
- for addr, unit in pairs(unities) do
- if window.nextBlock() then
- window.createTransposerBlock(window.lin, window.col, unit)
- end
- end
- if window.nextBlock() then
- window.createInsertionBlock()
- end
- end
- window.recreateGui()
- return window
- end
- ---@return autocompressor.save.unit[]
- local function exportData()
- local data = {}
- for addr, unit in pairs(unities) do
- ---@class autocompressor.save.unit
- ---@field inputs autocompressor.save.input[]
- local unitData = {addr=addr, name=unit.name, inputs={}}
- table.insert(data, unitData)
- for side, chest in pairs(unit:getInputs()) do
- ---@class autocompressor.save.input
- ---@field grids autocompressor.save.grid[]
- local inputData = {side=side, grids={}}
- table.insert(unitData.inputs, inputData)
- for k, grid in pairs(chest.grids) do
- ---@class autocompressor.save.grid
- ---@field matrix table<number, autocompressor.save.item>
- local gridData = {product=grid.product, amount=grid.amount, matrix={}}
- table.insert(inputData.grids, gridData)
- for slot, item in pairs(grid.matrix) do
- ---@class autocompressor.save.item
- local itemData = {id=item.id,metadata=item.metadata,amount=item.amount,name=item.name}
- gridData.matrix[slot] = itemData
- end
- end
- end
- end
- return data
- end
- ---@param save autocompressor.save.unit[]
- ---@return autocompressor.crafting_unit[]
- local function importData(save)
- local loaded = {}
- for i, unitData in ipairs(save) do
- local unit = crafting_unit.wrap(unitData.addr, unitData.name)
- loaded[unitData.addr] = unit
- local chests = unit:getInputs()
- for i, inputData in ipairs(unitData.inputs) do
- local chest = chests[inputData.side]
- for i, gridData in ipairs(inputData.grids) do
- local fakeStacks = {}
- for slot, item in pairs(gridData.matrix) do
- ---@type _item_stack
- local stack = {name=item.id,size=item.amount,label=item.name,damage=item.metadata,hasTag=false}
- fakeStacks[slot] = stack
- end
- chest:createGrid(fakeStacks, gridData.product, gridData.amount)
- end
- end
- end
- return loaded
- end
- save = function ()
- local data = serialization.serialize(exportData())
- fs.makeDirectory("/var")
- local file = io.open("/var/autocompressor.save", "w")
- file:write(data)
- file:close()
- end
- local function load()
- if fs.exists("/var/autocompressor.save") then
- local file = io.open("/var/autocompressor.save", "r")
- local data = file:read("*all")
- file:close()
- unities = importData(serialization.unserialize(data))
- end
- end
- -- End: Menu definitions
- load()
- local window = createWindow()
- gui.clearScreen()
- gui.setTop("Automação da Prensa")
- gui.setBottom("Criado por youtube.com/ProgramandoMinecraft")
- gui.displayGui(window.mainGui)
- local updateInsertion = true
- local service = coroutine.create(function ()
- while true do
- checkTime("Service Loop", function ()
- for addr, unit in pairs(unities) do
- for k, chest in pairs(unit:getInputs()) do
- checkTime("scanPatterns", chest.scanPatterns, chest)
- coroutine.yield()
- --checkTime("processDelayedMoves", chest.processDelayedMoves, chest)
- end
- for k, compressor in pairs(unit:getCompressors()) do
- checkTime("updateStatus", compressor.updateStatus, compressor)
- coroutine.yield()
- end
- end
- end )
- coroutine.yield()
- end
- end)
- local p
- local update = coroutine.create(function ()
- while true do
- --[[
- local s, i, v = pcall(next, window.transposers, p)
- if not s or i == nil then
- p = nil
- else
- if p == nil then
- p = 1
- else
- p = p + 1
- end
- v.update()
- --require("computer").beep()
- end
- coroutine.yield()
- ]]--
- for addr, transposer in pairs(window.transposers) do
- transposer.update()
- coroutine.yield()
- end
- end
- end)
- --[[
- thread.create(function ()
- while true do
- checkTime("Service Loop", function ()
- for addr, unit in pairs(unities) do
- for k, chest in pairs(unit:getInputs()) do
- checkTime("scanPatterns", chest.scanPatterns, chest)
- checkTime("processDelayedMoves", chest.processDelayedMoves, chest)
- end
- for k, compressor in pairs(unit:getCompressors()) do
- checkTime("updateStatus", compressor.updateStatus, compressor)
- end
- end
- end )
- end
- end)
- ]]--
- -- Main loop
- while true do
- gui.runGui(window.mainGui)
- if updateInsertion then
- updateInsertion = false
- --require("computer").beep()
- window.insertionBlock.update()
- event.timer(3, function () updateInsertion = true end, 1)
- end
- coroutine.resume(service)
- coroutine.resume(update)
- end
Add Comment
Please, Sign In to add comment