Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- API = require("buttonAPI")
- local component = require("component")
- local computer = require("computer")
- local term = require("term")
- local event = require("event")
- local side = require("sides")
- local gpu = component.gpu
- local colors = { blue = 0x4286F4, purple = 0xB673d6, red = 0xC14141, green = 0xDA841,
- black = 0x000000, white = 0xFFFFFF, grey = 0x47494C, lightGrey = 0xBBBBBB}
- -- set size of the screen for lvl 3
- gpu.setResolution(132,38)
- gpu.setBackground(colors.black)
- gpu.fill(1, 1, 132, 38, " ")
- -- Redstone IO addresses
- local configAddress = {}
- configAddress["oreMiner"] = "63a338c9-443f-43f9-8c10-33d920d8c511"
- configAddress["oreMiner2"] = "2b11e636-b5b0-4835-8f98-364d49235498"
- configAddress["resourceMiner"] = "34322d7a-01fa-4097-b067-3db2b1c179e0"
- configAddress["botanicMiner"] = "b7742cd6-7620-474a-b2ba-da710f6c73dc"
- configAddress["stone"] = "d39fae60-e7b5-4c4f-8952-4dc45e36bf37"
- configAddress["sand"] = "228d6623-7996-4637-9019-cf8eb797946c"
- configAddress["glass"] = "30f09a8b-e09b-455f-937c-ba275905b91f"
- configAddress["TBD"] = ""
- -- defninitions
- local sections = {}
- local rsToggle1 = component.proxy(configAddress["oreMiner"])
- local rsToggle2 = component.proxy(configAddress["oreMiner2"])
- local rsToggle3 = component.proxy(configAddress["resourceMiner"])
- local rsToggle4 = component.proxy(configAddress["botanicMiner"])
- local rsToggle5 = component.proxy(configAddress["stone"])
- local rsToggle6 = component.proxy(configAddress["sand"])
- local rsToggle7 = component.proxy(configAddress["glass"])
- local rsToggle8 = component.proxy(configAddress["TBD"])
- -- functions
- function clearTxt()
- gpu.setBackground(colors.black)
- gpu.fill(1, 1, 25, 1, " ")
- end
- function setSections()
- sections["left"] = { x = 4, y = 3, width = 60, height= 12, title = " MOB FARM(WIP) "}
- sections["right"] = { x = 70, y = 3, width = 60, height = 22, title = " RESOURCES "}
- sections["bottom-left"] = { x = 4, y = 17, width = 60, height = 20, title = " SECURITY "}
- sections["bottom-right"] = { x = 70, y = 27, width = 60, height = 10, title = " OTHER "}
- end
- function setButtons()
- API.setTable("mob1", mobAllOn, 9, 5, 31, 8, "ALL ON", {on = colors.green, off = colors.blue})
- API.setTable("mob2", mobAllOff, 9, 10, 31, 13, "ALL OFF", {on = colors.red, off = colors.blue})
- API.setTable("mob3", mobNormal, 36, 5, 58, 8, "Normal Op", {on = colors.red, off = colors.green})
- API.setTable("mob4", mobWither, 36, 10, 58, 13, "Wither", {on = colors.purple, off = colors.blue})
- API.setTable("resource1", oreMiner, 75, 5, 96, 8, "Ore Miner", {on = colors.red, off = colors.green})
- API.setTable("resource2", oreMiner2, 75, 10, 96, 13, "Ore Miner 2", {on = colors.red, off = colors.green})
- API.setTable("resource3", resourceMiner, 75, 15, 96, 18, "Resource Miner", {on = colors.red, off = colors.green})
- API.setTable("resource4", botanicMiner, 75, 20, 96, 23, "Botanic Miner", {on = colors.red, off = colors.green})
- API.setTable("resource5", stoneGen, 102, 5, 123, 8, "Stone Generator", {on = colors.red, off = colors.green})
- API.setTable("resource6", sandGen, 102, 10, 123, 13, "Sand Generator", {on = colors.red, off = colors.green})
- API.setTable("resource7", glassGen, 102, 15, 123, 18, "Glass Generator", {on = colors.red, off = colors.green})
- API.setTable("resource8", TBD, 102, 20, 123, 23, "TBD", {on = colors.red, off = colors.green})
- end
- function printBorders(sectionName)
- local s = sections[sectionName]
- -- set border
- gpu.setBackground(colors.grey)
- gpu.fill(s.x, s.y, s.width, 1, " ")
- gpu.fill(s.x, s.y, 1, s.height, " ")
- gpu.fill(s.x, s.y + s.height, s.width, 1, " ")
- gpu.fill(s.x + s.width, s.y, 1, s.height + 1, " ")
- -- set title
- gpu.setBackground(colors.black)
- gpu.set(s.x + 2, s.y, s.title)
- end
- function getMobStatus(name)
- --Code for getting status form mob control computer
- end
- function updateButtons()
- if ((getMobStatus("bay16") == true and API.getState("mob4") == false) or (getMobStatus("bay16") == false and API.getState("mob4") == true)) then
- API.toggleButton("mob4")
- end
- end
- function mobAllOn()
- API.flash("mob1", 0.15)
- --Send signal here
- end
- function mobAllOff()
- API.flash("mob2", 0.15)
- --Send signal here
- end
- function mobNormal()
- API.toggleButton("mob3")
- if API.getState("mob3") == true then
- --Send on signal
- else
- --Send off signal
- end
- end
- function mobWither()
- API.toggleButton("mob4")
- if API.getState("mob4") == true then
- --Send on signal
- else
- --Send off signal
- end
- end
- function oreMiner()
- API.toggleButton("resource1")
- if API.getState("resource1") == true then
- rsToggle1.setOutput(side.top, 0)
- else
- rsToggle1.setOutput(side.top, 15)
- end
- end
- function oreMiner2()
- API.toggleButton("resource2")
- if API.getState("resource2") == true then
- rsToggle2.setOutput(side.top, 0)
- else
- rsToggle2.setOutput(side.top, 15)
- end
- end
- function resourceMiner()
- API.toggleButton("resource3")
- if API.getState("resource3") == true then
- rsToggle3.setOutput(side.top, 0)
- else
- rsToggle3.setOutput(side.top, 15)
- end
- end
- function botanicMiner()
- API.toggleButton("resource4")
- if API.getState("resource4") == true then
- rsToggle4.setOutput(side.top, 0)
- else
- rsToggle4.setOutput(side.top, 15)
- end
- end
- function stoneGen()
- API.toggleButton("resource5")
- if API.getState("resource5") == true then
- rsToggle5.setOutput(side.south, 15)
- else
- rsToggle5.setOutput(side.south, 0)
- end
- end
- function sandGen()
- API.toggleButton("resource6")
- if API.getState("resource6") == true then
- rsToggle6.setOutput(side.south, 15)
- else
- rsToggle6.setOutput(side.south, 0)
- end
- end
- function glassGen()
- API.toggleButton("resource7")
- if API.getState("resource7") == true then
- rsToggle7.setOutput(side.south, 15)
- else
- rsToggle7.setOutput(side.south, 0)
- end
- end
- function TBD()
- API.toggleButton("resource8")
- if API.getState("resource8") == true then
- rsToggle8.setOutput(side.top, 15)
- else
- rsToggle8.setOutput(side.top, 0)
- end
- end
- function updateResources()
- if ((rsToggle1.getOutput(side.top) == 0 and API.getState("resource1") == false) or (rsToggle1.getOutput(side.top) == 15 and API.getState("resource1") == true)) then
- API.toggleButton("resource1")
- end
- if ((rsToggle2.getOutput(side.top) == 0 and API.getState("resource2") == false) or (rsToggle2.getOutput(side.top) == 15 and API.getState("resource2") == true)) then
- API.toggleButton("resource2")
- end
- if ((rsToggle3.getOutput(side.top) == 0 and API.getState("resource3") == false) or (rsToggle3.getOutput(side.top) == 15 and API.getState("resource3") == true)) then
- API.toggleButton("resource3")
- end
- if ((rsToggle4.getOutput(side.top) == 0 and API.getState("resource4") == false) or (rsToggle4.getOutput(side.top) == 15 and API.getState("resource4") == true)) then
- API.toggleButton("resource4")
- end
- if ((rsToggle5.getOutput(side.south) == 15 and API.getState("resource5") == false) or (rsToggle5.getOutput(side.south) == 0 and API.getState("resource5") == true)) then
- API.toggleButton("resource5")
- end
- if ((rsToggle6.getOutput(side.south) == 15 and API.getState("resource6") == false) or (rsToggle6.getOutput(side.south) == 0 and API.getState("resource6") == true)) then
- API.toggleButton("resource6")
- end
- if ((rsToggle7.getOutput(side.south) == 15 and API.getState("resource7") == false) or (rsToggle7.getOutput(side.south) == 0 and API.getState("resource7") == true)) then
- API.toggleButton("resource7")
- end
- end
- function getClick()
- local _, _, x, y = event.pull(1,touch)
- if x == nil or y == nil then
- local h, w = gpu.getResolution()
- gpu.set(h, w, ".")
- gpu.set(h, w, " ")
- else
- API.checkxy(_,_,x,y,_,_)
- end
- end
- function startup()
- term.setCursorBlink(false)
- setSections()
- setButtons()
- API.screen()
- API.heading("Mob Spawner Control Panel")
- for name, data in pairs(sections) do
- printBorders(name)
- end
- updateResources()
- end
- -- starting
- startup()
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement