Advertisement
Guest User

game.lua

a guest
Jul 3rd, 2013
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1. math.randomseed(os.time(s))
  2. require 'wait_func'
  3. num1 = 0
  4. num2 = 0
  5. num3 = 0
  6. credit = 5
  7. print("Welcome to the slot machine!")
  8. ::h::
  9. print("Type \"play\" to pull the lever!")
  10. print("Type \"exit\" to exit!")
  11.  
  12.  
  13. while true do
  14.  
  15. text = io.read()
  16. if text == "exit" then
  17. print("Aww you bugger ;(")
  18. os.exit()
  19. end
  20. if text == "play" then
  21. credit = credit - 1
  22. print("You insert a credit and pull the lever.")
  23.  
  24. end
  25.  
  26. num1 = math.random(0.0, 9.0)
  27. print("The machine shows...")
  28. wait(0.5)
  29. print(tonumber(num1))
  30. wait(0.5)
  31. num2 = math.random(0.0, 9.0)
  32. print(tonumber(num2))
  33. wait(0.5)
  34. num3 = math.random(0.0, 9.0)
  35. print(tonumber(num3))
  36. wait(0.3)
  37. print("")
  38. wait(0.3)
  39. if credit > 0 then
  40. print("You have "..credit.." credits left")
  41. goto h
  42. else
  43. break
  44. end
  45. end
  46.  
  47. if credit == 0 then
  48. print("You are out of credit. Restart the script to play again.")
  49.  
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement