Advertisement
DustinRosebery

startup beta 2

Sep 2nd, 2013
275
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.  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.    m.clear()
  88.    m.setBackgroundColor(colors.black)
  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.     m.setBackgroundColor(colors.lime)
  104.     for x = 20, 30 do
  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.       for y = 12, 16 do
  120.         m.setCursorPos(x, y)
  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.         m.write(" ")
  136.       end
  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.     end
  152.    m.setBackgroundColor(colors.black)
  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.    m.setCursorPos(1,1)
  168.    print("In the very real case of a player death the force field will finish the job. Good Luck soldier... \n")
  169.    term.restore()
  170.         local event = (os.pullEvent())
  171.                 if event == ("monitor_touch") theneid
  172.         end
  173.         end
  174.         end
  175.         end
  176.         end
  177.         end
  178.         end
  179.    term.restore()
  180. end      
  181.  
  182. local function redButton()      --Dont Accept Arena Challenge
  183.  m.clear()
  184.  m.setTextScale(5)
  185.  m.setCursorPos(2,2)
  186.  m.setTextColor(colors.red)
  187.  m.write("Next Time Then")
  188.  os.sleep(4)
  189.  os.reboot()
  190. end
  191.  
  192. local function goRep()          -- flashes go on the screen
  193.  m.setTextScale(10)
  194.  m.setCursorPos(2,2)
  195.  m.write("GO!")
  196.  os.sleep(1)
  197.  m.clear()
  198.  os.sleep(0.5)
  199. end
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.     --Monitor screens
  207.  
  208. local function swapScreen()
  209.   m.clear()
  210.   m.setBackgroundColor(colors.black)
  211.   m.setTextScale(1)
  212.   m.setCursorPos(14,12)
  213.   term.redirect(m)
  214.     print("Touch to Start")
  215.   term.restore()
  216.   os.sleep(2)
  217.   os.reboot()
  218. end
  219.    
  220. local function WelcomeScreen()
  221.   m.clear()
  222.   m.setBackgroundColor(colors.black)
  223.   m.setTextScale(4)
  224.   m.setCursorPos(0,1)
  225.   m.setTextColor(colors.lime)
  226.   m.write(" Welcome")
  227.   m.setCursorPos(5,3)
  228.   m.setTextColor(colors.yellow)
  229.   m.write("to the")
  230.   m.setCursorPos(8,5)
  231.   m.setTextColor(colors.red)
  232.   m.write("ARENA!")
  233. end
  234.  
  235. local function yesNo(x1, x2, y1, y2)
  236. local event, side, X, Y = os.pullEventRaw()
  237.   if event == "monitor_touch" then
  238.     if (x1 >= 10 and x2 <= 20 and y1 >=12 and y2 <= 16) then
  239.       grnButton()
  240.     elseif (x1 >= 30 and x2 <= 40 and y1 >= 12 and y2 <= 16) then
  241.       redButton()
  242.     else
  243.       os.reboot()
  244.     end
  245.   end
  246. end
  247.  
  248. local function screenTwo()
  249.   m.clear()
  250.   m.setBackgroundColor(colors.black)
  251.   m.setTextScale(1)
  252.   m.setCursorPos(9,1)
  253.   m.setTextColor(colors.white)
  254.   m.write("Welcome to HDbag's Wither Arena!!!")
  255.   m.setCursorPos(4,2)
  256.   m.write("Co-Hosting IPJ and the boss of the underworld")
  257.   m.setCursorPos(8,5)
  258.   m.write("simply push the green button to start")
  259.   m.setCursorPos(11,6)
  260.   m.write("Or push the red button to stop")
  261.   m.setCursorPos(13,7)
  262.   m.write("Double click the buttons")
  263.   m.setCursorPos(1,9)
  264.   m.write("Work In Progress - - - Owners not held responsible")
  265.   m.setBackgroundColor(colors.lime)
  266.     for x = 10, 20 do
  267.       for y = 12, 16 do
  268.         m.setCursorPos(x, y)
  269.         m.write(" ")
  270.     end
  271.    end
  272.  m.setBackgroundColor(colors.red)
  273.    for x = 30, 40 do
  274.      for y = 12, 16 do
  275.        m.setCursorPos(x, y)
  276.        m.write(" ")
  277.      end
  278.    end
  279.  local event = (os.pullEvent())
  280.    if event == "monitor_touch" then
  281.      return
  282.    end
  283. end
  284.  
  285.     --Tables and executables
  286.  
  287. local redGrnButtons ={
  288.  [1] = {buttonType = 1, startX = 10, endX = 20, startY = 12, endY = 16, buttonText = "GO!", command = grnButton},
  289.  [2] = {buttonType = 1, startX = 30, endX = 40, startY = 12, endY = 16, buttonText = "NO", command = redButton}
  290. }
  291.  
  292. --local tutorialButton ={
  293. -- [1] = {buttonType = 1, startX = 20, endx = 30, startY = 12, endY = 16, buttonText = "#", command = oneWither
  294. --}
  295.  
  296. --local witherNum ={
  297.  --[1] = {buttonType = 1, startX = 20, endX = 30, startY = 12, endY = 16, buttonText = "1", command = oneWither},
  298. --}
  299.    
  300. local function buttonMenu(table)
  301.  for k,v in ipairs(table) do
  302.   m.setCursorPos(table[k].startX, table[k].startY)
  303.  end
  304.  while running do
  305.   for k,v in ipairs(table) do
  306.    event, button, x, y = os.pullEvent()
  307.    if event == "monitor_touch" then
  308.     if x >= table[k].startX and x <= table[k].endX and y >= table[k].startY and y <= table[k].endY then
  309.       table[k].command()
  310.     end
  311.    end
  312.   end
  313.   return
  314.  end
  315.  m.clear()
  316. end
  317.  
  318. local function clickCatch()
  319.     local eventtocatch = "monitor_touch"
  320.     local timeout = os.startTimer(3)
  321.     local e, arg1, arg2, arg3 = os.pullEvent()
  322.         if e == 'timer' and arg1 == timeout then
  323.             swapScreen()
  324.         elseif e == eventtocatch then
  325.             screenTwo()
  326.         end
  327. end
  328.  
  329. -- end of functions list
  330.  
  331. m.clear()
  332.  
  333.  
  334. WelcomeScreen()
  335. clickCatch()
  336.  
  337. screenTwo()
  338. buttonMenu(redGrnButtons)
  339.  
  340. grnButton()
  341. buttonMenu(oneWither)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement