SHOW:
|
|
- or go back to the newest paste.
| 1 | os.loadAPI("bundleAPI") -- api by andrakon of badash games
| |
| 2 | local mon = peripheral.wrap("top") -- enables the monitor
| |
| 3 | mon.setTextScale(.5) | |
| 4 | mon.setTextColor(colors.white) | |
| 5 | local button = {}
| |
| 6 | mon.setBackgroundColor(colors.black) | |
| 7 | ||
| 8 | function setTable(name, func, xmin, xmax, ymin, ymax) | |
| 9 | button[name] = {}
| |
| 10 | button[name]["func"] = func | |
| 11 | button[name]["active"] = false | |
| 12 | button[name]["xmin"] = xmin | |
| 13 | button[name]["xmax"] = xmax | |
| 14 | button[name]["ymin"] = ymin | |
| 15 | button[name]["ymax"] = ymax | |
| 16 | end | |
| 17 | ||
| 18 | - | function bColor() |
| 18 | + | |
| 19 | - | local bColor |
| 19 | + | bundleAPI.on("bottom", "red")
|
| 20 | - | local on = data["active"] |
| 20 | + | |
| 21 | - | if on == true then bColor = colors.lime |
| 21 | + | |
| 22 | - | else bColor = colors.red |
| 22 | + | |
| 23 | bundleAPI.on("bottom", "orange")
| |
| 24 | end | |
| 25 | ||
| 26 | - | if bColor() = colors.lime then |
| 26 | + | |
| 27 | - | bundleAPI.on("bottom", "red")
|
| 27 | + | |
| 28 | - | else |
| 28 | + | |
| 29 | - | bundleAPI.off("bottom", "red")
|
| 29 | + | |
| 30 | function fillTable() | |
| 31 | setTable("Reactors", reactor, 5, 20, 4, 8)
| |
| 32 | setTable("Breeder", breeder, 5, 20, 10, 14)
| |
| 33 | setTable("ALL STOP", stop, 5, 20, 16, 20)
| |
| 34 | - | if bColor() = colors.lime then |
| 34 | + | |
| 35 | - | bundleAPI.on("bottom", "orange")
|
| 35 | + | |
| 36 | - | else |
| 36 | + | |
| 37 | - | bundleAPI.off("bottom", "orange")
|
| 37 | + | |
| 38 | local yspot = math.floor((bData["ymin"] + bData["ymax"]) /2) | |
| 39 | local xspot = math.floor((bData["xmax"] - bData["xmin"] - string.len(text)) /2) +1 | |
| 40 | for j = bData["ymin"], bData["ymax"] do | |
| 41 | mon.setCursorPos(bData["xmin"], j) | |
| 42 | if j == yspot then | |
| 43 | for k = 0, bData["xmax"] - bData["xmin"] - string.len(text) +1 do | |
| 44 | if k == xspot then | |
| 45 | mon.write(text) | |
| 46 | else | |
| 47 | mon.write(" ")
| |
| 48 | end | |
| 49 | end | |
| 50 | else | |
| 51 | for i = bData["xmin"], bData["xmax"] do | |
| 52 | mon.write(" ")
| |
| 53 | end | |
| 54 | end | |
| 55 | end | |
| 56 | mon.setBackgroundColor(colors.black) | |
| 57 | end | |
| 58 | ||
| 59 | function screen() | |
| 60 | local currColor | |
| 61 | for name,data in pairs(button) do | |
| 62 | local on = data["active"] | |
| 63 | if on == true then currColor = colors.lime | |
| 64 | else currColor = colors.red | |
| 65 | end | |
| 66 | fill(name, currColor, data) | |
| 67 | end | |
| 68 | end | |
| 69 | ||
| 70 | function checkxy(x, y) | |
| 71 | for name, data in pairs(button) do | |
| 72 | if y >= data["ymin"] and y <= data["ymax"] then | |
| 73 | if x >= data["xmin"] and x <= data["xmax"] then | |
| 74 | data["func"]() | |
| 75 | data["active"] = not data["active"] | |
| 76 | print(name) | |
| 77 | end | |
| 78 | - | if on == true then cuuColor = colors.lime |
| 78 | + | |
| 79 | end | |
| 80 | end | |
| 81 | ||
| 82 | function heading(text) | |
| 83 | w, h = mon.getSize() | |
| 84 | mon.setCursorPos((w - string.len(text))/2+1, 1) | |
| 85 | mon.write(text) | |
| 86 | end | |
| 87 | ||
| 88 | fillTable() | |
| 89 | ||
| 90 | while true do | |
| 91 | mon.clear() | |
| 92 | heading("Reactor Controller")
| |
| 93 | screen() | |
| 94 | local e, side, x, y = os.pullEvent("monitor_touch")
| |
| 95 | checkxy(x,y) | |
| 96 | sleep(0.1) | |
| 97 | - | function heding(text) |
| 97 | + | end |