quantumr8

MobControlPanel

Feb 25th, 2021 (edited)
279
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. API = require("buttonAPI")
  2. local component = require("component")
  3. local computer = require("computer")
  4. local term = require("term")
  5. local event = require("event")
  6. local side = require("sides")
  7. local gpu = component.gpu
  8.  
  9.  
  10.  
  11.  
  12. local colors = { blue = 0x4286F4, purple = 0xB673d6, red = 0xC14141, green = 0xDA841,
  13. black = 0x000000, white = 0xFFFFFF, grey = 0x47494C, lightGrey = 0xBBBBBB}
  14.  
  15. -- set size of the screen for lvl 3
  16. gpu.setResolution(132,38)
  17. gpu.setBackground(colors.black)
  18. gpu.fill(1, 1, 132, 38, " ")
  19.  
  20.  
  21. -- Redstone IO addresses
  22.  
  23. local bayAddress = {}
  24. bayAddress["bay1"] = "b054e612-782f-4b87-b965-7403e09804b4"
  25. bayAddress["bay2"] = "d1cf5b64-7539-49a3-97b7-cb7616d7cf56"
  26. bayAddress["bay3"] = "4572ca9f-caea-43c8-8be0-ebf57243fdf1"
  27. bayAddress["bay4"] = "c269358e-6813-425e-a30d-f697081fe023"
  28. bayAddress["bay5"] = "4aeb8950-cb90-4047-815c-c10ace86dda3"
  29. bayAddress["bay6"] = "f7b476d7-91df-4d87-8677-8890d462c6eb"
  30. bayAddress["bay7"] = "532b737f-eb9d-47e3-b15e-ed53ecc52086"
  31. bayAddress["bay8"] = "e7e394f2-c738-4bb6-9694-06c4ead46a99"
  32. bayAddress["bay9"] = "e64b2384-76ba-466e-a1c1-912dc52269f2"
  33. bayAddress["bay10"] = "3f66dedb-8526-455b-a016-2fc2baab733a"
  34. bayAddress["bay11"] = "7a61ba9f-9122-4afc-a0d2-4825b75c1257"
  35. bayAddress["bay12"] = "d899fc7b-7f22-439f-ac8d-09657b36fb68"
  36. bayAddress["bay13"] = "9df8025a-3bdf-4015-8d35-834560a82915"
  37. bayAddress["bay14"] = "543dd1e3-c229-4df3-81be-03f0078a2cf6"
  38. bayAddress["bay15"] = "f6b954df-71d3-48c7-a5e7-10cc7915eab8"
  39. --bayAddress["bay16"] = "" -- Extra bay
  40. bayAddress["bay17"] = "9f522dbf-1d10-4b9d-834e-0058f653de22" --Big bay at end(ghast)
  41. bayAddress["bay18"] = "6a8d6e32-20b8-4724-88be-286d8fc00939" --Wither bay
  42.  
  43. -- defninitions
  44.  
  45. local rsbay1 = component.proxy(bayAddress["bay1"])
  46. local rsbay2 = component.proxy(bayAddress["bay2"])
  47. local rsbay3 = component.proxy(bayAddress["bay3"])
  48. local rsbay4 = component.proxy(bayAddress["bay4"])
  49. local rsbay5 = component.proxy(bayAddress["bay5"])
  50. local rsbay6 = component.proxy(bayAddress["bay6"])
  51. local rsbay7 = component.proxy(bayAddress["bay7"])
  52. local rsbay8 = component.proxy(bayAddress["bay8"])
  53. local rsbay9 = component.proxy(bayAddress["bay9"])
  54. local rsbay10 = component.proxy(bayAddress["bay10"])
  55. local rsbay11 = component.proxy(bayAddress["bay11"])
  56. local rsbay12 = component.proxy(bayAddress["bay12"])
  57. local rsbay13 = component.proxy(bayAddress["bay13"])
  58. local rsbay14 = component.proxy(bayAddress["bay14"])
  59. local rsbay15 = component.proxy(bayAddress["bay15"])
  60. --local rsbay16 = component.proxy(bayAddress["bay16"])
  61. local rsbay17 = component.proxy(bayAddress["bay17"])
  62. local rsbay18 = component.proxy(bayAddress["bay18"])
  63.  
  64. local sections = {}
  65.  
  66.  
  67. -- functions
  68.  
  69. function clearTxt()
  70.  
  71.   gpu.setBackground(colors.black)
  72.   gpu.fill(1, 1, 25, 1, " ")
  73.  
  74. end
  75.  
  76.  
  77. function setSections()
  78.  
  79.   sections["left"] = { x = 4, y = 3, width = 60, height= 22, title = "  RIGHT  "}
  80.   sections["right"] = { x = 70, y = 3, width = 60, height = 22, title = "  LEFT  "}
  81.   sections["all"] = { x = 4, y = 27, width = 60, height = 10, title = "  ALL  "}
  82.   sections["other"] = { x = 70, y = 27, width = 60, height = 10, title = "  OTHER  "}
  83.  
  84. end
  85.  
  86.  
  87. function setButtons()
  88.  
  89.   API.setTable("bay1", bay1, 9, 5, 31, 8, "Zombie", {on = colors.red, off = colors.green})
  90.   API.setTable("bay2", bay2, 9, 10, 31, 13, "Skeleton", {on = colors.red, off = colors.green})
  91.   API.setTable("bay3", bay3, 9, 15, 31, 18, "Enderman", {on = colors.red, off = colors.green})
  92.   API.setTable("bay4", bay4, 9, 20, 31, 23, "Wither Skeleton", {on = colors.red, off = colors.green})
  93.  
  94.   API.setTable("bay5", bay5, 36, 5, 58, 8, "Blaze", {on = colors.red, off = colors.green})
  95.   API.setTable("bay6", bay6, 36, 10, 58, 13, "Blizz", {on = colors.red, off = colors.green})
  96.   API.setTable("bay7", bay7, 36, 15, 58, 18, "Basalz", {on = colors.red, off = colors.green})
  97.   API.setTable("bay8", bay8, 36, 20, 58, 23, "Blitz", {on = colors.red, off = colors.green})
  98.  
  99.   API.setTable("bay9", bay9, 75, 5, 96, 8, "Cow", {on = colors.red, off = colors.green})
  100.   API.setTable("bay10", bay10, 75, 10, 96, 13, "Sheep", {on = colors.red, off = colors.green})
  101.   API.setTable("bay11", bay11, 75, 15, 96, 18, "Squid", {on = colors.red, off = colors.green})
  102.   API.setTable("bay12", bay12, 75, 20, 96, 23, "Spider", {on = colors.red, off = colors.green})
  103.  
  104.   API.setTable("bay13", bay13, 102, 5, 123, 8, "Slime", {on = colors.red, off = colors.green})
  105.   API.setTable("bay14", bay14, 102, 10, 123, 13, "Magma", {on = colors.red, off = colors.green})
  106.   API.setTable("bay15", bay15, 102, 15, 123, 18, "bay15", {on = colors.red, off = colors.green})
  107.   API.setTable("bay16", bay16, 102, 20, 123, 23, "Bay 16", {on = colors.red, off = colors.green})
  108.  
  109.   API.setTable("allOn", allOn, 9, 30, 31, 34, "ALL ON", {on = colors.green, off= colors.green})
  110.   API.setTable("allOff", allOff, 36, 30, 58, 34, "ALL OFF", {on = colors.red, off= colors.red})
  111.  
  112.   API.setTable("bay17", bay17, 75, 30, 96, 34, "Ghast", {on = colors.red, off= colors.green})
  113.   API.setTable("bay18", bay18, 102, 30, 123, 34, "Wither", {on = colors.purple, off= colors.blue})
  114.  
  115.  
  116. end
  117.  
  118.  
  119. function printBorders(sectionName)
  120.  
  121.   local s = sections[sectionName]
  122.   -- set border
  123.   gpu.setBackground(colors.grey)
  124.   gpu.fill(s.x, s.y, s.width, 1, " ")
  125.   gpu.fill(s.x, s.y, 1, s.height, " ")
  126.   gpu.fill(s.x, s.y + s.height, s.width, 1, " ")
  127.   gpu.fill(s.x + s.width, s.y, 1, s.height + 1, " ")
  128.   -- set title
  129.   gpu.setBackground(colors.black)
  130.   gpu.set(s.x + 2, s.y, s.title)
  131.  
  132. end
  133.  
  134.  
  135. function allOff()
  136.  
  137.   API.flash("allOff", 0.15)
  138.   for name, data in pairs(bayAddress) do
  139.  
  140.     local rsbay = component.proxy(bayAddress[name])
  141.     rsbay.setOutput(side.top, 15)
  142.     if API.getState(name) == true then
  143.  
  144.       API.toggleButton(name)
  145.  
  146.     end
  147.  
  148.   end
  149.   rsbay18.setOutput(side.top, 0)
  150.   rsbay18.setOutput(side.west, 15)
  151.   rsbay18.setOutput(side.north, 0)
  152.  
  153. end
  154.  
  155.  
  156. function allOn()
  157.  
  158.   API.flash("allOn", 0.15)
  159.   for name, data in pairs(bayAddress) do
  160.  
  161.     local rsbay = component.proxy(bayAddress[name])
  162.     rsbay.setOutput(side.top, 0)
  163.     if API.getState(name) == false then
  164.  
  165.       API.toggleButton(name)
  166.  
  167.     end
  168.  
  169.   end
  170.  
  171. end
  172.  
  173.  
  174. function bay1()
  175.  
  176.   API.toggleButton("bay1")
  177.   if API.getState("bay1") == true then
  178.  
  179.     rsbay1.setOutput(side.top, 0)
  180.  
  181.   else
  182.  
  183.     rsbay1.setOutput(side.top, 15)
  184.  
  185.   end
  186.  
  187. end
  188.  
  189.  
  190. function bay2()
  191.  
  192.   API.toggleButton("bay2")
  193.   if API.getState("bay2") == true then
  194.  
  195.     rsbay2.setOutput(side.top, 0)
  196.  
  197.   else
  198.  
  199.     rsbay2.setOutput(side.top, 15)
  200.  
  201.   end
  202.  
  203. end
  204.  
  205.  
  206. function bay3()
  207.  
  208.   API.toggleButton("bay3")
  209.   if API.getState("bay3") == true then
  210.  
  211.     rsbay3.setOutput(side.top, 0)
  212.  
  213.   else
  214.  
  215.     rsbay3.setOutput(side.top, 15)
  216.  
  217.   end
  218.  
  219. end
  220.  
  221.  
  222. function bay4()
  223.  
  224.   API.toggleButton("bay4")
  225.   if API.getState("bay4") == true then
  226.  
  227.     rsbay4.setOutput(side.top, 0)
  228.  
  229.   else
  230.  
  231.     rsbay4.setOutput(side.top, 15)
  232.  
  233.   end
  234.  
  235. end
  236.  
  237.  
  238. function bay5()
  239.  
  240.   API.toggleButton("bay5")
  241.   if API.getState("bay5") == true then
  242.  
  243.     rsbay5.setOutput(side.top, 0)
  244.  
  245.   else
  246.  
  247.     rsbay5.setOutput(side.top, 15)
  248.  
  249.   end
  250.  
  251. end
  252.  
  253. function bay6()
  254.  
  255.   API.toggleButton("bay6")
  256.   if API.getState("bay6") == true then
  257.  
  258.     rsbay6.setOutput(side.top, 0)
  259.  
  260.   else
  261.  
  262.     rsbay6.setOutput(side.top, 15)
  263.  
  264.   end
  265.  
  266. end
  267.  
  268.  
  269. function bay7()
  270.  
  271.   API.toggleButton("bay7")
  272.   if API.getState("bay7") == true then
  273.  
  274.     rsbay7.setOutput(side.top, 0)
  275.  
  276.   else
  277.  
  278.     rsbay7.setOutput(side.top, 15)
  279.  
  280.   end
  281.  
  282. end
  283.  
  284.  
  285. function bay8()
  286.  
  287.   API.toggleButton("bay8")
  288.   if API.getState("bay8") == true then
  289.  
  290.     rsbay8.setOutput(side.top, 0)
  291.  
  292.   else
  293.  
  294.     rsbay8.setOutput(side.top, 15)
  295.  
  296.   end
  297.  
  298. end
  299.  
  300.  
  301. function bay9()
  302.  
  303.   API.toggleButton("bay9")
  304.   if API.getState("bay9") == true then
  305.  
  306.     rsbay9.setOutput(side.top, 0)
  307.  
  308.   else
  309.  
  310.     rsbay9.setOutput(side.top, 15)
  311.  
  312.   end
  313.  
  314. end
  315.  
  316.  
  317. function bay10()
  318.  
  319.   API.toggleButton("bay10")
  320.   if API.getState("bay10") == true then
  321.  
  322.     rsbay10.setOutput(side.top, 0)
  323.  
  324.   else
  325.  
  326.     rsbay10.setOutput(side.top, 15)
  327.  
  328.   end
  329.  
  330. end
  331.  
  332.  
  333. function bay11()
  334.  
  335.   API.toggleButton("bay11")
  336.   if API.getState("bay11") == true then
  337.  
  338.     rsbay11.setOutput(side.top, 0)
  339.  
  340.   else
  341.  
  342.     rsbay11.setOutput(side.top, 15)
  343.  
  344.   end
  345.  
  346. end
  347.  
  348.  
  349. function bay12()
  350.  
  351.   API.toggleButton("bay12")
  352.   if API.getState("bay12") == true then
  353.  
  354.     rsbay12.setOutput(side.top, 0)
  355.  
  356.   else
  357.  
  358.     rsbay12.setOutput(side.top, 15)
  359.  
  360.   end
  361.  
  362. end
  363.  
  364.  
  365. function bay13()
  366.  
  367.   API.toggleButton("bay13")
  368.   if API.getState("bay13") == true then
  369.  
  370.     rsbay13.setOutput(side.top, 0)
  371.  
  372.   else
  373.  
  374.     rsbay13.setOutput(side.top, 15)
  375.  
  376.   end
  377.  
  378. end
  379.  
  380.  
  381. function bay14()
  382.  
  383.   API.toggleButton("bay14")
  384.   if API.getState("bay14") == true then
  385.  
  386.     rsbay14.setOutput(side.top, 0)
  387.  
  388.   else
  389.  
  390.     rsbay14.setOutput(side.top, 15)
  391.  
  392.   end
  393.  
  394. end
  395.  
  396.  
  397. function bay15()
  398.  
  399.   API.toggleButton("bay15")
  400.   if API.getState("bay15") == true then
  401.  
  402.     rsbay15.setOutput(side.top, 0)
  403.  
  404.   else
  405.  
  406.     rsbay15.setOutput(side.top, 15)
  407.  
  408.   end
  409.  
  410. end
  411.  
  412.  
  413. function bay16()
  414.  
  415.     API.toggleButton("bay16")
  416.     if API.getState("bay16") == true then
  417.  
  418.       --rsbay16.setOutput(side.top, 0)
  419.  
  420.     else
  421.  
  422.       --rsbay16.setOutput(side.top, 15)
  423.    
  424.     end
  425.  
  426. end
  427.  
  428.  
  429. function bay17()
  430.  
  431.     API.toggleButton("bay17")
  432.     if API.getState("bay17") == true then
  433.  
  434.       rsbay17.setOutput(side.top, 0)
  435.  
  436.     else
  437.  
  438.       rsbay17.setOutput(side.top, 15)
  439.    
  440.     end
  441.  
  442. end
  443.  
  444.  
  445. function bay18()
  446.  
  447.   API.toggleButton("bay18")
  448.   if API.getState("bay18") == true then
  449.  
  450.     rsbay18.setOutput(side.west, 0)
  451.     rsbay18.setOutput(side.north, 15)
  452.  
  453.   else
  454.  
  455.     rsbay18.setOutput(side.west, 15)
  456.     rsbay18.setOutput(side.north, 0)
  457.  
  458.   end
  459.  
  460. end
  461.  
  462.  
  463. function getClick()
  464.  
  465.   local _, _, x, y = event.pull(1,touch)
  466.   if x == nil or y == nil then
  467.  
  468.     local h, w = gpu.getResolution()
  469.     gpu.set(h, w, ".")
  470.     gpu.set(h, w, " ")
  471.  
  472.   else
  473.  
  474.     API.checkxy(_,_,x,y,_,_)
  475.  
  476.   end
  477.  
  478. end
  479.  
  480.  
  481. function startup()
  482.  
  483.   term.setCursorBlink(false)
  484.   setSections()
  485.   setButtons()
  486.   API.screen()
  487.   API.heading("Mob Spawner Control Panel")
  488.   for name, data in pairs(sections) do
  489.    
  490.     printBorders(name)
  491.    
  492.   end
  493.   allOff()
  494.  
  495. end
  496.  
  497.  
  498. -- starting
  499.  
  500. startup()
  501.  
  502. while true do
  503.   getClick()
  504. end
RAW Paste Data