Advertisement
DustinRosebery

startup(adv comp 6)

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