C07v0

Personal assistant v1.1 WIP

Apr 13th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.80 KB | None | 0 0
  1. --[[
  2. Made by Kolten Viera aka "Spongy141"
  3. only may user edit "local passw"
  4. if modified, you mist give me credit.
  5. --]]
  6. --Game function
  7. local passw = ("password")
  8. function game()
  9.    print("* Guess a Number Game *")
  10.    math.randomseed( os.time() )
  11.    repeat
  12.       Trial = 1
  13.       Number = math.random(100)
  14.       print("Guess a Number 1-100")
  15.       while true do
  16.          print("Trial " .. Trial .. "?")
  17.          Guess = io.read("*n")
  18.          -- check end
  19.          if Guess == Number then
  20.             print("Correct")
  21.             print("You Won!")
  22.             break
  23.          elseif Trial == 10 then
  24.             print("You Lose!")
  25.             print("The Number is "..Number)
  26.             break
  27.          end
  28.          -- give hint
  29.          if Guess < Number then
  30.             print("Wrong")
  31.             print("Try Larger Number")
  32.          elseif Guess > Number then
  33.             print("Wrong")
  34.             print("Try Smaller Number")
  35.          end
  36.          Trial = Trial + 1
  37.       end
  38.       print("Do you want to Play again (y/n)?")
  39.       more = io.read()
  40.    until more ~= "y"
  41.    main()
  42. end
  43. -- Commands are entered here.
  44. function main()
  45.    while true do
  46.       print("Command: ")
  47.       local cmd = io.read()
  48.       if cmd == "help" then
  49.          print("Commands are: help, calculator, exit, date, game (WIP)")
  50.       end
  51.       if cmd == "calculator" then
  52.          print("OK")
  53.          calculate()
  54.       end
  55.       if cmd == "exit" then
  56.          print("Bye master!")
  57.          print(" ")
  58.          print(" ")
  59.          print(" ")
  60.          print(" ")
  61.          os.exit(0)
  62.       end
  63.       if cmd == "game" then
  64.          game()
  65.       end
  66.       if cmd == "date" then
  67.          print(os.date())
  68.       end
  69.       if cmd == "" then
  70.          print("Not a command")
  71.       end
  72.       if cmd == " " then
  73.          print("Not a command")
  74.       end
  75.       local gift = math.random(1000000000000)
  76.       if cmd == gift then
  77.          print("Holy crap... you are the worlds luckiest person.... well sadly there is no price")
  78.       end
  79.    end
  80. end
  81. -- The calculator
  82. function calculate()
  83.    local x = io.read()
  84.    print("math")
  85.    local var = io.read()
  86.    if var == "+" then
  87.       if n == nil then
  88.          local n = io.read()
  89.          print(x.."+"..n.."="..x+n)
  90.          main()
  91.       end
  92.    end
  93.    if var == "*" then
  94.       if n == nil then
  95.          local n = io.read()
  96.          print(x.."*"..n.."="..x*n)
  97.          main()
  98.       end
  99.    end
  100.    if var == "^" then
  101.       if n == nil then
  102.          local n = io.read()
  103.          print(x.."^"..n.."="..x^n)
  104.          main()
  105.       end
  106.    end
  107.    if var == "-" then
  108.       if n == nil then
  109.          local n = io.read()
  110.          print(x.."-"..n.."="..x-n)
  111.          main()
  112.       end
  113.    end
  114.    if var == "/" then
  115.       if n == nil then
  116.          local n = io.read()
  117.          print(x.."/"..n.."="..x/n)
  118.          main()
  119.       end
  120.    end
  121.    if var == "of" then
  122.       if n == nil then
  123.          local n = io.read()
  124.          print(n.." is "..n/x.." of "..x)
  125.          main()
  126.       end
  127.    end
  128.    if var == "compare" then
  129.       if n == nil then
  130.          local n = io.read()
  131.          if n>x then
  132.             print(x.." is less than "..n)
  133.          elseif n<x then
  134.             print(x.." is greater than "..n)
  135.          end
  136.       end
  137.    end
  138. end
  139. -- Password section
  140. print("Personal Assistant v1.1")
  141. print("===================")
  142. print("Password")
  143. local pass = io.read()
  144. if pass == passw then
  145.    print(" ")
  146.    print(" ")
  147.    print(" ")
  148.    print(" ")
  149.    print(" ")
  150.    print(" ")
  151.    print(" ")
  152.    print(" ")
  153.    print(" ")
  154.    print(" ")
  155.    print(" ")
  156.    print(" ")
  157.    print(" ")
  158.    print(" ")
  159.    print(" ")
  160.    print("For help type help")
  161.    main()
  162. else -- if the password is wrong.
  163.    print("Inncorrect password!")
  164.    print(" ")
  165.    print(" ")
  166.    os.exit()
  167. end
Advertisement
Add Comment
Please, Sign In to add comment