Advertisement
Guest User

UHV.lua

a guest
Jun 6th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.87 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. user = "root"
  118. r = 1
  119.  
  120. users = {}
  121. passwords = {}
  122. userCount = 1
  123.  
  124. users[1] = "root"
  125. passwords[1] = "password"
  126.  
  127. while r == 1 do
  128.  
  129.   os.execute("clear")
  130.     print("Hello,")
  131.     Wait(1)
  132.     print("press enter to")
  133.     print("continue.")
  134.     io.read()
  135.  
  136.     while true do
  137.  
  138.         print("1:Launch")
  139.         print("2:Tools")
  140.         print("3:Files")
  141.         print("4:Shutdown")
  142.         Input = io.read("*n")
  143.  
  144.         if Input == 1 then
  145.  
  146.             print("1:Calculator")
  147.             print("2:Guess")
  148.             --print("3:App Store")
  149.             print("0:back")
  150.             Input = io.read("*n")
  151.  
  152.             if Input == 1 then
  153.  
  154.                 print("Calculator:")
  155.                 print("")
  156.                 Calculate()
  157.             end
  158.  
  159.             if Input == 2 then
  160.  
  161.                 print("Game:")
  162.                 print("")
  163.                 Game(1,10)
  164.             end
  165.  
  166.             --if Input == 3 then
  167.  
  168.             --  appStore()
  169.  
  170.             --end
  171.  
  172.         end
  173.  
  174.         if Input == 2 then
  175.  
  176.             print("1:Time")
  177.             print("2:Info")
  178.       print("3:New user")
  179.             print("0:back")
  180.             Input = io.read("*n")
  181.  
  182.             if Input == 1 then
  183.  
  184.                 print(os.date())
  185.                 Wait(1)
  186.  
  187.                 Input = 0
  188.  
  189.             end
  190.  
  191.             if Input == 2 then
  192.  
  193.                 print("this program was writen compoletoly by ben1jen,\nit has 274 lines of code.")
  194.  
  195.                 Input = 0
  196.  
  197.             end
  198.  
  199.       if Input == 3 then
  200.  
  201.         io.read("*line") -- reset io.read
  202.  
  203.         io.write("username:")
  204.         local usernm = io.read("*line")
  205.         io.write("Password:")
  206.         local passwd = io.read("*line")
  207.  
  208.         users[userCount + 1] = usernm
  209.         passwords[userCount + 1] = passwd
  210.  
  211.         userCount = userCount + 1
  212.  
  213.         Input = 0
  214.  
  215.       end
  216.  
  217.         end
  218.  
  219.         if Input == 3 then
  220.  
  221.             fileClient()
  222.  
  223.         end
  224.  
  225.         if Input == 4 then
  226.  
  227.             print("1:Shutdown")
  228.             print("2:Reboot")
  229.             print("3:Sleep")
  230.       print("4:Logout")
  231.             print("0:back")
  232.             Input = io.read("*n")
  233.  
  234.             if Input == 1 then
  235.  
  236.                 r=0
  237.                 os.execute("clear")
  238.                 break
  239.  
  240.             end
  241.  
  242.             if Input == 2 then
  243.  
  244.                 os.execute("clear")
  245.                 io.read()
  246.                 break
  247.  
  248.             end
  249.  
  250.             if Input == 3 then
  251.  
  252.                 os.execute("clear")
  253.                 Wait(1)
  254.                 io.read() -- reset io.read
  255.                 io.read()
  256.  
  257.             end
  258.  
  259.       if Input == 4 then
  260.  
  261.         for i = 1, userCount do
  262.           io.write(i .. ":" .. users[i] .. "\n")
  263.         end
  264.  
  265.         Input = io.read("*n")
  266.  
  267.         io.read("*line") -- reset io.read
  268.         user = users[Input]
  269.  
  270.       end
  271.  
  272.         end
  273.  
  274.     end
  275.  
  276. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement