Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Programm made by Mrswisstobi-redo 51- april 2017 adapted by dezindzer lol
- local button = {}
- local side = "bottom"
- local mon = peripheral.wrap("back")
- local textScale = 1.2
- ------------ 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"] = true
- if name == "All OFF" then
- button[name]["active"] = false
- end
- mon.clear()
- heading("Spawners Controles on/off:")
- screen()
- end
- end
- function turnAllOn()
- rs.setBundledOutput(side, 65535)
- for name, data in pairs(button) do
- data["active"] = false
- if name == "All ON" then
- button[name]["active"] = true
- end
- mon.clear()
- heading("Spawners Controles 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("Yoyo 1", switchOutput, 3, 13, 3, 5, colors.red, colors.red, colors.lime)
- setTable("Yoyo 2", switchOutput, 3, 13, 7, 9, colors.blue, colors.red, colors.lime)
- setTable("Yoyo 3", switchOutput, 17, 27, 3, 5, colors.yellow, colors.red, colors.lime)
- setTable("Yoyo 4", switchOutput, 17, 27, 7, 9, colors.orange, colors.red, colors.lime)
- setTable("All OFF", turnAllOn, 3, 13, 11, 17, "" , colors.blue, colors.red)
- setTable("All ON", turnAllOff, 17, 27, 11, 17, "" , colors.blue, 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("Spawners Controles On/Off:")
- screen()
- local e,side,x,y = os.pullEvent("monitor_touch")
- checkxy(x,y)
- sleep(.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement