SHOW:
|
|
- or go back to the newest paste.
1 | --Programm made by Mrswisstobi-- | |
2 | ||
3 | local button = {} | |
4 | local side = "bottom" | |
5 | - | local mon = peripheral.wrap("monitor_8") |
5 | + | local mon = peripheral.wrap("monitor_7") |
6 | local textScale = 1 | |
7 | ||
8 | ------------ color variables ------------ | |
9 | ||
10 | local btnTextColor = colors.black | |
11 | local defaultBgColor = colors.black | |
12 | local headerColor = colors.green | |
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("AFCC Main Spawners") |
23 | + | heading("AFCC Industrial Machines") |
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 OFF" then | |
33 | button[name]["active"] = false | |
34 | end | |
35 | mon.clear() | |
36 | - | heading("AFCC Main Spawners") |
36 | + | heading("AFCC Industrial Machines") |
37 | screen() | |
38 | end | |
39 | end | |
40 | ||
41 | rs.setBundledOutput(side, 0) | |
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("Endermen", switchOutput, 17, 27, 3, 5, colors.white, colors.lightGray, colors.green) |
49 | + | setTable("Cobblestone", switchOutput, 17, 27, 3, 5, colors.white, colors.lightGray, colors.green) |
50 | - | setTable("Blazes", switchOutput, 17, 27, 7, 9, colors.orange, colors.lightGray, colors.green) |
50 | + | setTable("Obsidian", switchOutput, 17, 27, 7, 9, colors.orange, colors.lightGray, colors.green) |
51 | - | setTable("Blizzes", switchOutput, 17, 27, 11, 13, colors.magenta, colors.lightGray, colors.green) |
51 | + | setTable("Sand", switchOutput, 17, 27, 11, 13, colors.magenta, colors.lightGray, colors.green) |
52 | - | setTable("Skelet0rs", switchOutput, 17, 27, 15, 17, colors.lightBlue, colors.lightGray, colors.green) |
52 | + | setTable("Enderium", switchOutput, 17, 27, 15, 17, colors.lightBlue, colors.lightGray, colors.green) |
53 | - | setTable("Slimes", switchOutput, 31, 41, 3, 5, colors.yellow, colors.lightGray, colors.green) |
53 | + | setTable("Glass", switchOutput, 31, 41, 3, 5, colors.yellow, colors.lightGray, colors.green) |
54 | - | setTable("Withers", switchOutput, 31, 41, 7, 9, colors.lime, colors.lightGray, colors.green) |
54 | + | setTable("cr. Obs.", switchOutput, 31, 41, 7, 9, colors.lime, colors.lightGray, colors.green) |
55 | - | setTable("Your Mom", switchOutput, 31, 41, 11, 13, colors.pink, colors.lightGray, colors.green) |
55 | + | setTable("empty", switchOutput, 31, 41, 11, 13, colors.pink, colors.lightGray, colors.green) |
56 | - | setTable("Rainsensor", switchOutput, 31, 41, 15, 17, colors.gray, colors.lightGray, colors.green) |
56 | + | setTable("empty", switchOutput, 31, 41, 15, 17, colors.gray, colors.lightGray, colors.green) |
57 | - | setTable("Wheat", switchOutput, 45, 55, 3, 5, colors.lightGray, colors.lightGray, colors.green) |
57 | + | setTable("empty", switchOutput, 45, 55, 3, 5, colors.lightGray, colors.lightGray, colors.green) |
58 | - | setTable("Flowers", switchOutput, 45, 55, 7, 9, colors.cyan, colors.lightGray, colors.green) |
58 | + | setTable("empty", switchOutput, 45, 55, 7, 9, colors.cyan, colors.lightGray, colors.green) |
59 | - | setTable("Oak Trees", switchOutput, 45, 55, 11, 13, colors.purple, colors.lightGray, colors.green) |
59 | + | setTable("empty", switchOutput, 45, 55, 11, 13, colors.purple, colors.lightGray, colors.green) |
60 | - | setTable("Rubber", switchOutput, 45, 55, 15, 17, colors.blue, colors.lightGray, colors.green) |
60 | + | setTable("empty", switchOutput, 45, 55, 15, 17, colors.blue, colors.lightGray, colors.green) |
61 | - | setTable("Veggies", switchOutput, 59, 69, 3, 5, colors.brown, colors.lightGray, colors.green) |
61 | + | setTable("empty", switchOutput, 59, 69, 3, 5, colors.brown, colors.lightGray, colors.green) |
62 | - | setTable("Cows", switchOutput, 59, 69, 7, 9, colors.green, colors.lightGray, colors.green) |
62 | + | setTable("empty", switchOutput, 59, 69, 7, 9, colors.green, colors.lightGray, colors.green) |
63 | - | setTable("Pigs", switchOutput, 59, 69, 11, 13, colors.red, colors.lightGray, colors.green) |
63 | + | setTable("empty", switchOutput, 59, 69, 11, 13, colors.red, colors.lightGray, colors.green) |
64 | - | setTable("Chickens", switchOutput, 59, 69, 15, 17, colors.black, colors.lightGray, colors.green) |
64 | + | setTable("empty", switchOutput, 59, 69, 15, 17, colors.black, colors.lightGray, colors.green) |
65 | setTable("All ON", turnAllOn, 3, 13, 3, 9, "" , colors.green, colors.green) | |
66 | setTable("All OFF", turnAllOff, 3, 13, 11, 17, "" , colors.lightGray, colors.lightGray) | |
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]["btnOff"] = btnOff | |
79 | button[name]["btnOn"] = btnOn | |
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("AFCC Main Spawners") |
144 | + | heading("AFCC Industrial Machines") |
145 | screen() | |
146 | local e,side,x,y = os.pullEvent("monitor_touch") | |
147 | checkxy(x,y) | |
148 | sleep(.1) | |
149 | end |