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