Advertisement
DustinRosebery

wTest

Sep 1st, 2013
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.  m.setCursorPos(1,1)
  71.  term.redirect(m)
  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.    print("Touch green button at any point to skip tutorial")
  80.    m.setCursorPos(1,2)
  81.    print("Touch any other part of the screen to view the next page.")
  82.    m.setCursorPos(1,4)
  83.    textutils.slowPrint("Welcome to the Arena")
  84.    local event = (os.pullEvent("monitor_touch"))
  85. if event == true then
  86.  if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
  87.    oneWither()
  88.  else
  89.  return
  90.  end
  91.    m.clear()
  92.     m.setBackgroundColor(colors.lime)
  93.     for x = 20, 30 do
  94.       for y = 12, 16 do
  95.         m.setCursorPos(x, y)
  96.         m.write(" ")
  97.     end
  98.    end  
  99.  
  100.    m.setCursorPos(1,1)
  101.    print("This tutorial explains what you will need to do to safely battle the wither in our base \n")
  102.    local event = (os.pullEvent("monitor_touch"))
  103. if event == true then
  104.  if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
  105.    oneWither()
  106.  else
  107.  return
  108.  end
  109.    m.clear()
  110.     m.setBackgroundColor(colors.lime)
  111.     for x = 20, 30 do
  112.       for y = 12, 16 do
  113.         m.setCursorPos(x, y)
  114.         m.write(" ")
  115.     end
  116.    end
  117.  
  118.    m.setCursorPos(1,1)
  119.    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")
  120.    local event = (os.pullEvent("monitor_touch"))
  121. if event == true then
  122.  if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
  123.    oneWither()
  124.  else
  125.  return
  126.  end
  127.    m.clear()
  128.     m.setBackgroundColor(colors.lime)
  129.     for x = 20, 30 do
  130.       for y = 12, 16 do
  131.         m.setCursorPos(x, y)
  132.         m.write(" ")
  133.     end
  134.    end
  135.  
  136.    m.setCursorPos(1,1)
  137.    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")
  138.    local event = (os.pullEvent("monitor_touch"))
  139.  if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
  140.    oneWither()
  141.  else
  142.  return
  143.  end
  144.    m.clear()
  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.  
  153.    m.setCusorPos(1,1)
  154.    print("After you say the command in worldchat the blastshield will activate and the wither will start to be constructed \n")
  155.    local event = (os.pullEvent("monitor_touch"))
  156. if event == true then
  157.  if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
  158.    oneWither()
  159.  else
  160.  return
  161.  end
  162.    m.clear()
  163.     m.setBackgroundColor(colors.lime)
  164.     for x = 20, 30 do
  165.       for y = 12, 16 do
  166.         m.setCursorPos(x, y)
  167.         m.write(" ")
  168.     end
  169.    end
  170.  
  171.    m.setCursorPos(1,1)
  172.    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")
  173.    local event = (os.pullEvent("monitor_touch"))
  174. if event == true then
  175.  if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
  176.    oneWither()
  177.  else
  178.  return
  179.  end
  180.    m.clear()
  181.     m.setBackgroundColor(colors.lime)
  182.     for x = 20, 30 do
  183.       for y = 12, 16 do
  184.         m.setCursorPos(x, y)
  185.         m.write(" ")
  186.     end
  187.    end
  188.  
  189.    m.setCurosrPos()
  190.    print("In the very real case of a player death the force field will finish the job. Good Luck soldier... \n")
  191.    term.restore()
  192.    local event = (os.pullEvent("monitor_touch"))
  193.    if event == true then
  194.      if x <= 30 and x >= 20 and y <= 16 and y >= 12 then
  195.        oneWither()
  196.      end
  197. end      
  198.  
  199.  
  200. local function redButton()      --Dont Accept Arena Challenge
  201.  m.clear()
  202.  m.setTextScale(5)
  203.  m.setCursorPos(2,2)
  204.  m.setTextColor(colors.red)
  205.  m.write("LOSER")
  206.  os.sleep(10)
  207.  os.reboot()
  208. end
  209.  
  210. local function goRep()          -- flashes go on the screen
  211.  m.setTextScale(10)
  212.  m.setCursorPos(2,2)
  213.  m.write("GO!")
  214.  os.sleep(1)
  215.  m.clear()
  216.  os.sleep(0.5)
  217. end
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.     --Monitor screens
  225.    
  226. local function WelcomeScreen()
  227.   m.clear()
  228.   m.setBackgroundColor(colors.black)
  229.   m.setTextScale(4)
  230.   m.setCursorPos(0,1)
  231.   m.setTextColor(colors.lime)
  232.   m.write(" Welcome")
  233.   m.setCursorPos(5,3)
  234.   m.setTextColor(colors.yellow)
  235.   m.write("to the")
  236.   m.setCursorPos(8,5)
  237.   m.setTextColor(colors.red)
  238.   m.write("ARENA!")
  239. end
  240.  
  241. local function screenTwo()
  242.   m.clear()
  243.   m.setBackgroundColor(colors.black)
  244.   m.setTextScale(1)
  245.   m.setCursorPos(9,1)
  246.   m.setTextColor(colors.white)
  247.   m.write("Welcome to HDbag's Wither Arena!!!")
  248.   m.setCursorPos(4,2)
  249.   m.write("Co-Hosting IPJ and the boss of the underworld")
  250.   m.setCursorPos(8,5)
  251.   m.write("simply push the green button to start")
  252.   m.setCursorPos(11,6)
  253.   m.write("Or push the red button to stop")
  254.   m.setCursorPos(13,7)
  255.   m.write("Double click the buttons")
  256.   m.setCursorPos(1,9)
  257.   m.write("Work In Progress - - - Owners not held responsible")
  258.   m.setBackgroundColor(colors.lime)
  259.     for x = 10, 20 do
  260.       for y = 12, 16 do
  261.         m.setCursorPos(x, y)
  262.         m.write(" ")
  263.     end
  264.    end
  265.  m.setBackgroundColor(colors.red)
  266.    for x = 30, 40 do
  267.      for y = 12, 16 do
  268.        m.setCursorPos(x, y)
  269.        m.write(" ")
  270.      end
  271.    end
  272. end
  273.  
  274.     --Tables and executables
  275.  
  276. local redGrnButtons ={
  277.  [1] = {buttonType = 1, startX = 10, endX = 20, startY = 12, endY = 16, buttonText = "GO!", command = grnButton},
  278.  [2] = {buttonType = 1, startX = 30, endX = 40, startY = 12, endY = 16, buttonText = "NO", command = redButton}
  279. }
  280.  
  281. local tutorialButton ={
  282.  [1] = {buttonType = 1, startX = 20, endx = 30, startY = 12, endY = 16, buttonText = "#", command = oneWither
  283. }
  284.  
  285. --local witherNum ={
  286.  --[1] = {buttonType = 1, startX = 20, endX = 30, startY = 12, endY = 16, buttonText = "1", command = oneWither},
  287. --}
  288.    
  289. local function buttonMenu(table)
  290.  for k,v in ipairs(table) do
  291.   m.setCursorPos(table[k].startX, table[k].startY)
  292.  end
  293.  while running do
  294.   for k,v in ipairs(table) do
  295.    event, button, x, y = os.pullEvent()
  296.    if event == "monitor_touch" then
  297.     if x >= table[k].startX and x <= table[k].endX and y >= table[k].startY and y <= table[k].endY then
  298.       table[k].command()
  299.     end
  300.    end
  301.   end
  302.   return
  303.  end
  304.  m.clear()
  305. end
  306.  
  307. -- end of functions list
  308.  
  309. m.clear()
  310. WelcomeScreen()
  311. os.sleep(1.5)
  312.  
  313. local event = (os.pullEvent())
  314.   if event == "monitor_touch" then
  315.     screenTwo()
  316.     buttonMenu(redGrnButtons)
  317.     --buttonMenu(witherNum)
  318.   end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement