Advertisement
DustinRosebery

startup charlie 1

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