SHOW:
|
|
- or go back to the newest paste.
| 1 | - | --Programm made by Mrswisstobi - redo 51ing - april 2017 |
| 1 | + | --Programm made by Mrswisstobi-redo 51- april 2017 adapted by dezindzer lol |
| 2 | ||
| 3 | local button = {}
| |
| 4 | - | local side = "back" -- where your BUNDLED CABLE is |
| 4 | + | local side = "bottom" |
| 5 | - | local mon = peripheral.wrap("bottom") -- where your monitor is
|
| 5 | + | local mon = peripheral.wrap("back")
|
| 6 | local textScale = 1.2 | |
| 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"] = true | |
| 19 | if name == "All OFF" then | |
| 20 | button[name]["active"] = false | |
| 21 | end | |
| 22 | mon.clear() | |
| 23 | heading("Spawners Controles 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"] = false | |
| 32 | if name == "All ON" then | |
| 33 | button[name]["active"] = true | |
| 34 | end | |
| 35 | mon.clear() | |
| 36 | heading("Spawners Controles 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("Yoyo 1", switchOutput, 3, 13, 3, 5, colors.red, colors.red, colors.lime)
|
| 50 | - | setTable("free02", switchOutput, 3, 13, 7, 9, colors.orange, colors.red, colors.lime)
|
| 50 | + | setTable("Yoyo 2", switchOutput, 3, 13, 7, 9, colors.blue, colors.red, colors.lime)
|
| 51 | - | setTable("free03", switchOutput, 3, 13, 11, 13, colors.magenta, colors.red, colors.lime)
|
| 51 | + | setTable("Yoyo 3", switchOutput, 17, 27, 3, 5, colors.yellow, colors.red, colors.lime)
|
| 52 | - | setTable("free04", switchOutput, 3, 13, 15, 17, colors.lightBlue, colors.red, colors.lime)
|
| 52 | + | setTable("Yoyo 4", switchOutput, 17, 27, 7, 9, colors.orange, colors.red, colors.lime)
|
| 53 | - | setTable("free05", switchOutput, 17, 27, 3, 5, colors.yellow, colors.red, colors.lime)
|
| 53 | + | |
| 54 | - | setTable("free06", switchOutput, 17, 27, 7, 9, colors.lime, colors.red, colors.lime)
|
| 54 | + | setTable("All OFF", turnAllOn, 3, 13, 11, 17, "" , colors.blue, colors.red)
|
| 55 | - | setTable("free07", switchOutput, 17, 27, 11, 13, colors.pink, colors.red, colors.lime)
|
| 55 | + | setTable("All ON", turnAllOff, 17, 27, 11, 17, "" , colors.blue, colors.lime)
|
| 56 | - | setTable("free08", switchOutput, 17, 27, 15, 17, colors.gray, colors.red, colors.lime)
|
| 56 | + | |
| 57 | - | setTable("free09", switchOutput, 45, 55, 3, 5, colors.lightGray, colors.red, colors.lime)
|
| 57 | + | |
| 58 | - | setTable("free10", switchOutput, 45, 55, 7, 9, colors.cyan, colors.red, colors.lime)
|
| 58 | + | |
| 59 | - | setTable("free11", switchOutput, 45, 55, 11, 13, colors.purple, colors.red, colors.lime)
|
| 59 | + | |
| 60 | - | setTable("free12", switchOutput, 45, 55, 15, 17, colors.blue, colors.red, colors.lime)
|
| 60 | + | |
| 61 | - | setTable("free13", switchOutput, 59, 69, 3, 5, colors.brown, colors.red, colors.lime)
|
| 61 | + | |
| 62 | - | setTable("free14", switchOutput, 59, 69, 7, 9, colors.green, colors.red, colors.lime)
|
| 62 | + | |
| 63 | - | setTable("free15", switchOutput, 59, 69, 11, 13, colors.red, colors.red, colors.lime)
|
| 63 | + | |
| 64 | - | setTable("free16", switchOutput, 59, 69, 15, 17, colors.black, colors.red, colors.lime)
|
| 64 | + | |
| 65 | - | setTable("All OFF", turnAllOn, 31, 41, 3, 9, "" , colors.blue, colors.red)
|
| 65 | + | |
| 66 | - | setTable("All ON", turnAllOff, 31, 41, 11, 17, "" , colors.blue, colors.lime)
|
| 66 | + | |
| 67 | button[name]["color"] = color | |
| 68 | button[name]["btnOn"] = btnOn | |
| 69 | button[name]["btnOff"] = btnOff | |
| 70 | end | |
| 71 | ||
| 72 | function switchOutput(color) | |
| 73 | if rs.testBundledInput(side, color) then | |
| 74 | rs.setBundledOutput(side, (rs.getBundledInput(side)-color)) | |
| 75 | else | |
| 76 | rs.setBundledOutput(side, (rs.getBundledInput(side)+color)) | |
| 77 | end | |
| 78 | end | |
| 79 | ||
| 80 | function fill(text, color, bData) | |
| 81 | mon.setBackgroundColor(color) | |
| 82 | mon.setTextColor(btnTextColor) | |
| 83 | local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2) | |
| 84 | local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1 | |
| 85 | for j = bData["ymin"], bData["ymax"] do | |
| 86 | mon.setCursorPos(bData["xmin"], j) | |
| 87 | if j == yspot then | |
| 88 | for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do | |
| 89 | if k == xspot then | |
| 90 | mon.write(text) | |
| 91 | else | |
| 92 | mon.write(" ")
| |
| 93 | end | |
| 94 | end | |
| 95 | else | |
| 96 | for i = bData["xmin"], bData["xmax"] do | |
| 97 | mon.write(" ")
| |
| 98 | end | |
| 99 | end | |
| 100 | end | |
| 101 | mon.setBackgroundColor(defaultBgColor) | |
| 102 | end | |
| 103 | ||
| 104 | function screen() | |
| 105 | local currColor | |
| 106 | for name,data in pairs(button) do | |
| 107 | local on = data["active"] | |
| 108 | if on == true then currColor = data["btnOn"] else currColor = data["btnOff"] end | |
| 109 | fill(name, currColor, data) | |
| 110 | end | |
| 111 | end | |
| 112 | ||
| 113 | function checkxy(x, y) | |
| 114 | for name, data in pairs(button) do | |
| 115 | if y>=data["ymin"] and y <= data["ymax"] then | |
| 116 | if x>=data["xmin"] and x<= data["xmax"] then | |
| 117 | data["func"](button[name]["color"]) | |
| 118 | data["active"] = not data["active"] | |
| 119 | end | |
| 120 | end | |
| 121 | end | |
| 122 | end | |
| 123 | ||
| 124 | function heading(text) | |
| 125 | w, h = mon.getSize() | |
| 126 | mon.setTextColor(headerColor) | |
| 127 | mon.setCursorPos((w-string.len(text))/2+1, 1) | |
| 128 | mon.write(text) | |
| 129 | end | |
| 130 | ||
| 131 | fillTable() | |
| 132 | while true do | |
| 133 | mon.clear() | |
| 134 | heading("Spawners Controles On/Off:")
| |
| 135 | screen() | |
| 136 | local e,side,x,y = os.pullEvent("monitor_touch")
| |
| 137 | checkxy(x,y) | |
| 138 | sleep(.1) | |
| 139 | end |