Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- term.clear()
- term.setCursorPos(1,1)
- cash = 100
- print("Press Spacebar to play and E to exit")
- function won()
- print("YOU WON!!!")
- end
- function lost()
- print("YOU LOST")
- end
- line1 = " =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="
- line2 = " -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"
- while true do
- term.setCursorPos(2,2)
- print("Cash: "..cash.." ")
- local event, key = os.pullEvent("char")
- if key == "e" then
- term.clear()
- return
- elseif cash <= 0 then
- local x = 10
- for i=1,10 do
- term.clear()
- term.setCursorPos(1,5)
- print("Sorry you are out of cash please")
- print("start a new game.")
- x = x - 1
- print(x)
- sleep(1)
- end
- return
- end
- for i=1,10 do
- term.setCursorPos(1,1)
- if line == 0 then
- print(line1)
- line = 1
- else
- print(line2)
- line = 0
- end
- term.setCursorPos(1,17)
- if line == 0 then
- print(line2)
- else
- print(line1)
- end
- a = math.random(9)
- b = math.random(9)
- c = math.random(9)
- term.setCursorPos(20,9)
- print(a.." - "..b.." - "..c)
- sleep(0.5)
- end
- sleep(0.5)
- term.setCursorPos(20,9)
- print(a.." - "..b.." - "..c)
- print()
- term.setCursorPos(20,7)
- if a == b and b == c then
- won()
- if b == 9 then
- cash = cash + 500
- elseif b >= 5 then
- cash = cash + 100
- else
- cash = cash + 25
- end
- elseif a == b or b == c then
- won()
- if b == 9 then
- cash = cash + 25
- elseif b >= 5 then
- cash = cash + 10
- else
- cash = cash + 5
- end
- else
- lost()
- cash = cash - 5
- end
- term.setCursorPos(1,18)
- end
Advertisement
Add Comment
Please, Sign In to add comment