Guest User

wTest

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