Advertisement
Guest User

Untitled

a guest
Jul 12th, 2018
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. print("Random Math V0.1")
  2. ::diff::
  3. print("")
  4. print("What difficulty?")
  5. print("easy medium hard")
  6. gd = 0 dif = io.read()
  7. if dif == "easy" then
  8.     lives = 3
  9.     ran1 = 1
  10.     ran2 = 2
  11. elseif dif == "medium" then
  12.     lives = 2
  13.     ran1 = 1
  14.     ran2 = 3
  15. elseif dif == "hard" then
  16.     lives = 1
  17.     ran1 = 1
  18.     ran2 = 3.5
  19. else
  20.     os.execute("cls")
  21.     print("invalid response")
  22.     goto diff
  23. end
  24. os.execute("cls")
  25. rnd = 1
  26. while lives > 0 do
  27.     mult = 0.75+(rnd * 0.25)
  28.     mult = math.floor(mult)
  29.     num1 = math.random(ran1 * mult, ran2 * mult)
  30.     num2 = math.random(ran1 * mult, ran2 * mult)
  31.     if rnd >= 20 then
  32.         asmd = math.random(1,4)
  33.     elseif rnd >= 10
  34.         then asmd = math.random(1,3)
  35.     elseif rnd >= 5 then
  36.         asmd = math.random(1,2)
  37.     else
  38.         asmd = 1
  39.     end
  40.     if asmd == 1 then
  41.         ans = num1 + num2
  42.         print("What is "..num1.." + "..num2.."?")
  43.         pa = io.read()
  44.         if pa == ans then
  45.             print("Correct!")
  46.             rnd = rnd + 1
  47.         else
  48.             print("Wrong")
  49.             print("Correct answer was "..ans)
  50.             print("Your answer was "..pa)
  51.             lives = lives - 1
  52.             print("You now have "..lives.." lives")
  53.         end
  54.     elseif asmd == 2 then
  55.  
  56.     elseif asmd == 3 then
  57.  
  58.     else
  59.  
  60.     end
  61. end
  62.  
  63. print("Game Over")
  64. print("You Lost to Round "..rnd)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement