View difference between Paste ID: gBYAEGxK and m4PB0mpe
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
 m.setBackgroundColor(colors.black)
65
 m.clear()
66
 m.setTextScale(1)
67
 term.redirect(m)
68
   m.setCursorPos(1,1)
69
   m.clear()
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
   m.setBackgroundColor(colors.black)
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())
86
                if event == ("monitor_touch") then 
87-
                        return
87+
88-
                end
88+
89
   m.setBackgroundColor(colors.lime)
90
    for x = 20, 30 do
91
      for y = 12, 16 do
92
        m.setCursorPos(x, y)
93
        m.write(" ")
94
      end
95
    end  
96
   m.setBackgroundColor(colors.black)
97
   m.setCursorPos(1,1)
98
   print("This tutorial explains what you will need to do to safely battle the wither in our base \n")
99
        local event = (os.pullEvent())
100
                if event == ("monitor_touch") then
101
    m.clear()
102
    m.setBackgroundColor(colors.black)
103-
                        return
103+
104-
                end
104+
105
      for y = 12, 16 do
106
        m.setCursorPos(x, y)
107
        m.write(" ")
108
      end
109
    end
110
   m.setBackgroundColor(colors.black)
111
   m.setCursorPos(1,1)
112
   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")
113
        local event = (os.pullEvent())
114
                if event == ("monitor_touch") then
115
   m.clear()
116
   m.setBackgroundColor(colors.black)
117
   m.setBackgroundColor(colors.lime)
118
    for x = 20, 30 do
119-
                        return
119+
120-
                end
120+
121
        m.write(" ")
122
      end
123
    end
124
   m.setBackgroundColor(colors.black)
125
   m.setCursorPos(1,1)
126
   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")
127
        local event = (os.pullEvent())
128
                if event == ("monitor_touch") then
129
   m.clear()
130
   m.setBackgroundColor(colors.black)
131
   m.setBackgroundColor(colors.lime)
132
    for x = 20, 30 do
133
      for y = 12, 16 do
134
        m.setCursorPos(x, y)
135-
                        return
135+
136-
                end
136+
137
    end
138
   m.setBackgroundColor(colors.black)
139
   m.setCursorPos(1,1)
140
   print("After you say the command in worldchat the blastshield will activate and the wither will start to be constructed \n")
141
        local event = (os.pullEvent())
142
                if event == ("monitor_touch") then
143
   m.clear()
144
   m.setBackgroundColor(colors.black)
145
   m.setBackgroundColor(colors.lime)
146
    for x = 20, 30 do
147
      for y = 12, 16 do
148
        m.setCursorPos(x, y)
149
        m.write(" ")
150
      end
151-
                        return
151+
152-
                end
152+
153
   m.setCursorPos(1,1)
154
   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")
155
        local event = (os.pullEvent())
156
                if event == ("monitor_touch") then
157
   m.clear()
158
   m.setBackgroundColor(colors.black)
159
   m.setBackgroundColor(colors.lime)
160
    for x = 20, 30 do
161
      for y = 12, 16 do
162
        m.setCursorPos(x, y)
163
        m.write(" ")
164
      end
165
    end
166
   m.setBackgroundColor(colors.black)  
167-
                        return
167+
168-
                end
168+
169
   term.restore()
170
        local event = (os.pullEvent())
171
                if event == ("monitor_touch") theneid
172
   term.restore()
173
end      
174
175
local function redButton()		--Dont Accept Arena Challenge
176
 m.clear()
177
 m.setTextScale(5)
178
 m.setCursorPos(2,2)
179
 m.setTextColor(colors.red)
180
 m.write("Next Time Then")
181
 os.sleep(4)
182
 os.reboot()
183
end
184-
                        return
184+
185-
                end
185+
186
 m.setTextScale(10)
187
 m.setCursorPos(2,2)
188
 m.write("GO!")
189
 os.sleep(1)
190
 m.clear()
191
 os.sleep(0.5)
192
end
193
194
195
196
197
198
 
199
	--Monitor screens
200
201
local function swapScreen()
202
  m.clear()
203
  m.setBackgroundColor(colors.black)
204
  m.setTextScale(1)
205
  m.setCursorPos(14,12)
206
  term.redirect(m)
207
    print("Touch to Start")
208
  term.restore()
209
  os.sleep(2)
