Guest User

startup

a guest
Jun 4th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.23 KB | None | 0 0
  1. --Welcome to the Mainframe edit
  2.  
  3. --This program was written by me, Barlender
  4.  
  5. --Functions
  6.  
  7. function boot()
  8.  
  9.   term.setBackgroundColor(colors.black)
  10.   term.setTextColor(colors.blue)
  11.   term.clear()
  12.   term.setCursorPos(1,1)
  13.  
  14.   print("Welcome to the Barlender OS 1.0!")
  15.   print("Starting Up")
  16.  
  17.   term.setCursorPos(12,2)
  18.   textutils.slowPrint(".....................")
  19.  
  20.   term.setTextColor(colors.green)
  21.   term.setCursorPos(1,5)
  22.   print("001010101010010010010101111110000010100001110101110")
  23.   sleep(.1)
  24.   print("111010000110101110101011001010111010100011010101011")
  25.   sleep(.1)
  26.   print("010110011010110101001100101101000111011010101000100")
  27.   sleep(.1)
  28.   print("100010101101101101010010110101100011010101110010111")
  29.   sleep(.1)
  30.   print("101010101101000110111011101000101101010001110001100")
  31.   sleep(.1)
  32.   print("101010010101010101000100101010011101111101010101010")
  33.   sleep(.1)
  34.   print("001010101010110010101101110101001010100101001101110")
  35.   sleep(.1)
  36.   print("100001111101010100101110101101001101011010101110010")
  37.   sleep(.1)
  38.   print("001010101011010111101010101101010101110100110110101")
  39.   sleep(.1)
  40.   print("100101000101110110010101111000101000101001110101011")
  41.   sleep(.1)
  42.   print("010101101101101010011101010010010010000101101000111")
  43.   sleep(.1)
  44.   print("010101011011101000011100000101010111100100110100111")
  45.   sleep(.1)
  46.   print("001110110111010101000101011010111010101011100101001")
  47.   sleep(.1)
  48.   print("011101111010111110111101010011110101010101000111010")
  49.   sleep(1)
  50. end
  51.  
  52.  
  53.  
  54. function QR()
  55.  term.setCursorPos(4,16)
  56.  term.setBackgroundColor(colors.red)
  57.  term.setTextColor(colors.black)
  58.  print("Q")
  59.  
  60.  term.setCursorPos(6,16)
  61.  term.setBackgroundColor(colors.orange)
  62.  print("R")
  63.  term.setBackgroundColor(colors.blue)
  64.  term.setTextColor(colors.white)
  65. end
  66.  
  67.  
  68.  
  69. function shutdown()
  70.  
  71.  term.setBackgroundColor(colors.lightGray)
  72.  term.clear()
  73.  sleep(.2)
  74.  term.setBackgroundColor(colors.gray)
  75.  term.clear()
  76.  sleep(.2)
  77.  os.shutdown()
  78. end
  79.  
  80.  
  81.  
  82. function reboot()
  83.  
  84.   term.setBackgroundColor(colors.lightGray)
  85.   term.clear()
  86.   sleep(.2)
  87.   term.setBackgroundColor(colors.gray)
  88.   term.clear()
  89.   sleep(.2)
  90.   os.reboot()
  91. end
  92.  
  93.  
  94.  
  95. function screenPrep()
  96.  
  97.   term.setBackgroundColor(colors.blue)
  98.   term.clear()
  99.  
  100.   local borderTop = paintutils.loadImage(".borderTop")
  101.    paintutils.drawImage(borderTop,1,1)
  102.    
  103.   local borderBottom = paintutils.loadImage(".borderBottom")
  104.    paintutils.drawImage(borderBottom,1,2)
  105.  
  106.   local borderRight = paintutils.loadImage(".borderRight")
  107.    paintutils.drawImage(borderRight,3,1)
  108.    
  109.   local borderRight2 = paintutils.loadImage(".borderRight2")
  110.    paintutils.drawImage(borderRight2,3,2)
  111.    
  112.   term.setTextColor(colors.white)
  113.   term.setBackgroundColor(colors.blue)
  114. end
  115.  
  116.  
  117.  
  118. function passwordScreen()
  119.  
  120.   screenPrep()
  121.  
  122.   term.setCursorPos(20,4)
  123.   term.setBackgroundColor(colors.blue)
  124.   print("Select User:")
  125.  
  126.   QR()
  127.      
  128.   local user1 = paintutils.loadImage(".user1")
  129.    paintutils.drawImage(user1,9,6)
  130.    
  131.   local user2 = paintutils.loadImage(".user2")
  132.    paintutils.drawImage(user2,21,6)
  133.    
  134.   local user3 = paintutils.loadImage(".user3")
  135.    paintutils.drawImage(user3,33,6)
  136.  
  137. end
  138.  
  139.  
  140.  
  141. function userCheck(userslot)
  142.  
  143.   if not fs.exists("users/"..userslot) then
  144.    userCreator(userslot)
  145.  
  146.   elseif fs.exists("users/"..userstot) then
  147.    term.setCursorPos(19,4)
  148.    print("Enter Password:")
  149.   end
  150. end
  151.  
  152.  
  153.  
  154. function userCreator(userslot)
  155.  
  156.   screenPrep()
  157.    
  158.   term.setCursorPos(3,3)
  159.   textutils.slowPrint("You are creating a user under the save")
  160.   term.setCursorPos(42,3)
  161.   term.setTextColor(colors.yellow)
  162.   textutils.slowPrint("user "..userslot)
  163.   sleep(1)
  164.  
  165.   term.setTextColor(colors.white)
  166.   term.setCursorPos(3,4)
  167.   textutils.slowPrint("What would you like your username to be?")
  168.   QR()
  169.   term.setBackgroundColor(colors.blue)
  170.   term.setCursorPos(3,5)
  171.  
  172.   local function type()
  173.  
  174.    username = read()
  175.    local file = fs.open(".users/"..userslot,"w")
  176.    file.writeLine(username)
  177.    file.close()
  178.  
  179.   end
  180.  
  181.   local function click()
  182.  
  183.    event,side,x,y = os.pullEvent("mouse_click")
  184.  
  185.    while true do
  186.     if x == 4 and y == 16 then
  187.      shutdown()
  188.      break
  189.     elseif x == 6 and y ==16 then
  190.      reboot()
  191.      break
  192.     end
  193.    end
  194.   end
  195.  
  196.   parallel.waitForAny(type,click)
  197.  
  198.    
  199.   screenPrep()
  200.   QR()
  201.  
  202.   term.setCursorPos(3,3)
  203.   textutils.slowPrint("Ok then, "..username..". Would you like to")
  204.   term.setCursorPos(3,4)
  205.   textutils.slowPrint("change your profile picture?")
  206.  
  207.   term.setCursorPos(3,5)
  208.   term.setBackgroundColor(colors.green)
  209.   print("Yes")
  210.   term.setCursorPos(7,5)
  211.   term.setBackgroundColor(colors.red)
  212.   print("No")
  213.  
  214.   event,side,x,y = os.pullEvent("mouse_click")
  215.  
  216.   while true do
  217.  
  218.    if x >= 3 and x <= 5 and y == 5 then
  219.     screenPrep()
  220.     term.setCursorPos(3,3)
  221.     term.setTextColor(colors.orange)
  222.     textutils.slowPrint("Please only paint within the blue box")
  223.     sleep(1.5)
  224.     shell.run("paint .user"..userslot)
  225.     userCreator2()
  226.    
  227.    elseif x >= 7 and x <= 8 and y == 5 then
  228.     userCreator2()
  229.    
  230.    elseif x == 4 and y == 16 then
  231.     shutdown()
  232.    
  233.    elseif x == 6 and y == 16 then
  234.     reboot()
  235.    end
  236.   end
  237. end
  238.  
  239.  
  240.  
  241. function userCreator2()
  242.  
  243.   screenPrep()
  244.   QR()
  245.  
  246.   term.setCursorPos(3,3)
  247.   textutils.slowPrint("Would you like to set a password?")
  248.   term.setCursorPos(3,4)
  249.   term.setBackgroundColor(colors.green)
  250.   print("Yes")
  251.   term.setCursorPos(7,4)
  252.   term.setBackgroundColor(colors.red)
  253.   print("No")
  254.  
  255.   event,side,x,y = os.pullEvent("mouse_click")
  256.  
  257.   if x >= 3 and x <= 5 and y == 4 then
  258.  
  259.    local function passwordMaker()
  260.    
  261.     term.setCursorPos(3,3)
  262.     term.setBackgroundColor(colors.blue)
  263.     textutils.slowPrint("What would you like your password to be?")
  264.     term.setCursorPos(3,4)
  265.     local password = read()
  266.    
  267.     screenPrep()
  268.     QR()
  269.     term.setCursorPos(3,3)
  270.     textutils.slowPrint("Please re-enter your password")
  271.     term.setCursorPos(3,4)
  272.     local passwordCheck = read()
  273.    
  274.      if password == passwordCheck then
  275.       screenPrep()
  276.       QR()
  277.       term.setCursorPos(3,3)
  278.       textutils.slowPrint("Correct")
  279.       sleep(1)
  280.       reboot()
  281.  
  282.      else
  283.       screenPrep()
  284.       term.setCursorPos(3,3)
  285.       textutils.slowPrint("Password doesn't match")
  286.       sleep(1)
  287.       passwordMaker()
  288.      end
  289.    end
  290.    
  291.    passwordMaker()
  292.    
  293.   elseif x >= 7 and x <= 8 and y == 4 then
  294.    
  295.   elseif x == 4 and y == 16 then
  296.    shutdown()
  297.    
  298.   elseif x == 6 and y == 16 then
  299.    reboot()
  300.   end
  301. end
  302.  
  303.  
  304.  
  305. function barlenderScreen()
  306.  
  307.   term.clear()
  308.   screenPrep()
  309.  
  310.   local user1 = paintutils.loadImage(".user1")
  311.    paintutils.drawImage(user1,21,6)
  312.    
  313.   term.setCursorPos(19,4)
  314.   term.setBackgroundColor(colors.blue)
  315.   print("Enter Password:")
  316.  
  317.   term.setCursorPos(22,14)
  318.   term.setBackgroundColor(colors.blue)
  319.   term.setTextColor(colors.white)
  320.   guess = read("*")
  321.  
  322.   if "sumc" == guess then
  323.    term.setBackgroundColor(colors.white)
  324.    term.clear()
  325.    local check = paintutils.loadImage(".check")
  326.     paintutils.drawImage(check,1,4)
  327.    sleep(1)
  328.    term.setBackgroundColor(colors.lightGray)
  329.    term.clear()
  330.    sleep(.1)
  331.    term.setBackgroundColor(colors.gray)
  332.    term.clear()
  333.    sleep(.1)
  334.    term.setBackgroundColor(colors.lightGray)
  335.    term.clear()
  336.    sleep(.1)
  337.    menuSkin()
  338.    menu1()
  339.    options1()
  340.    
  341.   else
  342.    passwordScreen()
  343.    password()
  344.    term.setCursorPos(11,15)
  345.    term.setTextColor(colors.red)
  346.    print("Nope.")
  347.   end
  348. end
  349.  
  350.  
  351.  
  352. function password()
  353.  
  354.   event,side,x,y = os.pullEvent("mouse_click")
  355.  
  356.   if x >= 10 and x <= 17 and y >= 7 and y <= 12 then
  357.    userCheck("1")
  358.    
  359.   elseif x >= 22 and x <= 29 and y >= 7 and y <= 12 then
  360.    userCheck("2")
  361.    
  362.   elseif x >= 34 and x <= 41 and y >= 7 and y <= 12 then
  363.    userCheck("3")
  364.    
  365.   elseif x == 4 and y == 16 then
  366.    shutdown()
  367.    
  368.   elseif x == 6 and y == 16 then
  369.    reboot()
  370.  
  371.   else
  372.    passwordScreen()
  373.    password()
  374.   end
  375. end
  376.    
  377.    
  378.    
  379. function menuSkin()
  380.  
  381.   term.setBackgroundColor(colors.blue)
  382.   term.clear()
  383.  
  384.   local menu1 = paintutils.loadImage(".menu1")
  385.    paintutils.drawImage(menu1,1,1)
  386.  
  387.   local menu2 = paintutils.loadImage(".menu2")
  388.    paintutils.drawImage(menu2,3,1)
  389.      
  390.   local menu3 = paintutils.loadImage(".menu3")
  391.    paintutils.drawImage(menu3,1,2)
  392.  
  393.   local menu4 = paintutils.loadImage(".menu4")
  394.    paintutils.drawImage(menu4,3,2)
  395.    
  396.   local sumc = paintutils.loadImage(".sumc")
  397.    paintutils.drawImage(sumc,32,8)
  398.    
  399.   QR()
  400.  
  401. end
  402.  
  403.  
  404.  
  405. function menu1()
  406.  
  407.   term.setCursorPos(3,7)
  408.   term.setBackgroundColor(colors.blue)
  409.   term.setTextColor(colors.white)
  410.   print("Function Menu")
  411.   term.setCursorPos(3,8)
  412.   term.setTextColor(colors.orange)
  413.   print("Program Edit Menu")
  414.   term.setCursorPos(3,9)
  415.   term.setTextColor(colors.purple)
  416.   print("Enter Console")
  417.   term.setCursorPos(3,10)
  418.   term.setTextColor(colors.brown)
  419.   print("Reboot Mainframe")
  420.   term.setCursorPos(3,11)
  421.   term.setTextColor(colors.black)
  422.   print("Shut Down Mainframe")
  423.   term.setTextColor(colors.white)
  424.   term.setCursorPos(34,4)
  425.   print("The  Mainframe")
  426. end
  427.  
  428.  
  429.  
  430. function options1()
  431.  
  432.  event,side,x,y = os.pullEvent("mouse_click")
  433.  
  434.  if x > 3 and x < 30 and y == 7 then
  435.   menuSkin()
  436.   menu2()
  437.   options2()
  438.  
  439.  elseif x > 3 and x < 30 and y == 8 then
  440.   menuSkin()
  441.   menu3()
  442.   options3()
  443.  
  444.  elseif x > 3 and x < 30 and y == 9 then
  445.   term.setCursorPos(1,1)
  446.   term.setBackgroundColor(colors.black)
  447.   term.setTextColor(colors.yellow)
  448.   term.clear()
  449.   print("CraftOS 1.7")
  450.   term.setCursorPos(1,2)
  451.  
  452.  elseif x == 4 and y == 16 then
  453.   shutdown()
  454.  
  455.  elseif x == 6 and y == 16 then
  456.   reboot()
  457.    
  458.  else
  459.   menuSkin()
  460.   menu1()
  461.   options1()
  462.  end
  463. end
  464.  
  465.  
  466.  
  467. function menu2()
  468.  
  469.   term.setCursorPos(3,4)
  470.   term.setBackgroundColor(colors.blue)
  471.   term.setTextColor(colors.white)
  472.   print("Launch Todo")
  473.   term.setCursorPos(3,5)
  474.   print("Open Hidden Door (5 Sec.)")
  475.   term.setCursorPos(3,6)
  476.   print(" ")
  477.   term.setCursorPos(3,7)
  478.   print(" ")
  479.   term.setCursorPos(3,8)
  480.   print(" ")
  481.   term.setCursorPos(3,9)
  482.   print(" ")
  483.   term.setCursorPos(3,10)
  484.   print(" ")
  485.   term.setCursorPos(3,11)
  486.   print(" ")
  487.   term.setCursorPos(3,12)
  488.   print(" ")
  489.   term.setCursorPos(3,13)
  490.   print(" ")
  491.   term.setCursorPos(3,14)
  492.   print(" ")
  493.   term.setCursorPos(3,15)
  494.   print(" ")
  495.   term.setCursorPos(3,16)
  496.   print("13= Return to main menu")
  497.   term.setCursorPos(34,4)
  498.   print("Function  Menu")
  499. end
  500.  
  501.  
  502.  
  503. function options2()
  504.  
  505.   event,side,x,y = os.pullEvent("mouse_click")
  506.  
  507.   if x > 3 and x < 30 and y == 4  then
  508.    term.clear()
  509.    menuSkin()
  510.    menu2()
  511.    term.setBackgroundColor(colors.white)
  512.    term.setTextColor(colors.orange)
  513.    term.setCursorPos(6,17)
  514.    shell.run("monitor top todo")
  515.    term.setTextColor(colors.green)
  516.    term.setCursorPos(45,4)
  517.    options2()
  518.  
  519.   elseif x > 3 and x < 30 and y == 5 then
  520.    term.clear()
  521.    menuSkin()
  522.    menu2()
  523.    term.setCursorPos(4,17)
  524.    term.setBackgroundColor(colors.white)
  525.    term.setTextColor(colors.orange)
  526.    term.setCursorPos(6,17)
  527.    print("OPENING THE DOOOOOOR!")
  528.    rs.setOutput("back", true)
  529.    sleep(5)
  530.    term.setCursorPos(7,17)
  531.    term.clearLine()
  532.    rs.setOutput("back", false)
  533.    menuSkin()
  534.    menu2()
  535.    options2()
  536.  
  537.   elseif x > 3 and x < 30 and y == 16 then
  538.    menuSkin()
  539.    menu1()
  540.    options1()
  541.    
  542.   elseif x == 4 and y == 16 then
  543.    shutdown()
  544.    
  545.   elseif x == 6 and y == 16 then
  546.    reboot()
  547.  
  548.   else
  549.    menuSkin()
  550.    menu2()
  551.    options2()  
  552.  end
  553. end
  554.  
  555. function menu3()
  556.  
  557.   term.setBackgroundColor(colors.blue)
  558.   term.setTextColor(colors.white)
  559.  
  560.   term.setCursorPos(3,4)
  561.   print("Edit Todo")
  562.   term.setCursorPos(3,5)
  563.   print("Edit Startup (Mainframe)")
  564.   term.setCursorPos(3,6)
  565.   print(" ")
  566.   term.setCursorPos(3,7)
  567.   print(" ")
  568.   term.setCursorPos(3,8)
  569.   print(" ")
  570.   term.setCursorPos(3,9)
  571.   print(" ")
  572.   term.setCursorPos(3,10)
  573.   print(" ")
  574.   term.setCursorPos(3,11)
  575.   print(" ")
  576.   term.setCursorPos(3,12)
  577.   print(" ")
  578.   term.setCursorPos(3,13)
  579.   print(" ")
  580.   term.setCursorPos(3,14)
  581.   print(" ")
  582.   term.setCursorPos(3,15)
  583.   print(" ")
  584.   term.setCursorPos(3,16)
  585.   print("13= Return to main menu")
  586.   term.setCursorPos(34,4)
  587.   print("Editing   Menu")
  588. end
  589.  
  590.  
  591.  
  592. function options3()
  593.  
  594.   event,side,x,y = os.pullEvent("mouse_click")
  595.  
  596.   if x > 3 and x < 30 and y == 4 then
  597.    edit()
  598.    shell.run("edit todo")
  599.    
  600.   elseif x > 3 and x < 30 and y == 5 then
  601.    edit()
  602.    shell.run("edit startup")
  603.    
  604.   elseif x > 3 and x < 30 and y == 16 then
  605.    menuSkin()
  606.    menu1()
  607.    options1()
  608.    
  609.   elseif x == 4 and y == 16 then
  610.    shutdown()
  611.    
  612.   elseif x == 6 and y == 16 then
  613.    reboot()
  614.    
  615.   else
  616.    menuSkin()
  617.    menu3()
  618.    options3()
  619.    
  620.   end
  621. end
  622.  
  623.  
  624.  
  625. function edit()
  626.   term.clear()
  627.   term.setCursorPos(1,1)
  628.   term.setBackgroundColor(colors.black)
  629.   term.setTextColor(colors.white)
  630. end
  631.  
  632.  
  633.  
  634. --This Part makes sure that all of the necessary
  635. --files were installed properly, and that the
  636. --proper directories were created
  637.  
  638. function downloads()
  639.  
  640.  if not fs.isDir(".users") then
  641.   fs.makeDir(".users")
  642.  end
  643.  
  644.  if not fs.exists(".borderTop") then
  645.   term.setCursorPos(1,1)
  646.   shell.run("pastebin get", "ufqw3Cay", ".borderTop")
  647.   term.clear()
  648.  end
  649.  
  650.  if not fs.exists(".borderBotton") then
  651.   term.setCursorPos(1,1)
  652.   shell.run("pastebin get", "Ze8fQAuq", ".borderBottom")
  653.   term.clear()
  654.  end
  655.  
  656.  if not fs.exists(".borderRight") then
  657.   term.setCursorPos(1,1)
  658.   shell.run("pastebin get", "eitEekZK", ".borderRight")
  659.  end
  660.  
  661.  if not fs.exists(".borderRight2") then
  662.   term.setCursorPos(1,1)
  663.   shell.run("pastebin get", "NCf53j8k", ".borderRight2")
  664.  end
  665.  
  666.  if not fs.exists(".check") then
  667.   term.setCursorPos(1,1)
  668.   shell.run("pastebin get", "bYbPeB3V", ".check")
  669.   term.clear()
  670.  end
  671.  
  672.  if not fs.exists(".user1") then
  673.   term.setCursorPos(1,1)
  674.   shell.run("pastebin get", "UmxbJuEx", ".user1")
  675.   term.clear()
  676.  end
  677.  
  678.  if not fs.exists(".user2") then
  679.   term.setCursorPos(1,1)
  680.   shell.run("cp ", ".user1 ", ".user2")
  681.   term.clear()
  682.  end
  683.  
  684.  if not fs.exists(".user3") then
  685.   term.setCursorPos(1,1)
  686.   shell.run("cp ", ".user2 ", ".user3")
  687.   term.clear()
  688.  end
  689. end
  690. --Actual program begins here
  691.  
  692. downloads()
  693. boot()
  694. passwordScreen()
  695. password()
Add Comment
Please, Sign In to add comment