Advertisement
Phlimy

FindTheNumber

Jul 4th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.44 KB | None | 0 0
  1. term.clear()
  2.  
  3. function find()
  4.     print("Find the number:")
  5.     ans = read()
  6.     ans = tonumber(ans)
  7. end      
  8.  
  9. print("Min:")
  10. min = read()
  11. print("Max:")
  12. max = read()
  13.  
  14. print("Generating...")
  15. num = math.random(min,max)
  16. sleep(2)
  17.  
  18. term.clear()
  19.  
  20. while true do
  21.  
  22. find()
  23.  
  24. if ans == num then
  25. print("You win!")
  26. break
  27. elseif ans < num then
  28. print("+")
  29. elseif ans > num then
  30. print("-")
  31. else
  32. print("Error: Wrong input... Try again")
  33. end
  34.  
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement