View difference between Paste ID: UAWvbw2g and z3PK3FSM
SHOW: | | - or go back to the newest paste.
1
m = peripheral.wrap("left")
2
mBack = peripheral.wrap("back")
3
 
4
local running = true
5
6
--local printCenter = function(text, side)
7
 --local monitor = peripheral.wrap(side)
8
 --local maxw, maxh = monitor.getSize()
9
 --local curx, cury = monitor.getCursorPos()
10
11
 --monitor.setCursorPos((maxw-#text)/2,cury)
12
 --monitor.write(text)
13
 --monitor.setCursorPos(curx,cury+1)
14
--end
15
16
--local maxw, maxh = m.getSize()
17
--m.setCursorPos(1,math.floor(maxh/2))       reference sets to top middle line
18
19
	--Broadcasts
20
21
local function platOneBroadcastOn()
22
  rednet.open("top")
23
  rednet.broadcast("platOneOn")
24
  print("First Layer")
25
  rednet.close("top")
26
end
27
28
     -- Button Functions
29
30
local function oneWither()		--One Wither has been selected
31
 m.setBackgroundColor(colors.black)
32
 m.clear()
33
 m.setTextScale(5)
34
 m.setTextColor(colors.lime)
35
 m.setCursorPos(5,2)
36
 m.write("5")
37
 os.sleep(1)
38
 m.clear()
39
 m.setCursorPos(5,2)
40
 m.write("4")
41
 os.sleep(1)
42
 m.clear()
43
 m.setCursorPos(5,2)
44
 m.write("3")
45
 os.sleep(1)
46
 m.clear()
47
 m.setCursorPos(5,2)
48
 m.write("2")
49
 os.sleep(1)
50
 m.clear()
51
 m.setCursorPos(5,2)
52
 m.write("1")
53
 os.sleep(1)
54
 m.clear()
55
56
 platOneBroadcastOn()
57
58
 goRep()
59
 goRep()
60
 goRep()
61
end
62
63
local function grnButton()		--Accept Arena challenge button
64
65
66
 m.setBackgroundColor(colors.black)
67
 m.clear()
68
 m.setTextScale(1)
69
 term.redirect(m)
70
   m.setBackgroundColor(colors.black)
71
   m.setBackgroundColor(colors.lime)
72
    for x = 20, 30 do
73
      for y = 12, 16 do
74
        m.setCursorPos(x, y)
75
        m.write(" ")
76
    end
77
   end
78
   
79
   m.setCursorPos(1,1)
80
   print("Touch green button at any point to skip tutorial")
81
   m.setCursorPos(1,2)
82
   print("Touch any other part of the screen to view the next page.")
83
   m.setCursorPos(1,4)
84
   textutils.slowPrint("Welcome to the Arena")
85
   local event = (os.pullEvent("monitor_touch"))
86
 if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
87
   oneWither()
88
 else
89
 return
90
 end
91
92
   m.clear()
93
    m.setBackgroundColor(colors.black)
94
    m.setBackgroundColor(colors.lime)
95
    for x = 20, 30 do
96
      for y = 12, 16 do
97
        m.setCursorPos(x, y)
98
        m.write(" ")
99
    end
100
   end   
101
102
   m.setCursorPos(1,1)
103
   print("This tutorial explains what you will need to do to safely battle the wither in our base \n")
104
   local event = (os.pullEvent("monitor_touch"))
105
if event == true then
106
 if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
107
   oneWither()
108
 else
109
 return
110
 end
111
end
112
   
113
   m.clear()
114
    m.setBackgroundColor(colors.black)
115
    m.setBackgroundColor(colors.lime)
116
    for x = 20, 30 do
117
      for y = 12, 16 do
118
        m.setCursorPos(x, y)
119
        m.write(" ")
120
    end
121
   end
122
123
   m.setCursorPos(1,1)
124
   print("to start the battle you will touch the green button and a timer will count down from 5 and the screen will flash GO! \n")
125
   local event = (os.pullEvent("monitor_touch"))
126
if event == true then
127
 if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
128
   oneWither()
129
 else
130
 return
131
 end
132
end
133
   m.clear()
134
    m.setBackgroundColor(colors.black)
135
    m.setBackgroundColor(colors.lime)
136
    for x = 20, 30 do
137
      for y = 12, 16 do
138
        m.setCursorPos(x, y)
139
        m.write(" ")
140
    end
141
   end
142
143
   m.setCursorPos(1,1)
144
   print("As soon as the timer ends and the go begins to flash a platform will appear directly off the left of the platform, jump down and type Ready in the world chat... use a capitol R in Ready \n")
145
   local event = (os.pullEvent("monitor_touch"))
146
if event == true then
147
 if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
148
   oneWither()
149
 else
150
 return
151
 end
152
end
153
   m.clear()
154
    m.setBackgroundColor(colors.black)
155
    m.setBackgroundColor(colors.lime)
156
    for x = 20, 30 do
157
      for y = 12, 16 do
158
        m.setCursorPos(x, y)
159
        m.write(" ")
160
      end
161
    end
162
163
   m.setCursorPos(1,1)
164
   print("After you say the command in worldchat the blastshield will activate and the wither will start to be constructed \n")
165
   local event = (os.pullEvent("monitor_touch"))
166
if event == true then
167
 if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
168
   oneWither()
169
 else
170
 return
171
 end
172
end
173
   m.clear()
174
    m.setBackgroundColor(colors.black)
175
    m.setBackgroundColor(colors.lime)
176
    for x = 20, 30 do
177
      for y = 12, 16 do
178
        m.setCursorPos(x, y)
179
        m.write(" ")
180
    end
181
   end
182
183
   m.setCursorPos(1,1)
184
   print("For this version, how you defeat the wither is up to you... But to prevent accidental release of the wither the force field can not be deactivated until the nether star is placed in the last slot of the turtle you will find at the corner of the arena \n")
185
   local event = (os.pullEvent("monitor_touch"))
186
if event == true then
187
 if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
188
   oneWither()
189
 else
190
 return
191
 end
192
end
193
   m.clear()
194
    m.setBackgroundColor(colors.black)
195
    m.setBackgroundColor(colors.lime)
196
    for x = 20, 30 do
197
      for y = 12, 16 do
198
        m.setCursorPos(x, y)
199
        m.write(" ")
200
    end
201
   end
202
203
   m.setCursorPos(1,1)
204
   print("In the very real case of a player death the force field will finish the job. Good Luck soldier... \n")
205
   term.restore()
206
   local event = (os.pullEvent("monitor_touch"))
207
   if event == true then
208
     if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
209
       oneWither()
210
     end
211
   end
212
   term.restore()
213
end      
214
 
215
 
216
local function redButton()		--Dont Accept Arena Challenge
217
 m.clear()
218
 m.setTextScale(5)
219
 m.setCursorPos(2,2)
220
 m.setTextColor(colors.red)
221
 m.write("LOSER")
222
 os.sleep(10)
223
 os.reboot()
224
end
225
226
local function goRep()			-- flashes go on the screen
227
 m.setTextScale(10)
228
 m.setCursorPos(2,2)
229
 m.write("GO!")
230
 os.sleep(1)
231
 m.clear()
232
 os.sleep(0.5)
233
end
234
235
236
237
238
239
 
240
	--Monitor screens
241
242
local function swapScreen()
243
  m.clear()
244
  m.setBackgroundColor(colors.black)
245
  m.setTextScale(1)
246
  m.setCursorPos(14,12)
247
  term.redirect(m)
248
    print("Touch to Start")
249
  term.restore()
250
  os.sleep(2)
251
  os.reboot()
252
end
253
    
254
local function WelcomeScreen()
255
  m.clear()
256
  m.setBackgroundColor(colors.black)
257
  m.setTextScale(4)
258
  m.setCursorPos(0,1)
259
  m.setTextColor(colors.lime)
260
  m.write(" Welcome")
261
  m.setCursorPos(5,3)
262
  m.setTextColor(colors.yellow)
263
  m.write("to the")
264
  m.setCursorPos(8,5)
265
  m.setTextColor(colors.red)
266
  m.write("ARENA!")
267
  os.sleep(3)
268
  swapScreen()
269
end
270
271
local function yesNo(x1, x2, y1, y2)
272
local event, side, X, Y = os.pullEventRaw()
273
  if event == "monitor_touch" then
274
    if (x1 >= 10 and x2 <= 20 and y1 >=12 and y2 <= 16) then
275
      grnButton()
276
    elseif (x1 >= 30 and x2 <= 40 and y1 >= 12 and y2 <= 16) then
277
      os.reboot()
278
    else
279
      os.reboot()
280
    end
281
  end
282
end
283
284
local function screenTwo()
285
  m.clear()
286
  m.setBackgroundColor(colors.black)
287
  m.setTextScale(1)
288
  m.setCursorPos(9,1)
289
  m.setTextColor(colors.white)
290
  m.write("Welcome to HDbag's Wither Arena!!!")
291
  m.setCursorPos(4,2)
292
  m.write("Co-Hosting IPJ and the boss of the underworld")
293
  m.setCursorPos(8,5)
294
  m.write("simply push the green button to start")
295
  m.setCursorPos(11,6)
296
  m.write("Or push the red button to stop")
297
  m.setCursorPos(13,7)
298
  m.write("Double click the buttons")
299
  m.setCursorPos(1,9)
300
  m.write("Work In Progress - - - Owners not held responsible")
301
  m.setBackgroundColor(colors.lime)
302
    for x = 10, 20 do
303
      for y = 12, 16 do
304
        m.setCursorPos(x, y)
305
        m.write(" ")
306
    end
307
   end
308
 m.setBackgroundColor(colors.red)
309
   for x = 30, 40 do
310
     for y = 12, 16 do
311
       m.setCursorPos(x, y)
312
       m.write(" ")
313
     end
314
   end
315
end
316
317
	--Tables and executables
318
319
local redGrnButtons ={
320
 [1] = {buttonType = 1, startX = 10, endX = 20, startY = 12, endY = 16, buttonText = "GO!", command = grnButton},
321
 [2] = {buttonType = 1, startX = 30, endX = 40, startY = 12, endY = 16, buttonText = "NO", command = redButton}
322
}
323
324
--local tutorialButton ={
325
-- [1] = {buttonType = 1, startX = 20, endx = 30, startY = 12, endY = 16, buttonText = "#", command = oneWither 
326
--}
327
328
--local witherNum ={
329
 --[1] = {buttonType = 1, startX = 20, endX = 30, startY = 12, endY = 16, buttonText = "1", command = oneWither},
330
--}
331
   
332
local function buttonMenu(table)
333
 for k,v in ipairs(table) do
334
  m.setCursorPos(table[k].startX, table[k].startY)
335
 end
336
 while running do
337
  for k,v in ipairs(table) do
338
   event, button, x, y = os.pullEvent()
339
   if event == "monitor_touch" then
340
    if x >= table[k].startX and x <= table[k].endX and y >= table[k].startY and y <= table[k].endY then
341
      table[k].command()
342
    end
343
   end
344
  end
345
  return
346
 end
347
 m.clear()
348
end
349
350
351
352
-- end of functions list
353
354
m.clear()
355
356
while true do
357
WelcomeScreen()
358-
	else
358+
359-
		WelcomeScreen()
359+
360
	if event == "monitor_touch" then
361
		screenTwo()
362
	end
363
end