Advertisement
joshgreatuk

LUAOS Startup 0.2.2 Indev

Jul 24th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.72 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. function ac1(eid,t)
  3.     term.clear()
  4.     paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  5.     paintutils.drawBox(1,1,51,19,colors.blue)
  6.     term.setBackgroundColor(colors.lightBlue)
  7.     term.setCursorPos(3,3)
  8.     print("Please type an ID to create or type exit")
  9.     term.setCursorPos(3,5)
  10.     print("ID:")
  11.     term.setCursorPos(6,5)
  12.     nid = read()
  13.     if nid == "exit" then
  14.         ac(eid,t)
  15.     end
  16.     term.setCursorPos(3,7)
  17.     fs.makeDir("/LUAOS/S/Users/"..nid)
  18.     term.setCursorPos(3,9)
  19.     print("Now type a username and password")
  20.     term.setCursorPos(3,11)
  21.     print("Username:")
  22.     term.setCursorPos(12,11)
  23.     nu = read()
  24.     term.setCursorPos(3,13)
  25.     print("Password:")
  26.     term.setCursorPos(12,13)
  27.     np = read()
  28.     f = fs.open("/LUAOS/S/Users/"..nid.."/u","w")
  29.     f.write(nu)
  30.     f.close()
  31.     f = fs.open("/LUAOS/S/Users/"..nid.."/p","w")
  32.     f.write(np)
  33.     f.close()
  34.     term.setCursorPos(3,15)
  35.     print("finally time to enter the user's")
  36.     term.setCursorPos(3,16)
  37.     print("level of permission (a / n)")
  38.     term.setCursorPos(3,18)
  39.     print("Permission level:")
  40.     term.setCursorPos(20,18)
  41.     nt = read()
  42.     if not nt == "a" and not nt == "n" then
  43.         term.clear()
  44.         paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  45.         paintutils.drawBox(1,1,51,19,colors.blue)
  46.         term.setBackgroundColor(colors.lightBlue)
  47.         term.setCursorPos(3,3)
  48.         print("invalid permission level")
  49.         sleep(5)
  50.         ac(eid,t)
  51.     end
  52.     f= fs.open("/LUAOS/S/Users/"..nid.."/t","w")
  53.     f.write(nt)
  54.     f.close()
  55.     term.clear()
  56.     paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  57.     paintutils.drawBox(1,1,51,19,colors.blue)
  58.     term.setBackgroundColor(colors.lightBlue)
  59.     term.setCursorPos(3,3)
  60.     print("Account created")
  61.     sleep(5)
  62.     ac(eid,t)
  63. end
  64. function ac2(eid,t)
  65.     term.clear()
  66.     paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  67.     paintutils.drawBox(1,1,51,19,colors.blue)
  68.     term.setBackgroundColor(colors.lightBlue)
  69.     term.setCursorPos(3,3)
  70.     print("enter an ID to delete")
  71.     term.setCursorPos(3,5)
  72.     print("ID:")
  73.     term.setCursorPos(6,5)
  74.     did = read()
  75.     did1 = "/LUAOS/S/Users/"..did
  76.     if not fs.exists(did1) then
  77.         term.setCursorPos(3,7)
  78.         print("Invalid ID")
  79.         sleep(5)
  80.         ac(eid,t)
  81.     end
  82.     fs.delete(did1)
  83.     term.clear()
  84.     paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  85.     paintutils.drawBox(1,1,51,19,colors.blue)
  86.     term.setBackgroundColor(colors.lightBlue)
  87.     term.setCursorPos(3,3)
  88.     print("Account deleted")
  89.     sleep(5)
  90.     ac(eid,t)
  91. end
  92. function fb(eid,t)
  93.  dir = "/LUAOS/C/"
  94.     term.clear()
  95.     term.setCursorPos(1,1)
  96.     print("directory:",dir)
  97.     print("type a command")
  98.     cmd = read()
  99.     if cmd == "cd" then
  100.         print("enter a directory to go to")
  101.         ed = read()
  102.         if not fs.exists(ed) then
  103.           print("directory not found")
  104.           fb()
  105.         end
  106.     dir = ed
  107.     fb()
  108.     else if cmd == "ls" then
  109.         local filelist = fs.list(dir)
  110.         for _, file in ipairs(filelist) do
  111.           print(file)
  112.      end
  113.         fb()
  114.     else if cmd == "exit" then
  115.         li(eid,t)
  116.     else
  117.         print("invalid command")
  118.         fb()
  119.     end
  120.     end
  121.     end
  122. end
  123. function ac(eid,t)
  124.   term.clear()
  125.   paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  126.   paintutils.drawBox(1,1,51,19,colors.blue)
  127.   term.setBackgroundColour(colors.lightBlue)
  128.   local x1, y1 = 3,5
  129.   local x2, y2 = 3,7
  130.   local x3, y3 = 3,9
  131.   local choice1 = " Add Account    "
  132.   local choice2 = " Delete Account "
  133.   local choice3 = " Exit           "
  134.   term.setCursorPos(3,3)
  135.   print("Welcome to LUAOS account control")
  136.   term.setBackgroundColor(colors.red)
  137.   term.setCursorPos(x1,y1)
  138.   write(choice1)
  139.   term.setCursorPos(x2,y2)
  140.   write(choice2)
  141.   term.setCursorPos(x3,y3)
  142.   write(choice3)
  143.   while true do
  144.     local event, button, cx, cy = os.pullEvent()
  145.     if event == "mouse_click" then
  146.       if cx >= x1 and cx < choice1:len() and cy == y1 and button == 1 then
  147.         term.clear()
  148.         ac1(eid,t)
  149.         break
  150.       end
  151.       if cx >= x2 and cx < choice2:len() and cy == y2 and button == 1 then
  152.         term.clear()
  153.         ac2(eid,t)
  154.         break
  155.       end
  156.       if cx >= x3 and cx < choice3:len() and cy == y3 and button == 1 then
  157.         term.clear()
  158.         li(eid,t)
  159.         break
  160.       end
  161.     end
  162.   end
  163. end
  164. function ud(v,eid,t)
  165.   term.clear()
  166.   term.setCursorPos(3,3)
  167.   paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  168.   paintutils.drawBox(1,1,51,19,colors.blue)
  169.   print("LUAOS version:", v)
  170.   shell.run("pastebin get AC6USdEP version")
  171.   f = fs.open("/version", "r")
  172.   nv = tonumber(f.readAll())
  173.   f.close()
  174.   term.setCursorPos(3,4)
  175.   print("the newest version of LUAOS is:", nv)
  176.   sleep(3)
  177.   if nv > v then
  178.     u = y
  179.   else
  180.     u = n
  181.   end
  182.   if u == "y" then
  183.     term.CursorPos(3,5)
  184.     print("updating now")
  185.     shell.run("pastebin get WnjNK63g version1")
  186.     f = fs.open("/version1", "r")
  187.     pb = f.readAll()
  188.     f.close()
  189.     shell.run("pastebin get ", pb, " LUAOSinstall")
  190.     dofile("/LUAOSinstall")
  191.   else
  192.    
  193.     print("your version of LUAOS is up to date")
  194.     sleep(5)
  195.     li(eid, t)
  196.   end
  197. end
  198. function li(eid,t)
  199.   term.clear()
  200.   paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  201.   paintutils.drawBox(1,1,51,19,colors.blue)  
  202.   term.setBackgroundColor(colors.lightBlue)
  203.   term.setCursorPos(4,3)
  204.   print("Welcome to the LUAOS Indev 0.2.2 Menu")
  205.   local x1, y1 = 4,5
  206.   local x2, y2 = 4,7
  207.   local x3, y3 = 4,9
  208.   local x4, y4 = 4,11
  209.   local x5, y5 = 4,13
  210.   local x6, y6 = 4,15
  211.   local choice1 = " Shutdown        "
  212.   local choice2 = " Restart         "
  213.   local choice3 = " Sign Out        "
  214.   local choice4 = " File Browser    "
  215.   local choice5 = " Account Control "
  216.   local choice6 = " Update          "
  217.   term.setBackgroundColor(colors.red)
  218.   term.setCursorPos(x1,y1)
  219.   write(choice1)
  220.   term.setCursorPos(x2,y2)
  221.   write(choice2)
  222.   term.setCursorPos(x3,y3)
  223.   write(choice3)
  224.   term.setCursorPos(x4,y4)
  225.   write(choice4)
  226.   term.setCursorPos(x5,y5)
  227.   write(choice5)
  228.   term.setCursorPos(x6,y6)
  229.   write(choice6)
  230.   while true do
  231.     local event, button, cx, cy = os.pullEvent()
  232.     if event == "mouse_click" then
  233.       if cx >= x1 and cx < choice1:len() and cy == y1 and button == 1 then
  234.         os.shutdown()
  235.         break
  236.       else if cx >= x2 and cx < choice2:len() and cy == y2 and button == 1 then
  237.         os.reboot()
  238.         break
  239.       else if cx >= x3 and cx < choice3:len() and cy == y3 and button == 1 then
  240.         boot()
  241.         break
  242.       else if cx >= x4 and cx < choice4:len() and cy == y4 and button == 1 then
  243.         fb(eid,t)
  244.         break
  245.       else if cx >= x5 and cx < choice5:len() and cy == y5 and button == 1 then
  246.         ac(eid,t)
  247.         break
  248.       else if cx >= x6 and cx < choice6:len() and cy == y6 and button == 1 then
  249.         v = "0.22"
  250.         ud(v,eid,t)
  251.         break
  252.       end
  253.       end
  254.       end
  255.       end
  256.       end
  257.       end
  258.     end
  259.   end
  260. end
  261. function uc1()
  262.   term.clear()
  263.   paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  264.   paintutils.drawBox(1,1,51,19,colors.blue)
  265.   term.setTextColor(colors.white)
  266.   term.setCursorPos(3,3)
  267.   print("welcome to the LUAOS first user setup")
  268.   term.setCursorPos(3,4)
  269.   print("your first user will be an administrator")
  270.   term.setCursorPos(3,5)
  271.   print("administrators can edit and add users")
  272.   term.setCursorPos(3,6)
  273.   print("while normal users cant, administrators")
  274.   term.setCursorPos(3,7)
  275.   print("can also install apps onto the PC but")
  276.   term.setCursorPos(3,8)
  277.   print("normal users also can if they have their")
  278.   term.setCursorPos(3,9)
  279.   print("administrators password.")
  280.   term.setCursorPos(3,10)
  281.   print("press enter to create your account.")
  282.   back = read()
  283.   term.clear()
  284.   term.setCursorPos(3,3)
  285.   print("now to make your administrator account")
  286.   term.setCursorPos(3,5)
  287.   print("Username:")
  288.   term.setCursorPos(3,6)
  289.   print("Password:")
  290.   term.setCursorPos(12,5)
  291.   nu = read()
  292.   term.setCursorPos(12,6)
  293.   np = read("*")
  294.   fs.makeDir("/LUAOS/S/Users/1")
  295.   f = fs.open("/LUAOS/S/Users/1/u", "w")
  296.   f.write(nu)
  297.   f.close()
  298.   f = fs.open("/LUAOS/S/Users/1/p", "w")
  299.   f.write(np)
  300.   f.close()
  301.   f = fs.open("/LUAOS/S/Users/1/t", "w")
  302.   f.write("a")
  303.   f.close()
  304.   term.setCursorPos(3,8)
  305.   print("Your new account has been made!")
  306.   term.setCursorPos(3,9)
  307.   print("Restarting now!")
  308.   sleep(5)
  309.   os.reboot()
  310. end
  311. function boot()
  312.   term.clear()
  313.   if not fs.exists("LUAOS/S/Users/1") then
  314.     uc1()
  315.   end
  316.   paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  317.   paintutils.drawBox(1,1,51,19,colors.blue)
  318.   term.setTextColor(colors.white)
  319.   term.setBackgroundColor(colors.lightBlue)
  320.   term.setCursorPos(3,3)
  321.   print("welcome to LUAOS login")
  322.   term.setCursorPos(3,6)
  323.   print("enter your ID to contine")
  324.   term.setCursorPos(3,9)
  325.   eid = read()
  326.   if not fs.exists("LUAOS/S/Users/"..eid) then
  327.     term.clear()
  328.     paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  329.     paintutils.drawBox(1,1,51,19,colors.blue)
  330.     term.setBackgroundColor(colors.lightBlue)
  331.     term.setCursorPos(3,3)
  332.     print("your ID is invalid, it may not exist")
  333.     sleep(5)
  334.     term.setCursorPos(3,5)
  335.     print("do you want to shutdown?, Y/N")
  336.     local sEvent, param = os.pullEvent("key")
  337.     if param == "49" then
  338.       os.shutdown()
  339.     else
  340.       boot()
  341.     end
  342.   else if eid == "" then
  343.     term.clear()
  344.     paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  345.     paintutils.drawBox(1,1,51,19,colors.blue)
  346.     term.setBackgroundColor(colors.lightBlue)
  347.     term.setCursorPos(3,3)
  348.     print("your ID is invalid, it may not exist")
  349.     sleep(5)
  350.     term.setCursorPos(3,5)
  351.     print("do you want to shutdown?, Y/N")
  352.     local sEvent, param = os.pullEvent("key")
  353.     if param == "49" then
  354.       os.shutdown()
  355.     else
  356.       boot()
  357.     end
  358.   end
  359.   end
  360.   term.clear()
  361.   paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  362.   paintutils.drawBox(1,1,51,19,colors.blue)
  363.   term.setBackgroundColor(colors.lightBlue)
  364.   term.setCursorPos(3,3)
  365.   print("now login to your account")
  366.   term.setCursorPos(3,6)
  367.   print("username:")
  368.   term.setCursorPos(3,8)
  369.   print("password:")
  370.   term.setCursorPos(12,6)
  371.   eu = read()
  372.   term.setCursorPos(12,8)
  373.   ep = read("*")
  374.   dir1 = "/LUAOS/S/Users/"..eid.."/u"
  375.   dir2 = "/LUAOS/S/Users/"..eid.."/p"
  376.   dir3 = "/LUAOS/S/Users/"..eid.."/t"
  377.   fu = fs.open(dir1,"r")
  378.   ru = fu.readAll()
  379.   fu.close()
  380.   fp = fs.open(dir2,"r")
  381.   rp = fp.readAll()
  382.   fp.close()
  383.   ft = fs.open(dir3,"r")
  384.   t = ft.readAll()
  385.   ft.close()
  386.   if eu == ru and ep == rp then
  387.     term.setCursorPos(3,11)
  388.     print("welcome to LUAOS",ru)
  389.     sleep(5)
  390.     li(eid,t)
  391.   else
  392.     term.setCursorPos(3,11)
  393.     print("Incorrect username and/or password")
  394.     print("do you want to shutdown?, Y/N")
  395.     local sEvent, param = os.pullEvent("key")
  396.     if param == "49" then
  397.         os.shutdown()
  398.     else
  399.         boot()
  400.     end
  401.   end
  402. end
  403. function recovery()
  404.   term.clear()
  405.   paintutils.drawFilledBox(1,1,51,19,colors.lightBlue)
  406.   paintutils.drawBox(1,1,51,19,colors.blue)
  407.   term.setBackgroundColor(colors.lightBlue)
  408.   print("something went wrong with booting your PC")
  409.   print("recovery is going to try and fix this error now")
  410.   print("if this does not work then recovery will")
  411.   print("reinstall LUAOS for you, if this doesnt work")
  412.   print("then report this to the owner of the OS")
  413.   print("thank you for using LUAOS")
  414.   sleep(20)
  415.   fs.makeDir("/LUAOS")
  416.   fs.makeDir("/LUAOS/C")
  417.   fs.makeDir("/LUAOS/S")
  418.   fs.makeDir("/LUAOS/S/Users")
  419.   if not fs.exists("/LUAOS") then
  420.     print("LUAOS Recovery has failed to fix your computer")
  421.     print("please report this code to the owner")
  422.     print("LUAOSRFSNE(/LUAOS)")
  423.     sleep(10)
  424.     print("this computer will now shutdown")
  425.     sleep(3)
  426.     os.shutdown()
  427.   end
  428.   if not fs.exist("/LUAOS/C") then
  429.     print("LUAOS Recovery has failed to fix your computer")
  430.     print("please report this code to the owner")
  431.     print("LUAOSRFSNE(/LUAOS/C)")
  432.     sleep(10)
  433.     print("this computer will now shutdown")
  434.     sleep(3)
  435.     os.shutdown()
  436.   end
  437.   if not fs.exists("/LUAOS/S") then
  438.     print("LUAOS Recovery has failed to fix your computer")
  439.     print("please report this code to the owner")
  440.     print("LUAOSRFSNE(/LUAOS/S")
  441.     sleep(10)
  442.     print("this computer will now shutdown")
  443.     sleep(3)
  444.     os.shutdown()
  445.   end
  446.   if not fs.exists("/LUAOS/S/Users") then
  447.     print("LUAOS Recovery has failed to fix your computer")
  448.     print("please report this code to the owner")
  449.     print("LUAOSRFSNE(/LUAOS/S/Users)")
  450.     sleep(10)
  451.     print("this computer will now shutdown")
  452.     sleep(3)
  453.     os.shutdown()
  454.   end
  455.   print("LUAOS Recovery has fixed your computer, this computer will now restart")
  456.   sleep(5)
  457.   os.reboot()
  458. end
  459. function fc()
  460.   if not fs.exists("/LUAOS") then
  461.     print("/LUAOS does not exist, if you get this error please \n reinstall LUAOS or if that doesnt work \n then contact the owner, recovery will start now")
  462.     sleep(10)
  463.     recovery()
  464.   end
  465.   if not fs.exists("/LUAOS/C") then
  466.     print("/LUAOS/C does not exist, if you get this error please \n reinstall LUAOS or if that doesnt work \n then contact the owner, recovery will start now")
  467.     sleep(10)
  468.     recovery()
  469.   end
  470.   if not fs.exists("/LUAOS/S") then
  471.     print("/LUAOS/S does not exist, if you get this error please \n reinstall LUAOS or if that doesnt work \n then contact the owner, recovery will start now")
  472.     sleep(10)
  473.     recovery()
  474.   end
  475.   if not fs.exists("/LUAOS/S/Users") then
  476.     print("/LUAOS/S/Users does not exist, if you get this error please \n reinstall LUAOS or if that doesnt work \n then contact the owner, recovery will start now")
  477.     sleep(10)
  478.     recovery()
  479.   end
  480.   print("all essential drives files succesfully found")
  481.   sleep(5)
  482.   boot()
  483. end
  484. term.clear()
  485. term.setCursorPos(1,1)
  486. term.setTextColor(colors.red)
  487. build = "0.2.2 Indev"
  488. print("Welcome To LUAOS Version:",build)
  489. sleep(3)
  490. print("preparing to check files")
  491. textutils.slowPrint("|||||||||||||||||||||||||||||||||||||||||||||||||||")
  492. sleep(1)
  493. print("checking files now")
  494. fc()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement