SHOW:
|
|
- or go back to the newest paste.
1 | ||
2 | m = peripheral.wrap("left") | |
3 | mBack = peripheral.wrap("back") | |
4 | ||
5 | local running = true | |
6 | ||
7 | local printCenter = function(text, side) | |
8 | local monitor = peripheral.wrap(side) | |
9 | local maxw, maxh = monitor.getSize() | |
10 | local curx, cury = monitor.getCursorPos() | |
11 | ||
12 | monitor.setCursorPos((maxw-#text)/2,cury) | |
13 | monitor.write(text) | |
14 | monitor.setCursorPos(curx,cury+1) | |
15 | end | |
16 | ||
17 | local maxw, maxh = m.getSize() | |
18 | --m.setCursorPos(1,math.floor(maxh/2)) reference sets to top middle line | |
19 | ||
20 | --Broadcasts | |
21 | ||
22 | local function platOneBroadcastOn() | |
23 | rednet.open("top") | |
24 | rednet.broadcast("platOneOn") | |
25 | print("First Layer") | |
26 | rednet.close("top") | |
27 | end | |
28 | ||
29 | -- Button Functions | |
30 | ||
31 | local function grnButton() --Accept Arena challenge button | |
32 | m.setBackGroundColor(colors.black) | |
33 | m.clear() | |
34 | m.setTextScale(1) | |
35 | m.setCursorPos(1,1) | |
36 | term.redirect(m) | |
37 | print("Touch screen at any point to skip tutorial") | |
38 | term.restore() | |
39 | m.setCursorPos(1,3) | |
40 | term.redirect(m) | |
41 | textutils.slowPrint("Welcome to the Arena") | |
42 | clear() | |
43 | term.r | |
44 | ||
45 | ||
46 | ||
47 | local function redButton() --Dont Accept Arena Challenge | |
48 | m.clear() | |
49 | m.setTextScale(5) | |
50 | m.setCursorPos(2,2) | |
51 | m.setTextColor(colors.red) | |
52 | m.write("LOSER") | |
53 | os.sleep(10) | |
54 | os.reboot() | |
55 | end | |
56 | ||
57 | local function goRep() -- flashes go on the screen | |
58 | m.setTextScale(10) | |
59 | m.setCursorPos(2,2) | |
60 | m.write("GO!) | |
61 | os.sleep(1) | |
62 | m.clear() | |
63 | os.sleep(0.5) | |
64 | end | |
65 | ||
66 | local function oneWither() --One Wither has been selected | |
67 | m.setBackgroundColor(colors.black) | |
68 | m.clear() | |
69 | m.setTextScale(5) | |
70 | m.setTextColor(colors.lime) | |
71 | m.setCursorPos(5,2) | |
72 | m.write("5") | |
73 | os.sleep(1) | |
74 | m.clear() | |
75 | m.setCursorPos(5,2) | |
76 | m.write("4") | |
77 | os.sleep(1) | |
78 | m.clear() | |
79 | m.setCursorPos(5,2) | |
80 | m.write("3") | |
81 | os.sleep(1) | |
82 | m.clear() | |
83 | m.setCursorPos(5,2) | |
84 | m.write("2") | |
85 | os.sleep(1) | |
86 | m.clear() | |
87 | m.setCursorPos(5,2) | |
88 | m.write("1") | |
89 | os.sleep(1) | |
90 | m.clear() | |
91 | ||
92 | platOneBroadcastOn() | |
93 | ||
94 | goRep() | |
95 | goRep() | |
96 | goRep() | |
97 | ||
98 | end | |
99 | ||
100 | ||
101 | ||
102 | --Tables and executables | |
103 | ||
104 | local redGrnButtons ={ | |
105 | [1] = {buttonType = 1, startX = 10, endX = 20, startY = 12, endY = 16, buttonText = "GO!", command = grnButton}, | |
106 | [2] = {buttonType = 1, startX = 30, endX = 40, startY = 12, endY = 16, buttonText = "NO", command = redButton} | |
107 | } | |
108 | ||
109 | local witherNum ={ | |
110 | [1] = {buttonType = 1, startX = 10, endX = 20, startY = 12, endY = 16, buttonText = "1", command = oneWither}, | |
111 | [2] = {buttinType = 1, startX = 30, endX = 40, startY = 12, endY = 16, buttonText = "2", command = twoWither} | |
112 | } | |
113 | ||
114 | local function buttonMenu(table) | |
115 | for k,v in ipairs(table) do | |
116 | m.setCursorPos(table[k].startX, table[k].startY) | |
117 | end | |
118 | while running do | |
119 | for k,v in ipairs(table) do | |
120 | event, button, x, y = os.pullEvent() | |
121 | if event == "monitor_touch" then | |
122 | if x >= table[k].startX and x <= table[k].endX and y >= table[k].startY and y <= table[k].endY then | |
123 | table[k].command() | |
124 | end | |
125 | end | |
126 | end | |
127 | return | |
128 | end | |
129 | m.clear() | |
130 | end | |
131 | ||
132 | --Monitor screens | |
133 | ||
134 | local function WelcomeScreen() | |
135 | m.clear() | |
136 | m.setBackgroundColor(colors.black) | |
137 | m.setTextScale(4) | |
138 | m.setCursorPos(0,1) | |
139 | m.setTextColor(colors.lime) | |
140 | m.write(" Welcome") | |
141 | m.setCursorPos(5,3) | |
142 | m.setTextColor(colors.yellow) | |
143 | m.write("to the") | |
144 | m.setCursorPos(8,5) | |
145 | m.setTextColor(colors.red) | |
146 | m.write("ARENA!") | |
147 | end | |
148 | ||
149 | local function screenTwo() | |
150 | m.clear() | |
151 | m.setBackgroundColor(colors.black) | |
152 | m.setTextScale(1) | |
153 | m.setCursorPos(9,1) | |
154 | m.setTextColor(colors.white) | |
155 | m.write("Welcome to HDbag's Wither Arena!!!") | |
156 | m.setCursorPos(4,2) | |
157 | m.write("Co-Hosting IPJ and the boss of the underworld") | |
158 | m.setCursorPos(8,5) | |
159 | m.write("simply push the green button to start") | |
160 | m.setCursorPos(11,6) | |
161 | m.write("Or push the red button to stop") | |
162 | m.setCursorPos(1,8) | |
163 | m.write("Work In Progress - - - Owners not held responsible") | |
164 | m.setBackgroundColor(colors.lime) | |
165 | for x = 10, 20 do | |
166 | for y = 12, 16 do | |
167 | m.setCursorPos(x, y) | |
168 | m.write(" ") | |
169 | end | |
170 | end | |
171 | m.setBackgroundColor(colors.red) | |
172 | for x = 30, 40 do | |
173 | for y = 12, 16 do | |
174 | m.setCursorPos(x, y) | |
175 | m.write(" ") | |
176 | end | |
177 | end | |
178 | end | |
179 | ||
180 | -- end of functions list | |
181 | ||
182 | m.clear() | |
183 | WelcomeScreen() | |
184 | os.sleep(1.5) | |
185 | ||
186 | local event = (os.pullEvent()) | |
187 | if event == "monitor_touch" then | |
188 | screenTwo() | |
189 | buttonMenu(redGrnButtons) | |
190 | buttonMenu(witherNum) | |
191 | end |