Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Tables
- local symbol = {"A","2","3","4","5","6","7","8","9","10","J","Q","K"}
- local gMenu = {
- "Lucky Dice",
- "Magic 8 Block",
- "Card Slots",
- "Main Menu"
- }
- local answers = {
- "It is Certain ",
- " Decidedly So ",
- " No ",
- " Yes ",
- " No doubt ",
- " Never ",
- " Unknown ",
- " Ask again ",
- " Doubtful ",
- " Most Likely ",
- "Cannot predict",
- " Probably not ",
- " Stars say no ",
- " For sure "
- }
- --[[Pretty screen printing functions]]--
- local function blank()
- term.setCursorPos(7,3)
- print("+--------------+ +--------------+")
- term.setCursorPos(7,4)
- print("| | | |")
- term.setCursorPos(7,5)
- print("| | | |")
- term.setCursorPos(7,6)
- print("| Press ENTER | | to Roll |")
- term.setCursorPos(7,7)
- print("| | | |")
- term.setCursorPos(7,8)
- print("| BACKSPACE | | to Exit |")
- term.setCursorPos(7,9)
- print("| | | |")
- term.setCursorPos(7,10)
- print("| | | |")
- term.setCursorPos(7,11)
- print("+--------------+ +--------------+")
- end
- local function gPage()
- term.clear()
- term.setCursorPos(1,1)
- print(" _______ _______ _______ _______ _______ ")
- print(" ( ____ \\( ___ )( )( ____ \\( ____ \\")
- print(" | ( \\/| ( ) || () () || ( \\/| ( \\/")
- print(" | | | (___) || || || || (__ | (_____ ")
- print(" | | ____ | ___ || |(_)| || __) (_____ )")
- print(" | | \\_ )| ( ) || | | || ( ) |")
- print(" | (___) || ) ( || ) ( || (____/\\/\\____) |")
- print(" (_______)|/ \\||/ \\|(_______/\\_______)")
- end
- local function sTitle()
- term.setCursorPos(1,15)
- print(" __ __ ___ ___ __ _ ___ _____ __ ")
- print(" / /' / /\\ | |_)| | \\ ( ('| | / / \\ | | ( ('")
- print(" \\_\\_,/_/--\\|_| \\|_|_/ _)_)|_|__\\_\\_/ |_| _)_)")
- end
- local function loser()
- term.clear()
- term.setCursorPos(1,5)
- print(" __ ___ __ ____ ____ ")
- print(" || // \\\\ (( \\ || || \\\\")
- print(" || (( )) \\\\ ||== ||_//")
- print(" ||__| \\\\_// \\_)) ||___ || \\\\")
- sleep(3)
- term.clear()
- end
- local function jackpot()
- for x = 1,5 do
- term.clear()
- sleep(.25)
- term.setCursorPos(1,5)
- print(" __ ___ ___ __ __ ____ ___ ______")
- print(" || // \\\\ // || // || \\\\ // \\\\ | || |")
- print(" || ||=|| (( ||<< ||_// (( )) || ")
- print(" |__|| || || \\\\__ || \\\\ || \\\\_// || ")
- sleep(.25)
- end
- end
- local function soon()
- for i = 1,5 do
- term.clear()
- term.setCursorPos(1,1)
- sleep(.25)
- print(" ) ( ) ")
- print(" ( ( /( ( )\\ ) ( /( ( ")
- print(" )\\ )\\()) )\\))( (()/( )\\()))\\ ) ")
- print(" (((_|(_)\\ ((_)()\\ /(_)|(_)\\(()/( ")
- print(" )\\___ ((_)(_()((_|_)) _((_)/(_))_ ")
- print(" ((/ __/ _ \\| \\/ |_ _|| \\| (_)) __| ")
- print(" | (_| (_) | |\\/| || | | .' | | (_ | ")
- print(" (\\___\\__)/|_| |_|__)||_|\\_| \\___| ")
- print(" ")
- print(" )\\ ) ( /( ( /( ( /( ")
- print(" (()/( )\\()) )\\()) )\\()) ")
- print(" /(_)|(_)\\ ((_)\\ ((_)\\ ")
- print(" (_)) ((_) ((_) _((_) ")
- print(" / __| / _ \\ / _ \\| \\| | ")
- print(" \\__ \\| (_) | (_) | .' | ")
- print(" |___/ \\___/ \\___/|_|\\_| ")
- sleep(.5)
- end
- end
- -- dice functions
- local function dTitle()
- term.setCursorPos(1,14)
- print(" __ __ ___ _ ")
- print(" / / __ ______/ /____ __ / _ \\(_)______ ")
- print(" / /__/ // / __/ '_/ // / / // / / __/ -_)")
- print(" /____/\\_,_/\\__/_/\\_\\\\_, / /____/_/\\__/\\__/ ")
- print(" /___/ ")
- end
- local function die1()
- local x = math.random(1,6)
- if x == 1 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| O |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- elseif x == 2 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| O |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| O |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- elseif x == 3 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| O |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| O |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| O |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- elseif x == 4 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| O O |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| O O |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- elseif x == 5 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| O O |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| O |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| O O |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- elseif x == 6 then
- term.setCursorPos(7,3)
- print("+--------------+")
- term.setCursorPos(7,4)
- print("| |")
- term.setCursorPos(7,5)
- print("| O O |")
- term.setCursorPos(7,6)
- print("| |")
- term.setCursorPos(7,7)
- print("| O O |")
- term.setCursorPos(7,8)
- print("| |")
- term.setCursorPos(7,9)
- print("| O O |")
- term.setCursorPos(7,10)
- print("| |")
- term.setCursorPos(7,11)
- print("+--------------+")
- end
- end
- local function die2()
- local x = math.random(1,6)
- if x == 1 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| O |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- elseif x == 2 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| O |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| O |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- elseif x == 3 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| O |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| O |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| O |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- elseif x == 4 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| O O |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| O O |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- elseif x == 5 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| O O |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| O |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| O O |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- elseif x == 6 then
- term.setCursorPos(25,3)
- print("+--------------+")
- term.setCursorPos(25,4)
- print("| |")
- term.setCursorPos(25,5)
- print("| O O |")
- term.setCursorPos(25,6)
- print("| |")
- term.setCursorPos(25,7)
- print("| O O |")
- term.setCursorPos(25,8)
- print("| |")
- term.setCursorPos(25,9)
- print("| O O |")
- term.setCursorPos(25,10)
- print("| |")
- term.setCursorPos(25,11)
- print("+--------------+")
- end
- end
- local function roll()
- local r = 1
- for r = 1,50 do
- parallel.waitForAll(die1,die2,sleep(.1))
- end
- end
- local function dice()
- while true do
- term.clear()
- dTitle()
- blank()
- event, p1 = os.pullEvent("key")
- if p1 == 28 then
- roll()
- sleep(3)
- elseif p1 == 14 then break
- end
- end
- end
- -- 8block functions
- local function bTitle()
- term.clear()
- term.setCursorPos(1,1)
- print(" _ _ _ __ __ _ ")
- print(" ' ) ) ) ( ) / ) // / ")
- print(" / / / __. _, o _. ./' /--< // __ _. /_ ")
- print(" / ' (_(_/|_(_)_<_(__ (__) /___/_</_(_)(__/ <_ ")
- print(" /| ")
- print(" |/ ")
- end
- local function ans()
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" | .--------------. |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | |"..answers[math.random(1,#answers)].."| |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | '--------------' |")
- print(" '----------------' ")
- end
- local function start()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print("Ask me ANY | .--------------. | ")
- print("question, and | | ____ | | BACKSPACE ")
- print("press ENTER | | .' __ '. | | ")
- print("to receive | | | (__) | | | ")
- print("your answer... | | .'____'. | | to exit ")
- print(" | | | (____) | | | ")
- print(" | | '.______.' | | ")
- print(" | | | | ")
- print(" | '--------------' | ")
- print(" '----------------' ")
- end
- local function shake()
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" | .--------------. | * ")
- print(" * | | | | ")
- print(" | | | | ")
- print(" * | | | | * ")
- print(" | | | | ")
- print(" | | | | ")
- print(" * | | | | * ")
- print(" | | | | ")
- print(" * | '--------------' | ")
- print(" '----------------' ")
- sleep(.2)
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" * .----------------. ")
- print(" | .--------------. | ")
- print(" | | | | * * ")
- print(" * | | | | ")
- print(" | | | | ")
- print(" | | | | ")
- print(" | | | | * ")
- print(" | | | | ")
- print(" * | | | | * ")
- print(" | '--------------' | ")
- print(" '----------------' ")
- sleep(.2)
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" * | .--------------. | * ")
- print(" | | | | ")
- print(" | | | | ")
- print(" * | | | | ")
- print(" | | | | * ")
- print(" | | | | ")
- print(" * | | | | ")
- print(" | | | | * ")
- print(" * | '--------------' | * ")
- print(" '----------------' ")
- sleep(.2)
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" * | .--------------. | * ")
- print(" | | | | ")
- print(" | | | | * ")
- print(" | | | | ")
- print(" * | | | | ")
- print(" | | | | ")
- print(" | | | | ")
- print(" * * | | | | * ")
- print(" | '--------------' | ")
- print(" '----------------' * ")
- sleep(.2)
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" * | .--------------. | * ")
- print(" | | | | ")
- print(" * | | | | * ")
- print(" | | | | ")
- print(" | | | | * ")
- print(" | | | | ")
- print(" * * | | | | ")
- print(" | | | | * ")
- print(" | '--------------' | ")
- print(" * '----------------' * ")
- sleep(.2)
- term.clear()
- bTitle()
- term.setCursorPos(1,7)
- print(" .----------------. ")
- print(" | .--------------. |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | | | |")
- print(" | '--------------' |")
- print(" '----------------' ")
- sleep(1.5)
- ans()
- end
- local function block()
- start()
- while true do
- local event, p1 = os.pullEvent("key")
- if p1 == 28 then
- shake()
- sleep(2)
- start()
- elseif p1 == 14 then break
- end
- end
- end
- -- slots functions
- local 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
- local 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
- local 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
- local 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
- local function spade(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | :/\: | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | (__) | | |]])
- end
- local function heart(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | (\/) | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | :\/: | | |]])
- end
- local function club(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | :(): | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | ()() | | |]])
- end
- local function diamond(x,y)
- term.setCursorPos(x,y+5)
- write([[| | | :/\: | | |]])
- term.setCursorPos(x,y+6)
- write([[| | | :\/: | | |]])
- end
- local 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
- local function spin()
- for cnt = 1, 10 do
- slot(2)
- slot(18)
- slot(34)
- sleep(cnt/30)
- end
- end
- local function allsuitsmatch(result)
- return (result[1] == result[3] and result[3] == result[5] and result[5] ==result[1])
- end
- local function allvaluesmatch(result)
- return (result[2] == result[4] and result[4] == result[6] and result[6] ==result[2] )
- end
- local 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
- local 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
- local 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
- --options
- local function opt(m,mY)
- n=1
- l=#m
- while true do
- for i=1, l, 1 do
- if i==n then
- local x, y = term.getSize()
- local b = string.len(">"..m[i].."<")/2
- local x = (x/2)-b
- term.setCursorPos(x,i+mY)
- term.clearLine()
- print(">"..m[i].."<")
- else
- local x, y = term.getSize()
- b = string.len(m[i])/2
- x = (x/2)-b
- term.setCursorPos(x,i+mY)
- term.clearLine()
- print(m[i]) end
- end
- a, b= os.pullEventRaw()
- if a == "key" then
- if b==200 and n>1 then n=n-1 end
- if b==208 and n<l then n=n+1 end
- if b==28 then break end
- end
- end
- term.clear() term.setCursorPos(1,1)
- return n
- end
- -- game system
- while true do
- gPage()
- local input = opt(gMenu,10)
- if input == 1 then
- dice()
- elseif input == 2 then
- block()
- elseif input == 3 then
- slots()
- elseif input == 4 then break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement