Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- math.randomseed(os.time(s))
- require 'wait_func'
- num1 = 0
- num2 = 0
- num3 = 0
- credit = 5
- print("Welcome to the slot machine!")
- ::h::
- print("Type \"play\" to pull the lever!")
- print("Type \"exit\" to exit!")
- while true do
- text = io.read()
- if text == "exit" then
- print("Aww you bugger ;(")
- os.exit()
- end
- if text == "play" then
- credit = credit - 1
- print("You insert a credit and pull the lever.")
- end
- num1 = math.random(0.0, 9.0)
- print("The machine shows...")
- wait(0.5)
- print(tonumber(num1))
- wait(0.5)
- num2 = math.random(0.0, 9.0)
- print(tonumber(num2))
- wait(0.5)
- num3 = math.random(0.0, 9.0)
- print(tonumber(num3))
- wait(0.3)
- print("")
- wait(0.3)
- if credit > 0 then
- print("You have "..credit.." credits left")
- goto h
- else
- break
- end
- end
- if credit == 0 then
- print("You are out of credit. Restart the script to play again.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement