--Programm made by Mrswisstobi-redo 51-- local button = {} local side = "back" local mon = peripheral.wrap("top") local textScale = 1 ------------ color variables ------------ local btnTextColor = colors.white local defaultBgColor = colors.black local headerColor = colors.white ----------------------------------------- function turnAllOff() rs.setBundledOutput(side, 0) for name, data in pairs(button) do data["active"] = false if name == "All OFF" then button[name]["active"] = true end mon.clear() heading("Turn Spawners on/off:") screen() end end function turnAllOn() rs.setBundledOutput(side, 65535) for name, data in pairs(button) do data["active"] = true if name == "All ON" then button[name]["active"] = false end mon.clear() heading("Turn Spawners on/off:") screen() end end rs.setBundledOutput(side, 65535) term.clear() term.setCursorPos(1,1) mon.setBackgroundColor(defaultBgColor) mon.setTextScale(textScale) mon.clear() function fillTable() setTable("Enderman", switchOutput, 17, 27, 3, 5, colors.white, colors.lime, colors.red) setTable("Wither", switchOutput, 17, 27, 7, 9, colors.orange, colors.lime, colors.red) setTable("ZombiePig", switchOutput, 17, 27, 11, 13, colors.magenta, colors.lime, colors.red) setTable("Witch", switchOutput, 17, 27, 15, 17, colors.lightBlue, colors.lime, colors.red) setTable("AngryZ", switchOutput, 31, 41, 3, 5, colors.yellow, colors.lime, colors.red) setTable("Creeper", switchOutput, 31, 41, 7, 9, colors.lime, colors.lime, colors.red) setTable("Cow", switchOutput, 31, 41, 11, 13, colors.pink, colors.lime, colors.red) setTable("Sheep", switchOutput, 31, 41, 15, 17, colors.gray, colors.lime, colors.red) setTable("Ghast", switchOutput, 45, 55, 3, 5, colors.lightGray, colors.lime, colors.red) setTable("WSkull", switchOutput, 45, 55, 7, 9, colors.cyan, colors.lime, colors.red) setTable("Slime", switchOutput, 45, 55, 11, 13, colors.purple, colors.lime, colors.red) setTable("free", switchOutput, 45, 55, 15, 17, colors.blue, colors.lime, colors.red) setTable("free", switchOutput, 59, 69, 3, 5, colors.brown, colors.lime, colors.red) setTable("free", switchOutput, 59, 69, 7, 9, colors.green, colors.lime, colors.red) setTable("free", switchOutput, 59, 69, 11, 13, colors.red, colors.lime, colors.red) setTable("free", switchOutput, 59, 69, 15, 17, colors.black, colors.lime, colors.red) setTable("All OFF", turnAllOn, 3, 13, 3, 9, "" , colors.magenta, colors.red) setTable("All ON", turnAllOff, 3, 13, 11, 17, "" , colors.magenta, colors.lime) end function setTable(name, func, xmin, xmax, ymin, ymax, color, btnOff, btnOn) button[name] = {} button[name]["func"] = func button[name]["active"] = false button[name]["xmin"] = xmin button[name]["ymin"] = ymin button[name]["xmax"] = xmax button[name]["ymax"] = ymax button[name]["color"] = color button[name]["btnOn"] = btnOn button[name]["btnOff"] = btnOff end function switchOutput(color) if rs.testBundledInput(side, color) then rs.setBundledOutput(side, (rs.getBundledInput(side)-color)) else rs.setBundledOutput(side, (rs.getBundledInput(side)+color)) end end function fill(text, color, bData) mon.setBackgroundColor(color) mon.setTextColor(btnTextColor) local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2) local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1 for j = bData["ymin"], bData["ymax"] do mon.setCursorPos(bData["xmin"], j) if j == yspot then for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do if k == xspot then mon.write(text) else mon.write(" ") end end else for i = bData["xmin"], bData["xmax"] do mon.write(" ") end end end mon.setBackgroundColor(defaultBgColor) end function screen() local currColor for name,data in pairs(button) do local on = data["active"] if on == true then currColor = data["btnOn"] else currColor = data["btnOff"] end fill(name, currColor, data) end end function checkxy(x, y) for name, data in pairs(button) do if y>=data["ymin"] and y <= data["ymax"] then if x>=data["xmin"] and x<= data["xmax"] then data["func"](button[name]["color"]) data["active"] = not data["active"] end end end end function heading(text) w, h = mon.getSize() mon.setTextColor(headerColor) mon.setCursorPos((w-string.len(text))/2+1, 1) mon.write(text) end fillTable() while true do mon.clear() heading("Turn Spawners On/Off:") screen() local e,side,x,y = os.pullEvent("monitor_touch") checkxy(x,y) sleep(.1) end