View difference between Paste ID: 6ytq8wCc and 8Xqesn6v
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(4)
246
  m.setCursorPos(0,1)
247
  m.setTextColor(colors.lime)
248
  m.write(" Welcome")
249
  m.setCursorPos(5,3)
250
  m.setTextColor(colors.yellow)
251
  m.write("to the")
252
  m.setCursorPos(8,5)
253
  m.setTextColor(colors.red)
254
  m.write("ARENA!")
255
end
256
257
local function WelcomeScreen()
258
  m.clear()
259
  m.setBackgroundColor(colors.black)
260
  m.setTextScale(1)
261
  m.setCursorPos(14,12)
262
  term.redirect(m)
263
    print("Touch to Start")
264
  term.restore()
265
  os.sleep(2)
266
  swapScreen()
267
end
268
269
local function screenTwo()
270
  m.clear()
271
  m.setBackgroundColor(colors.black)
272
  m.setTextScale(1)
273
  m.setCursorPos(9,1)
274
  m.setTextColor(colors.white)
275
  m.write("Welcome to HDbag's Wither Arena!!!")
276
  m.setCursorPos(4,2)
277
  m.write("Co-Hosting IPJ and the boss of the underworld")
278
  m.setCursorPos(8,5)
279
  m.write("simply push the green button to start")
280
  m.setCursorPos(11,6)
281
  m.write("Or push the red button to stop")
282
  m.setCursorPos(13,7)
283
  m.write("Double click the buttons")
284
  m.setCursorPos(1,9)
285
  m.write("Work In Progress - - - Owners not held responsible")
286
  m.setBackgroundColor(colors.lime)
287
    for x = 10, 20 do
288
      for y = 12, 16 do
289
        m.setCursorPos(x, y)
290
        m.write(" ")
291
    end
292
   end
293
 m.setBackgroundColor(colors.red)
294
   for x = 30, 40 do
295
     for y = 12, 16 do
296
       m.setCursorPos(x, y)
297
       m.write(" ")
298
     end
299
   end
300
end
301
302
	--Tables and executables
303
304
local redGrnButtons ={
305
 [1] = {buttonType = 1, startX = 10, endX = 20, startY = 12, endY = 16, buttonText = "GO!", command = grnButton},
306
 [2] = {buttonType = 1, startX = 30, endX = 40, startY = 12, endY = 16, buttonText = "NO", command = redButton}
307
}
308
309
--local tutorialButton ={
310
-- [1] = {buttonType = 1, startX = 20, endx = 30, startY = 12, endY = 16, buttonText = "#", command = oneWither 
311
--}
312
313
--local witherNum ={
314
 --[1] = {buttonType = 1, startX = 20, endX = 30, startY = 12, endY = 16, buttonText = "1", command = oneWither},
315
--}
316
   
317
local function buttonMenu(table)
318
 for k,v in ipairs(table) do
319
  m.setCursorPos(table[k].startX, table[k].startY)
320
 end
321
 while running do
322
  for k,v in ipairs(table) do
323
   event, button, x, y = os.pullEvent()
324
   if event == "monitor_touch" then
325
    if x >= table[k].startX and x <= table[k].endX and y >= table[k].startY and y <= table[k].endY then
326
      table[k].command()
327
    end
328
   end
329
  end
330
  return
331
 end
332
 m.clear()
333
end
334
335
-- end of functions list
336
337
m.clear()
338
339
swapScreen()
340
341
local eventtocatch = 'monitor_touch'
342
local timeout = os.startTimer(5)
343
local e, arg1, arg2, arg3 = os.pullEvent()
344
  if e == 'timer' and arg1 == timeout then
345
    WelcomeScreen()
346
  end
347
  
348
os.sleep(2)
349
os.reboot()