Advertisement
Guest User

UH V43.lua

a guest
Jun 6th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.45 KB | None | 0 0
  1. function Wait(seconds)
  2.  
  3.   local start = os.time()
  4.   repeat until os.time() > start + seconds
  5.  
  6. end
  7.  
  8. function Game(min,max)
  9.  
  10.     while true do
  11.  
  12.         print("Guess the Number betwen")
  13.         print(min,"and",max)
  14.         Ans = math.random(min,max)
  15.     Guss = io.read("*n")
  16.         if Guss == Ans then
  17.             print("You win!")
  18.             break
  19.         end
  20.  
  21.         if not (Guss == Ans) then
  22.             print("1 = Try again")
  23.             TA = io.read("*n")
  24.         end
  25.  
  26.         if not (TA == 1) then
  27.             print("Correct answar:",Ans)
  28.             break
  29.         end
  30.  
  31.         for i=1,5 do
  32.             print("")
  33.         end
  34.         Wait(1)
  35.  
  36.         Input = 0
  37.  
  38.     end
  39.     for i=1,5 do
  40.         print("")
  41.     end
  42.     Wait(1)
  43.  
  44.     Input = 0
  45.  
  46. end
  47.  
  48. function Calculate()
  49.  
  50.     print("1st number")
  51.     one = io.read("*n")
  52.     print("Symbol")
  53.     print("(0 = -, 1 = +")
  54.     print("2 = *, 3 = /)")
  55.     Symbol = io.read("*n")
  56.     print("2nt number")
  57.     two = io.read("*n")
  58.  
  59.     if Symbol == 0 then
  60.         Out = one-two
  61.     end
  62.  
  63.     if Symbol == 1 then
  64.         Out = one+two
  65.     end
  66.  
  67.     if Symbol == 2 then
  68.         Out = one*two
  69.     end
  70.  
  71.     if Symbol == 3 then
  72.         Out = one/two
  73.     end
  74.  
  75.     print("")
  76.     print(Out)
  77.     Wait(1)
  78.  
  79.     Input = 0
  80.  
  81. end
  82.  
  83. function fileClient()
  84.  
  85.   local command = 0
  86.   local dir = "/"
  87.  
  88.     os.execute("clear")
  89.   --BTW DON'T use spaces in file names
  90.  
  91.   io.read("*line") -- reset io.read
  92.  
  93.     while not (command == "exit") do
  94.  
  95.     io.write("\n" .. user .. "@" .. dir .. " $:")
  96.  
  97.         command = io.read("*line")
  98.  
  99.     if command == "ls" then
  100.           os.execute("ls -Ah files-V4.3/" .. dir)
  101.     end
  102.  
  103.       if string.sub(command, 1, 2) == "cd" then
  104.       dir = string.sub(command, 4, string.len(command))
  105.     end
  106.  
  107.     end
  108.  
  109. end
  110.  
  111. function appStore()
  112.  
  113.     print(os.execute("ls -h apps-V4.3"))
  114.  
  115. end
  116.  
  117. userNum = 1
  118. user = "root"
  119. r = 1
  120.  
  121. users = {}
  122. passwords = {}
  123. userCount = 1
  124.  
  125. users[1] = "root"
  126. passwords[1] = "password"
  127.  
  128. while r == 1 do
  129.  
  130.   os.execute("clear")
  131.     print("Hello,")
  132.     Wait(1)
  133.     print("press enter to")
  134.     print("continue.")
  135.     io.read()
  136.  
  137.     while true do
  138.  
  139.         print("1:Launch")
  140.         print("2:Tools")
  141.         print("3:Files")
  142.         print("4:Shutdown")
  143.         Input = io.read("*n")
  144.  
  145.         if Input == 1 then
  146.  
  147.             print("1:Calculator")
  148.             print("2:Guess")
  149.             --print("3:App Store")
  150.             print("0:back")
  151.             Input = io.read("*n")
  152.  
  153.             if Input == 1 then
  154.  
  155.                 print("Calculator:")
  156.                 print("")
  157.                 Calculate()
  158.             end
  159.  
  160.             if Input == 2 then
  161.  
  162.                 print("Game:")
  163.                 print("")
  164.                 Game(1,10)
  165.             end
  166.  
  167.             --if Input == 3 then
  168.  
  169.             --  appStore()
  170.  
  171.             --end
  172.  
  173.         end
  174.  
  175.         if Input == 2 then
  176.  
  177.             print("1:Time")
  178.             print("2:Info")
  179.       print("3:New user")
  180.       print("4:Change password")
  181.             print("0:back")
  182.             Input = io.read("*n")
  183.  
  184.             if Input == 1 then
  185.  
  186.                 print(os.date())
  187.                 Wait(1)
  188.  
  189.                 Input = 0
  190.  
  191.             end
  192.  
  193.             if Input == 2 then
  194.  
  195.                 print("this program was writen compoletoly by ben1jen,\nit has 274 lines of code.")
  196.  
  197.                 Input = 0
  198.  
  199.             end
  200.  
  201.       if Input == 3 then
  202.  
  203.         io.read("*line") -- reset io.read
  204.  
  205.         io.write("username:")
  206.         local usernm = io.read("*line")
  207.         io.write("Password:")
  208.         local passwd = io.read("*line")
  209.  
  210.         users[userCount + 1] = usernm
  211.         passwords[userCount + 1] = passwd
  212.  
  213.         userCount = userCount + 1
  214.  
  215.         Input = 0
  216.  
  217.       end
  218.  
  219.       if Input == 4 then
  220.  
  221.         io.read("*line") -- reset io.read
  222.  
  223.         io.write("New password:")
  224.         local passwordTMP = io.read("*line")
  225.  
  226.         passwords[userNum] = passwordTMP
  227.         print("password changed to:" .. passwords[userNum])
  228.  
  229.         Wait(1)
  230.  
  231.         os.execute("clear")
  232.  
  233.         Input == 0
  234.  
  235.       end
  236.  
  237.         end
  238.  
  239.         if Input == 3 then
  240.  
  241.             fileClient()
  242.  
  243.         end
  244.  
  245.         if Input == 4 then
  246.  
  247.             print("1:Shutdown")
  248.             print("2:Reboot")
  249.             print("3:Sleep")
  250.       print("4:Logout")
  251.             print("0:back")
  252.             Input = io.read("*n")
  253.  
  254.             if Input == 1 then
  255.  
  256.                 r=0
  257.                 os.execute("clear")
  258.                 break
  259.  
  260.             end
  261.  
  262.             if Input == 2 then
  263.  
  264.                 os.execute("clear")
  265.                 io.read()
  266.                 break
  267.  
  268.             end
  269.  
  270.             if Input == 3 then
  271.  
  272.                 os.execute("clear")
  273.                 Wait(1)
  274.                 io.read() -- reset io.read
  275.                 io.read()
  276.  
  277.             end
  278.  
  279.       if Input == 4 then
  280.  
  281.         for i = 1, userCount do
  282.           io.write(i .. ":" .. users[i] .. "\n")
  283.         end
  284.  
  285.         userNum = io.read("*n")
  286.  
  287.         io.read("*line") -- reset io.read
  288.  
  289.         io.write("Password:")
  290.         local passwordTMP = io.read("*line")
  291.  
  292.         if passwordTMP == passwords[Input] then
  293.           user = users[userNum]
  294.         else
  295.           print("PASSWORD INCORRECT")
  296.         end
  297.  
  298.       end
  299.  
  300.         end
  301.  
  302.     end
  303.  
  304. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement