Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -----------------------------------------------------
- -- This program was made,typed and conceived --
- -- by Craniumkid22 --
- -----------------------------------------------------
- ----------------------------
- --(And debugged by Pharap)--
- -- A LOT --
- ----------------------------
- -------------------------------------------------------------------------------------------
- -------------------------------------Debug notes-------------------------------------------
- -------------------------------------------------------------------------------------------
- -- Fixed the problem with the "10" not displaying correctly --
- -- I created a title, with an ASCII generator. --
- -- --
- -------------------------------------------------------------------------------------------
- ------------------------------------Derp goes here-----------------------------------------
- -------------------------------------------------------------------------------------------
- --variables
- local symbol = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"}
- --screen functions
- function sTitle()
- term.setCursorPos(1,15)
- print(" __ __ ___ ___ __ _ ___ _____ __ ")
- print(" / /' / /\\ | |_)| | \\ ( ('| | / / \\ | | ( ('")
- print(" \\_\\_,/_/--\\|_| \\|_|_/ _)_)|_|__\\_\\_/ |_| _)_)")
- end
- function loser()
- term.clear()
- term.setCursorPos(1,5)
- print(" __ ___ __ ____ ____ ")
- print(" || // \\\\ (( \\ || || \\\\")
- print(" || (( )) \\\\ ||== ||_//")
- print(" ||__| \\\\_// \\_)) ||___ || \\\\")
- sleep(3)
- term.clear()
- end
- function jackpot()
- for x = 1,5 do
- term.clear()
- sleep(.25)
- term.setCursorPos(1,5)
- print(" __ ___ ___ __ __ ____ ___ ______")
- print(" || // \\\\ // || // || \\\\ // \\\\ | || |")
- print(" || ||=|| (( ||<< ||_// (( )) || ")
- print(" |__|| || || \\\\__ || \\\\ || \\\\_// || ")
- sleep(.25)
- end
- end
- function cardtop(x,y)
- term.setCursorPos(x,y)
- write([[ .------------. ]])
- term.setCursorPos(x,y+1)
- write([[| .----------. |]])
- term.setCursorPos(x,y+2)
- write([[| | | |]])
- term.setCursorPos(x,y+3)
- write([[| | .------. | |]])
- term.setCursorPos(x,y+4)
- end
- function cardbase(x,y)
- term.setCursorPos(x,y+8)
- write([[| | '------' | |]])
- term.setCursorPos(x,y+9)
- write([[| | | |]])
- term.setCursorPos(x,y+10)
- write([[| '----------' |]])
- term.setCursorPos(x,y+11)
- write([[ '------------' ]])
- end
- function numtop(n,x,y)
- if symbol[n] == "10" then
- term.setCursorPos(x,y+4)
- write([[| | |]]..symbol[n]..[[--. | | |]])
- else
- term.setCursorPos(x,y+4)
- write([[| | |]]..symbol[n]..[[.--. | | |]])
- end
- end
- function numbase(n,x,y)
- if symbol[n] == "10" then
- term.setCursorPos(x,y+7)
- write([[| | | '--]]..symbol[n]..[[| | |]])
- else
- term.setCursorPos(x,y+7)
- write([[| | | '--']]..symbol[n]..[[| | |]])
- end
- end
- function spade(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | :/\: | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | (__) | | |]])
- end
- function heart(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | (\/) | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | :\/: | | |]])
- end
- function club(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | :(): | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | ()() | | |]])
- end
- function diamond(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | :/\: | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | :\/: | | |]])
- end
- --action functions
- function slot(pos)
- local c = math.random(1,4)
- local n = math.random(1,13)
- cardtop(pos,1)
- numtop(n,pos,1)
- if c == 1 then
- spade(pos,1)
- elseif c == 2 then
- heart(pos,1)
- elseif c == 3 then
- club(pos,1)
- elseif c == 4 then
- diamond(pos,1)
- end
- numbase(n,pos,1)
- cardbase(pos,1)
- return c,n
- end
- function spin()
- for cnt = 1, 10 do
- slot(2)
- slot(18)
- slot(34)
- sleep(cnt/30)
- end
- end
- function allsuitsmatch(result)
- return (result[1] == result[3] and result[3] == result[5] and result[5] ==result[1])
- end
- function allvaluesmatch(result)
- return (result[2] == result[4] and result[4] == result[6] and result[6] ==result[2] )
- end
- function isroyalflush(result)
- local Fresult = false
- if result[2] > 10 and result[4] > 10 and result[6] > 10 then
- if result[2] ~= result[4] and result[4] ~= result[6] and result[6] ~= result[2] then return true -- royal flush discounting Ace
- end
- end
- if result[2] == 1 and result[4] > 11 and result[6] > 11 and result[4] ~= result[6] then return true --royal flush including ace, condition 1
- elseif result[4] == 1 and result[6] > 11 and result[2] > 11 and result[6] ~= result[2] then return true --royal flush including ace, condition 2
- elseif result[6] == 1 and result[2] > 11 and result[4] > 11 and result[2] ~= result[4] then return true --royal flush including ace, condition 3
- end
- return false
- end
- function testwin(results)
- ------------------------------
- -- This function has been --
- -- brought to you by Pharap --
- ------------------------------
- local value = 0
- if allsuitsmatch(results) then value = 1 end -- suits match
- if allvaluesmatch(results) then value = 2 end -- values match
- if allsuitsmatch(results) and allvaluesmatch(results) then value = 3 end --suits and values match
- if isroyalflush(results) then value = 4 end -- royal flush
- if isroyalflush(results) and allsuitsmatch(results) then value = 5 end -- royal flush of all matching suits
- if isroyalflush(results) and allvaluesmatch(results) then value = "wtfiswrongwithyou,howthehelldidyoucausesuchabloodystupiderror" return "error" end-- lol, like this would actually happen
- return value
- end
- --code
- function slots()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- while true do
- local event, p1 = os.pullEvent()
- if event == "key" then
- if p1 == 28 then
- spin()
- local s1, n1 = slot(2)
- local s2, n2 = slot(18)
- local s3, n3 = slot(34)
- sleep(2)
- local results = {s1,n1,s2,n2,s3,n3}
- --local results = {3,1,3,12,3,13}
- local condition = testwin(results)
- if condition == 0 then
- loser()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- elseif condition == 1 then --suits
- jackpot()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- elseif condition == 2 then --values
- jackpot()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- elseif condition == 3 then --suits and values
- jackpot()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- elseif condition == 4 then --royal flush
- jackpot()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- elseif condition == 5 then --royal flush suited
- jackpot()
- term.clear()
- sTitle()
- slot(2)
- slot(18)
- slot(34)
- end
- elseif p1 == 14 then break
- end
- end
- end
- end
- --test
- slots()
Advertisement
Add Comment
Please, Sign In to add comment