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 bayAddress = {}
- bayAddress["bay1"] = "b054e612-782f-4b87-b965-7403e09804b4"
- bayAddress["bay2"] = "d1cf5b64-7539-49a3-97b7-cb7616d7cf56"
- bayAddress["bay3"] = "4572ca9f-caea-43c8-8be0-ebf57243fdf1"
- bayAddress["bay4"] = "c269358e-6813-425e-a30d-f697081fe023"
- bayAddress["bay5"] = "4aeb8950-cb90-4047-815c-c10ace86dda3"
- bayAddress["bay6"] = "f7b476d7-91df-4d87-8677-8890d462c6eb"
- bayAddress["bay7"] = "532b737f-eb9d-47e3-b15e-ed53ecc52086"
- bayAddress["bay8"] = "e7e394f2-c738-4bb6-9694-06c4ead46a99"
- bayAddress["bay9"] = "e64b2384-76ba-466e-a1c1-912dc52269f2"
- bayAddress["bay10"] = "3f66dedb-8526-455b-a016-2fc2baab733a"
- bayAddress["bay11"] = "7a61ba9f-9122-4afc-a0d2-4825b75c1257"
- bayAddress["bay12"] = "d899fc7b-7f22-439f-ac8d-09657b36fb68"
- bayAddress["bay13"] = "9df8025a-3bdf-4015-8d35-834560a82915"
- bayAddress["bay14"] = "543dd1e3-c229-4df3-81be-03f0078a2cf6"
- bayAddress["bay15"] = "f6b954df-71d3-48c7-a5e7-10cc7915eab8"
- --bayAddress["bay16"] = "" -- Extra bay
- bayAddress["bay17"] = "9f522dbf-1d10-4b9d-834e-0058f653de22" --Big bay at end(ghast)
- bayAddress["bay18"] = "6a8d6e32-20b8-4724-88be-286d8fc00939" --Wither bay
- -- defninitions
- local rsbay1 = component.proxy(bayAddress["bay1"])
- local rsbay2 = component.proxy(bayAddress["bay2"])
- local rsbay3 = component.proxy(bayAddress["bay3"])
- local rsbay4 = component.proxy(bayAddress["bay4"])
- local rsbay5 = component.proxy(bayAddress["bay5"])
- local rsbay6 = component.proxy(bayAddress["bay6"])
- local rsbay7 = component.proxy(bayAddress["bay7"])
- local rsbay8 = component.proxy(bayAddress["bay8"])
- local rsbay9 = component.proxy(bayAddress["bay9"])
- local rsbay10 = component.proxy(bayAddress["bay10"])
- local rsbay11 = component.proxy(bayAddress["bay11"])
- local rsbay12 = component.proxy(bayAddress["bay12"])
- local rsbay13 = component.proxy(bayAddress["bay13"])
- local rsbay14 = component.proxy(bayAddress["bay14"])
- local rsbay15 = component.proxy(bayAddress["bay15"])
- --local rsbay16 = component.proxy(bayAddress["bay16"])
- local rsbay17 = component.proxy(bayAddress["bay17"])
- local rsbay18 = component.proxy(bayAddress["bay18"])
- local sections = {}
- -- 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= 22, title = " RIGHT "}
- sections["right"] = { x = 70, y = 3, width = 60, height = 22, title = " LEFT "}
- sections["all"] = { x = 4, y = 27, width = 60, height = 10, title = " ALL "}
- sections["other"] = { x = 70, y = 27, width = 60, height = 10, title = " OTHER "}
- end
- function setButtons()
- API.setTable("bay1", bay1, 9, 5, 31, 8, "Zombie", {on = colors.red, off = colors.green})
- API.setTable("bay2", bay2, 9, 10, 31, 13, "Skeleton", {on = colors.red, off = colors.green})
- API.setTable("bay3", bay3, 9, 15, 31, 18, "Enderman", {on = colors.red, off = colors.green})
- API.setTable("bay4", bay4, 9, 20, 31, 23, "Wither Skeleton", {on = colors.red, off = colors.green})
- API.setTable("bay5", bay5, 36, 5, 58, 8, "Blaze", {on = colors.red, off = colors.green})
- API.setTable("bay6", bay6, 36, 10, 58, 13, "Blizz", {on = colors.red, off = colors.green})
- API.setTable("bay7", bay7, 36, 15, 58, 18, "Basalz", {on = colors.red, off = colors.green})
- API.setTable("bay8", bay8, 36, 20, 58, 23, "Blitz", {on = colors.red, off = colors.green})
- API.setTable("bay9", bay9, 75, 5, 96, 8, "Cow", {on = colors.red, off = colors.green})
- API.setTable("bay10", bay10, 75, 10, 96, 13, "Sheep", {on = colors.red, off = colors.green})
- API.setTable("bay11", bay11, 75, 15, 96, 18, "Squid", {on = colors.red, off = colors.green})
- API.setTable("bay12", bay12, 75, 20, 96, 23, "Spider", {on = colors.red, off = colors.green})
- API.setTable("bay13", bay13, 102, 5, 123, 8, "Slime", {on = colors.red, off = colors.green})
- API.setTable("bay14", bay14, 102, 10, 123, 13, "Magma", {on = colors.red, off = colors.green})
- API.setTable("bay15", bay15, 102, 15, 123, 18, "bay15", {on = colors.red, off = colors.green})
- API.setTable("bay16", bay16, 102, 20, 123, 23, "Bay 16", {on = colors.red, off = colors.green})
- API.setTable("allOn", allOn, 9, 30, 31, 34, "ALL ON", {on = colors.green, off= colors.green})
- API.setTable("allOff", allOff, 36, 30, 58, 34, "ALL OFF", {on = colors.red, off= colors.red})
- API.setTable("bay17", bay17, 75, 30, 96, 34, "Ghast", {on = colors.red, off= colors.green})
- API.setTable("bay18", bay18, 102, 30, 123, 34, "Wither", {on = colors.purple, off= colors.blue})
- 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 allOff()
- API.flash("allOff", 0.15)
- for name, data in pairs(bayAddress) do
- local rsbay = component.proxy(bayAddress[name])
- rsbay.setOutput(side.top, 15)
- if API.getState(name) == true then
- API.toggleButton(name)
- end
- end
- rsbay18.setOutput(side.top, 0)
- rsbay18.setOutput(side.west, 15)
- rsbay18.setOutput(side.north, 0)
- end
- function allOn()
- API.flash("allOn", 0.15)
- for name, data in pairs(bayAddress) do
- local rsbay = component.proxy(bayAddress[name])
- rsbay.setOutput(side.top, 0)
- if API.getState(name) == false then
- API.toggleButton(name)
- end
- end
- end
- function bay1()
- API.toggleButton("bay1")
- if API.getState("bay1") == true then
- rsbay1.setOutput(side.top, 0)
- else
- rsbay1.setOutput(side.top, 15)
- end
- end
- function bay2()
- API.toggleButton("bay2")
- if API.getState("bay2") == true then
- rsbay2.setOutput(side.top, 0)
- else
- rsbay2.setOutput(side.top, 15)
- end
- end
- function bay3()
- API.toggleButton("bay3")
- if API.getState("bay3") == true then
- rsbay3.setOutput(side.top, 0)
- else
- rsbay3.setOutput(side.top, 15)
- end
- end
- function bay4()
- API.toggleButton("bay4")
- if API.getState("bay4") == true then
- rsbay4.setOutput(side.top, 0)
- else
- rsbay4.setOutput(side.top, 15)
- end
- end
- function bay5()
- API.toggleButton("bay5")
- if API.getState("bay5") == true then
- rsbay5.setOutput(side.top, 0)
- else
- rsbay5.setOutput(side.top, 15)
- end
- end
- function bay6()
- API.toggleButton("bay6")
- if API.getState("bay6") == true then
- rsbay6.setOutput(side.top, 0)
- else
- rsbay6.setOutput(side.top, 15)
- end
- end
- function bay7()
- API.toggleButton("bay7")
- if API.getState("bay7") == true then
- rsbay7.setOutput(side.top, 0)
- else
- rsbay7.setOutput(side.top, 15)
- end
- end
- function bay8()
- API.toggleButton("bay8")
- if API.getState("bay8") == true then
- rsbay8.setOutput(side.top, 0)
- else
- rsbay8.setOutput(side.top, 15)
- end
- end
- function bay9()
- API.toggleButton("bay9")
- if API.getState("bay9") == true then
- rsbay9.setOutput(side.top, 0)
- else
- rsbay9.setOutput(side.top, 15)
- end
- end
- function bay10()
- API.toggleButton("bay10")
- if API.getState("bay10") == true then
- rsbay10.setOutput(side.top, 0)
- else
- rsbay10.setOutput(side.top, 15)
- end
- end
- function bay11()
- API.toggleButton("bay11")
- if API.getState("bay11") == true then
- rsbay11.setOutput(side.top, 0)
- else
- rsbay11.setOutput(side.top, 15)
- end
- end
- function bay12()
- API.toggleButton("bay12")
- if API.getState("bay12") == true then
- rsbay12.setOutput(side.top, 0)
- else
- rsbay12.setOutput(side.top, 15)
- end
- end
- function bay13()
- API.toggleButton("bay13")
- if API.getState("bay13") == true then
- rsbay13.setOutput(side.top, 0)
- else
- rsbay13.setOutput(side.top, 15)
- end
- end
- function bay14()
- API.toggleButton("bay14")
- if API.getState("bay14") == true then
- rsbay14.setOutput(side.top, 0)
- else
- rsbay14.setOutput(side.top, 15)
- end
- end
- function bay15()
- API.toggleButton("bay15")
- if API.getState("bay15") == true then
- rsbay15.setOutput(side.top, 0)
- else
- rsbay15.setOutput(side.top, 15)
- end
- end
- function bay16()
- API.toggleButton("bay16")
- if API.getState("bay16") == true then
- --rsbay16.setOutput(side.top, 0)
- else
- --rsbay16.setOutput(side.top, 15)
- end
- end
- function bay17()
- API.toggleButton("bay17")
- if API.getState("bay17") == true then
- rsbay17.setOutput(side.top, 0)
- else
- rsbay17.setOutput(side.top, 15)
- end
- end
- function bay18()
- API.toggleButton("bay18")
- if API.getState("bay18") == true then
- rsbay18.setOutput(side.west, 0)
- rsbay18.setOutput(side.north, 15)
- else
- rsbay18.setOutput(side.west, 15)
- rsbay18.setOutput(side.north, 0)
- 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
- allOff()
- end
- -- starting
- startup()
- while true do
- getClick()
- end
Add Comment
Please, Sign In to add comment