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