Guest User

witherTest

a guest
Sep 1st, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.64 KB | None | 0 0
  1.  
  2.  
  3. m = peripheral.wrap("left")
  4. mBack = peripheral.wrap("back")
  5.  
  6. local running = true
  7.  
  8. --local printCenter = function(text, side)
  9.  --local monitor = peripheral.wrap(side)
  10.  --local maxw, maxh = monitor.getSize()
  11.  --local curx, cury = monitor.getCursorPos()
  12.  
  13.  --monitor.setCursorPos((maxw-#text)/2,cury)
  14.  --monitor.write(text)
  15.  --monitor.setCursorPos(curx,cury+1)
  16. --end
  17.  
  18. --local maxw, maxh = m.getSize()
  19. --m.setCursorPos(1,math.floor(maxh/2))       reference sets to top middle line
  20.  
  21.      -- Button Functions
  22.  
  23. local function grnButton()      --Accept Arena challenge button
  24.  m.setBackgroundColor(colors.black)
  25.  m.clear()
  26.  m.setTextScale(1)
  27.  m.setCursorPos(1,1)
  28.  term.redirect(m)
  29.    print("Touch green button at any point to skip tutorial")
  30.  term.restore()
  31.  m.setCursorPos(1,3)
  32.  term.redirect(m)
  33.    textutils.slowPrint("Welcome to the Arena")
  34.    os.sleep(5)
  35.    m.setCursorPos(1,3)
  36.    m.clearLine()
  37.    os.sleep(1)
  38.    m.clear()  
  39.    m.setCursorPos(1,1)
  40.    m.clear()
  41.    print("This tutorial explains what you will need to do to safely battle the wither in our base \n")
  42.    os.sleep(5)
  43.    m.clear()
  44.    m.setCursorPos(1,1)
  45.    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")
  46.    os.sleep(5)
  47.    m.clear()
  48.    m.setCursorPos(1,1)
  49.    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")
  50.    os.sleep(5)
  51.    m.clear()
  52.    m.setCusorPos(1,1)
  53.    print("After you say the command in worldchat the blastshield will activate and the wither will start to be constructed \n")
  54.    os.sleep(5)
  55.    m.clear()
  56.    m.setCursorPos(1,1)
  57.    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")
  58.    os.sleep(5)
  59.    m.clear()
  60.    m.setCurosrPos()
  61.    print("In the very real case of a player death the force field will finish the job. Good Luck soldier... \n")
  62.    term.restore()
  63. end      
  64.  
  65.  
  66. local function redButton()      --Dont Accept Arena Challenge
  67.  m.clear()
  68.  m.setTextScale(5)
  69.  m.setCursorPos(2,2)
  70.  m.setTextColor(colors.red)
  71.  m.write("LOSER")
  72.  os.sleep(10)
  73.  os.reboot()
  74. end
  75.  
  76. local function goRep()          -- flashes go on the screen
  77.  m.setTextScale(10)
  78.  m.setCursorPos(2,2)
  79.  m.write("GO!")
  80.  os.sleep(1)
  81.  m.clear()
  82.  os.sleep(0.5)
  83. end
  84.  
  85. local function oneWither()      --One Wither has been selected
  86.  m.setBackgroundColor(colors.black)
  87.  m.clear()
  88.  m.setTextScale(5)
  89.  m.setTextColor(colors.lime)
  90.  m.setCursorPos(5,2)
  91.  m.write("5")
  92.  os.sleep(1)
  93.  m.clear()
  94.  m.setCursorPos(5,2)
  95.  m.write("4")
  96.  os.sleep(1)
  97.  m.clear()
  98.  m.setCursorPos(5,2)
  99.  m.write("3")
  100.  os.sleep(1)
  101.  m.clear()
  102.  m.setCursorPos(5,2)
  103.  m.write("2")
  104.  os.sleep(1)
  105.  m.clear()
  106.  m.setCursorPos(5,2)
  107.  m.write("1")
  108.  os.sleep(1)
  109.  m.clear()
  110.  
  111.  platOneBroadcastOn()
  112.  
  113.  goRep()
  114.  goRep()
  115.  goRep()
  116.  
  117. end
  118.  
  119.     --Broadcasts
  120.  
  121. local function platOneBroadcastOn()
  122.   rednet.open("top")
  123.   rednet.broadcast("platOneOn")
  124.   print("First Layer")
  125.   rednet.close("top")
  126. end
  127.  
  128.     --Tables and executables
  129.  
  130. local redGrnButtons ={
  131.  [1] = {buttonType = 1, startX = 10, endX = 20, startY = 12, endY = 16, buttonText = "GO!", command = grnButton},
  132.  [2] = {buttonType = 1, startX = 30, endX = 40, startY = 12, endY = 16, buttonText = "NO", command = redButton}
  133. }
  134.  
  135. local witherNum ={
  136.  [1] = {buttonType = 1, startX = 10, endX = 20, startY = 12, endY = 16, buttonText = "1", command = oneWither},
  137.  [2] = {buttinType = 1, startX = 30, endX = 40, startY = 12, endY = 16, buttonText = "2", command = twoWither}
  138. }
  139.  
  140. local function buttonMenu(table)
  141.  for k,v in ipairs(table) do
  142.   m.setCursorPos(table[k].startX, table[k].startY)
  143.  end
  144.  while running do
  145.   for k,v in ipairs(table) do
  146.    event, button, x, y = os.pullEvent()
  147.    if event == "monitor_touch" then
  148.     if x >= table[k].startX and x <= table[k].endX and y >= table[k].startY and y <= table[k].endY then
  149.       table[k].command()
  150.     end
  151.    end
  152.   end
  153.   return
  154.  end
  155.  m.clear()
  156. end
  157.  
  158.     --Monitor screens
  159.    
  160. local function WelcomeScreen()
  161.   m.clear()
  162.   m.setBackgroundColor(colors.black)
  163.   m.setTextScale(4)
  164.   m.setCursorPos(0,1)
  165.   m.setTextColor(colors.lime)
  166.   m.write(" Welcome")
  167.   m.setCursorPos(5,3)
  168.   m.setTextColor(colors.yellow)
  169.   m.write("to the")
  170.   m.setCursorPos(8,5)
  171.   m.setTextColor(colors.red)
  172.   m.write("ARENA!")
  173. end
  174.  
  175. local function screenTwo()
  176.   m.clear()
  177.   m.setBackgroundColor(colors.black)
  178.   m.setTextScale(1)
  179.   m.setCursorPos(9,1)
  180.   m.setTextColor(colors.white)
  181.   m.write("Welcome to HDbag's Wither Arena!!!")
  182.   m.setCursorPos(4,2)
  183.   m.write("Co-Hosting IPJ and the boss of the underworld")
  184.   m.setCursorPos(8,5)
  185.   m.write("simply push the green button to start")
  186.   m.setCursorPos(11,6)
  187.   m.write("Or push the red button to stop")
  188.   m.setCursorPos(13,7)
  189.   m.write("Double click the buttons")
  190.   m.setCursorPos(1,9)
  191.   m.write("Work In Progress - - - Owners not held responsible")
  192.   m.setBackgroundColor(colors.lime)
  193.     for x = 10, 20 do
  194.       for y = 12, 16 do
  195.         m.setCursorPos(x, y)
  196.         m.write(" ")
  197.     end
  198.    end
  199.  m.setBackgroundColor(colors.red)
  200.    for x = 30, 40 do
  201.      for y = 12, 16 do
  202.        m.setCursorPos(x, y)
  203.        m.write(" ")
  204.      end
  205.    end
  206. end
  207.  
  208. -- end of functions list
  209.  
  210. m.clear()
  211. WelcomeScreen()
  212. os.sleep(1.5)
  213.  
  214. local event = (os.pullEvent())
  215.   if event == "monitor_touch" then
  216.     screenTwo()
  217.     buttonMenu(redGrnButtons)
  218.     buttonMenu(witherNum)
  219.   end
Advertisement
Add Comment
Please, Sign In to add comment