210
  os.reboot()
211
end
212
    
213
local function WelcomeScreen()
214
  m.clear()
215
  m.setBackgroundColor(colors.black)
216
  m.setTextScale(4)
217
  m.setCursorPos(0,1)
218
  m.setTextColor(colors.lime)
219
  m.write(" Welcome")
220
  m.setCursorPos(5,3)
221
  m.setTextColor(colors.yellow)
222
  m.write("to the")
223
  m.setCursorPos(8,5)
224
  m.setTextColor(colors.red)
225
  m.write("ARENA!")
226
end
227
228
local function yesNo(x1, x2, y1, y2)
229
local event, side, X, Y = os.pullEventRaw()
230
  if event == "monitor_touch" then
231
    if (x1 >= 10 and x2 <= 20 and y1 >=12 and y2 <= 16) then
232
      grnButton()
233
    elseif (x1 >= 30 and x2 <= 40 and y1 >= 12 and y2 <= 16) then
234
      redButton()
235
    else
236
      os.reboot()
237
    end
238
  end
239
end
240
241
local function screenTwo()
242
  m.clear()
243
  m.setBackgroundColor(colors.black)
244
  m.setTextScale(1)
245
  m.setCursorPos(9,1)
246
  m.setTextColor(colors.white)
247
  m.write("Welcome to HDbag's Wither Arena!!!")
248
  m.setCursorPos(4,2)
249
  m.write("Co-Hosting IPJ and the boss of the underworld")
250
  m.setCursorPos(8,5)
251
  m.write("simply push the green button to start")
252
  m.setCursorPos(11,6)
253
  m.write("Or push the red button to stop")
254
  m.setCursorPos(13,7)
255
  m.write("Double click the buttons")
256
  m.setCursorPos(1,9)
257
  m.write("Work In Progress - - - Owners not held responsible")
258
  m.setBackgroundColor(colors.lime)
259
    for x = 10, 20 do
260
      for y = 12, 16 do
261
        m.setCursorPos(x, y)
262
        m.write(" ")
263
    end
264
   end
265
 m.setBackgroundColor(colors.red)
266
   for x = 30, 40 do
267
     for y = 12, 16 do
268
       m.setCursorPos(x, y)
269
       m.write(" ")
270
     end
271
   end
272
 local event = (os.pullEvent())
273
   if event == "monitor_touch" then
274
     return
275
   end
276
end
277
278
	--Tables and executables
279
280
local redGrnButtons ={
281
 [1] = {buttonType = 1, startX = 10, endX = 20, startY = 12, endY = 16, buttonText = "GO!", command = grnButton},
282
 [2] = {buttonType = 1, startX = 30, endX = 40, startY = 12, endY = 16, buttonText = "NO", command = redButton}
283
}
284
285
--local tutorialButton ={
286
-- [1] = {buttonType = 1, startX = 20, endx = 30, startY = 12, endY = 16, buttonText = "#", command = oneWither 
287
--}
288
289
--local witherNum ={
290
 --[1] = {buttonType = 1, startX = 20, endX = 30, startY = 12, endY = 16, buttonText = "1", command = oneWither},
291
--}
292
   
293
local function buttonMenu(table)
294
 for k,v in ipairs(table) do
295
  m.setCursorPos(table[k].startX, table[k].startY)
296
 end
297
 while running do
298
  for k,v in ipairs(table) do
299
   event, button, x, y = os.pullEvent()
300
   if event == "monitor_touch" then
301
    if x >= table[k].startX and x <= table[k].endX and y >= table[k].startY and y <= table[k].endY then
302
      table[k].command()
303
    end
304
   end
305
  end
306
  return
307
 end
308
 m.clear()
309
end
310
311
local function clickCatch()
312
	local eventtocatch = "monitor_touch"
313
	local timeout = os.startTimer(3)
314
	local e, arg1, arg2, arg3 = os.pullEvent()
315
  		if e == 'timer' and arg1 == timeout then
316
			swapScreen()
317
		elseif e == eventtocatch then
318
			screenTwo()
319
		end
320
end
321
322
-- end of functions list
323
324
m.clear()
325
326
327
WelcomeScreen()
328
clickCatch()
329
330
screenTwo()
331
buttonMenu(redGrnButtons)
332
333
grnButton()
334
buttonMenu(oneWither)