SHOW:
|
|
- or go back to the newest paste.
| 1 | - | --Programm made by Mrswisstobi-redo 51- april 2017 |
| 1 | + | --Programm made by Mrswisstobi-redo 51-- |
| 2 | ||
| 3 | local button = {}
| |
| 4 | local side = "back" | |
| 5 | local mon = peripheral.wrap("top")
| |
| 6 | - | local textScale = 1.2 |
| 6 | + | local textScale = 1 |
| 7 | ||
| 8 | ------------ color variables ------------ | |
| 9 | ||
| 10 | local btnTextColor = colors.white | |
| 11 | local defaultBgColor = colors.black | |
| 12 | local headerColor = colors.white | |
| 13 | ||
| 14 | ----------------------------------------- | |
| 15 | function turnAllOff() | |
| 16 | rs.setBundledOutput(side, 0) | |
| 17 | for name, data in pairs(button) do | |
| 18 | data["active"] = false | |
| 19 | if name == "All OFF" then | |
| 20 | button[name]["active"] = true | |
| 21 | end | |
| 22 | mon.clear() | |
| 23 | - | heading("Spawners Controles on/off:")
|
| 23 | + | heading("Turn Spawners on/off:")
|
| 24 | screen() | |
| 25 | end | |
| 26 | end | |
| 27 | ||
| 28 | function turnAllOn() | |
| 29 | rs.setBundledOutput(side, 65535) | |
| 30 | for name, data in pairs(button) do | |
| 31 | data["active"] = true | |
| 32 | if name == "All ON" then | |
| 33 | button[name]["active"] = false | |
| 34 | end | |
| 35 | mon.clear() | |
| 36 | - | heading("Spawners Controles on/off:")
|
| 36 | + | heading("Turn Spawners on/off:")
|
| 37 | screen() | |
| 38 | end | |
| 39 | end | |
| 40 | ||
| 41 | rs.setBundledOutput(side, 65535) | |
| 42 | term.clear() | |
| 43 | term.setCursorPos(1,1) | |
| 44 | mon.setBackgroundColor(defaultBgColor) | |
| 45 | mon.setTextScale(textScale) | |
| 46 | mon.clear() | |
| 47 | ||
| 48 | function fillTable() | |
| 49 | - | setTable("free01", switchOutput, 3, 13, 3, 5, colors.white, colors.red, colors.lime)
|
| 49 | + | setTable("Enderman", switchOutput, 17, 27, 3, 5, colors.white, colors.lime, colors.red)
|
| 50 | - | setTable("free02", switchOutput, 3, 13, 7, 9, colors.orange, colors.red, colors.lime)
|
| 50 | + | setTable("Wither", switchOutput, 17, 27, 7, 9, colors.orange, colors.lime, colors.red)
|
| 51 | - | setTable("free03", switchOutput, 3, 13, 11, 13, colors.magenta, colors.red, colors.lime)
|
| 51 | + | setTable("ZombiePig", switchOutput, 17, 27, 11, 13, colors.magenta, colors.lime, colors.red)
|
| 52 | - | setTable("free04", switchOutput, 3, 13, 15, 17, colors.lightBlue, colors.red, colors.lime)
|
| 52 | + | setTable("Witch", switchOutput, 17, 27, 15, 17, colors.lightBlue, colors.lime, colors.red)
|
| 53 | - | setTable("free05", switchOutput, 17, 27, 3, 5, colors.yellow, colors.red, colors.lime)
|
| 53 | + | setTable("AngryZ", switchOutput, 31, 41, 3, 5, colors.yellow, colors.lime, colors.red)
|
| 54 | - | setTable("free06", switchOutput, 17, 27, 7, 9, colors.lime, colors.red, colors.lime)
|
| 54 | + | setTable("Creeper", switchOutput, 31, 41, 7, 9, colors.lime, colors.lime, colors.red)
|
| 55 | - | setTable("free07", switchOutput, 17, 27, 11, 13, colors.pink, colors.red, colors.lime)
|
| 55 | + | setTable("Cow", switchOutput, 31, 41, 11, 13, colors.pink, colors.lime, colors.red)
|
| 56 | - | setTable("free08", switchOutput, 17, 27, 15, 17, colors.gray, colors.red, colors.lime)
|
| 56 | + | setTable("Sheep", switchOutput, 31, 41, 15, 17, colors.gray, colors.lime, colors.red)
|
| 57 | - | setTable("free09", switchOutput, 45, 55, 3, 5, colors.lightGray, colors.red, colors.lime)
|
| 57 | + | setTable("Ghast", switchOutput, 45, 55, 3, 5, colors.lightGray, colors.lime, colors.red)
|
| 58 | - | setTable("free10", switchOutput, 45, 55, 7, 9, colors.cyan, colors.red, colors.lime)
|
| 58 | + | setTable("WSkull", switchOutput, 45, 55, 7, 9, colors.cyan, colors.lime, colors.red)
|
| 59 | - | setTable("free11", switchOutput, 45, 55, 11, 13, colors.purple, colors.red, colors.lime)
|
| 59 | + | setTable("Slime", switchOutput, 45, 55, 11, 13, colors.purple, colors.lime, colors.red)
|
| 60 | - | setTable("free12", switchOutput, 45, 55, 15, 17, colors.blue, colors.red, colors.lime)
|
| 60 | + | setTable("free", switchOutput, 45, 55, 15, 17, colors.blue, colors.lime, colors.red)
|
| 61 | - | setTable("free13", switchOutput, 59, 69, 3, 5, colors.brown, colors.red, colors.lime)
|
| 61 | + | setTable("free", switchOutput, 59, 69, 3, 5, colors.brown, colors.lime, colors.red)
|
| 62 | - | setTable("free14", switchOutput, 59, 69, 7, 9, colors.green, colors.red, colors.lime)
|
| 62 | + | setTable("free", switchOutput, 59, 69, 7, 9, colors.green, colors.lime, colors.red)
|
| 63 | - | setTable("free15", switchOutput, 59, 69, 11, 13, colors.red, colors.red, colors.lime)
|
| 63 | + | setTable("free", switchOutput, 59, 69, 11, 13, colors.red, colors.lime, colors.red)
|
| 64 | - | setTable("free16", switchOutput, 59, 69, 15, 17, colors.black, colors.red, colors.lime)
|
| 64 | + | setTable("free", switchOutput, 59, 69, 15, 17, colors.black, colors.lime, colors.red)
|
| 65 | - | setTable("All OFF", turnAllOn, 31, 41, 3, 9, "" , colors.blue, colors.red)
|
| 65 | + | setTable("All OFF", turnAllOn, 3, 13, 3, 9, "" , colors.magenta, colors.red)
|
| 66 | - | setTable("All ON", turnAllOff, 31, 41, 11, 17, "" , colors.blue, colors.lime)
|
| 66 | + | setTable("All ON", turnAllOff, 3, 13, 11, 17, "" , colors.magenta, colors.lime)
|
| 67 | end | |
| 68 | ||
| 69 | function setTable(name, func, xmin, xmax, ymin, ymax, color, btnOff, btnOn) | |
| 70 | button[name] = {}
| |
| 71 | button[name]["func"] = func | |
| 72 | button[name]["active"] = false | |
| 73 | button[name]["xmin"] = xmin | |
| 74 | button[name]["ymin"] = ymin | |
| 75 | button[name]["xmax"] = xmax | |
| 76 | button[name]["ymax"] = ymax | |
| 77 | button[name]["color"] = color | |
| 78 | button[name]["btnOn"] = btnOn | |
| 79 | button[name]["btnOff"] = btnOff | |
| 80 | end | |
| 81 | ||
| 82 | function switchOutput(color) | |
| 83 | if rs.testBundledInput(side, color) then | |
| 84 | rs.setBundledOutput(side, (rs.getBundledInput(side)-color)) | |
| 85 | else | |
| 86 | rs.setBundledOutput(side, (rs.getBundledInput(side)+color)) | |
| 87 | end | |
| 88 | end | |
| 89 | ||
| 90 | function fill(text, color, bData) | |
| 91 | mon.setBackgroundColor(color) | |
| 92 | mon.setTextColor(btnTextColor) | |
| 93 | local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2) | |
| 94 | local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1 | |
| 95 | for j = bData["ymin"], bData["ymax"] do | |
| 96 | mon.setCursorPos(bData["xmin"], j) | |
| 97 | if j == yspot then | |
| 98 | for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do | |
| 99 | if k == xspot then | |
| 100 | mon.write(text) | |
| 101 | else | |
| 102 | mon.write(" ")
| |
| 103 | end | |
| 104 | end | |
| 105 | else | |
| 106 | for i = bData["xmin"], bData["xmax"] do | |
| 107 | mon.write(" ")
| |
| 108 | end | |
| 109 | end | |
| 110 | end | |
| 111 | mon.setBackgroundColor(defaultBgColor) | |
| 112 | end | |
| 113 | ||
| 114 | function screen() | |
| 115 | local currColor | |
| 116 | for name,data in pairs(button) do | |
| 117 | local on = data["active"] | |
| 118 | if on == true then currColor = data["btnOn"] else currColor = data["btnOff"] end | |
| 119 | fill(name, currColor, data) | |
| 120 | end | |
| 121 | end | |
| 122 | ||
| 123 | function checkxy(x, y) | |
| 124 | for name, data in pairs(button) do | |
| 125 | if y>=data["ymin"] and y <= data["ymax"] then | |
| 126 | if x>=data["xmin"] and x<= data["xmax"] then | |
| 127 | data["func"](button[name]["color"]) | |
| 128 | data["active"] = not data["active"] | |
| 129 | end | |
| 130 | end | |
| 131 | end | |
| 132 | end | |
| 133 | ||
| 134 | function heading(text) | |
| 135 | w, h = mon.getSize() | |
| 136 | mon.setTextColor(headerColor) | |
| 137 | mon.setCursorPos((w-string.len(text))/2+1, 1) | |
| 138 | mon.write(text) | |
| 139 | end | |
| 140 | ||
| 141 | fillTable() | |
| 142 | while true do | |
| 143 | mon.clear() | |
| 144 | - | heading("Spawners Controles On/Off:")
|
| 144 | + | heading("Turn Spawners On/Off:")
|
| 145 | screen() | |
| 146 | local e,side,x,y = os.pullEvent("monitor_touch")
| |
| 147 | checkxy(x,y) | |
| 148 | sleep(.1) | |
| 149 | end |