Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("bottom")
- local bet = 1
- local user = ""
- local inactivity = nil
- local times = 0
- local timeout = 180
- local idServer = 1
- local blanks = 0
- local final = ""
- local slot1 = ""
- local slot2 = ""
- local slot3 = ""
- local playing = false
- local name = nil
- local pass = nil
- local results = {
- "Diamond", "Diamond",
- "Emerald","Emerald","Emerald",
- "Gold","Gold","Gold","Gold",
- "Iron","Iron","Iron","Iron","Iron",
- "Stone","Stone","Stone","Stone","Stone","Stone",
- "Wood","Wood","Wood","Wood","Wood","Wood","Wood"
- }
- local payouts = {}
- payouts["Diamond,Diamond,Diamond"] = 300
- payouts["Emerald,Emerald,Emerald"] = 100
- payouts["Gold,Gold,Gold"] = 50
- payouts["Iron,Iron,Iron"] = 25
- payouts["Stone,Stone,Stone"] = 15
- payouts["Wood,Wood,Wood"] = 5
- local function CheckID(nameID, passID)
- rednet.send(idServer, nameID ..",".. passID)
- local senderid, message, distance = rednet.receive()
- if senderid == idServer and message == "allow" then
- user = nameID
- return true
- else
- return false
- end
- end
- local function FitText(space, word)
- final = ""
- blanks = math.floor((space - string.len(word))/2)
- if (blanks*2 + string.len(word)) ~= space then
- for i=1, blanks+1 do
- final = final .. " "
- end
- final = final .. word
- for i=1, blanks do
- final = final .. " "
- end
- return final
- else
- for i=1, blanks do
- final = final .. " "
- end
- final = final .. word
- for i=1, blanks do
- final = final .. " "
- end
- return final
- end
- end
- local function BadID()
- term.clear()
- term.setCursorPos(1,1)
- print([[
- You either Don't have a valid Casino
- Identification card, or you don't have one at
- all. Please buy one from one of the casino
- clerks. If you're card is somehow corrupt
- you can request a replacement.
- Press [ENTER] To Return
- ]])
- while true do
- event, param1, param2, param3 = os.pullEvent()
- if event == "key" and param1 == 28 then
- StartScreen()
- break
- end
- end
- end
- local function Slots()
- print([[
- Welcome to the Casino of Sparky's Minecraft
- Credits:
- ----------------------------------------
- - - - -
- - - - -
- - - - -
- - - - -
- - - - -
- ----------------------------------------
- Payout:
- Press [S] To Spin
- Press [Q] To Quit
- Press Numbers
- To Change Bet
- [1] 2 3
- ]])
- term.setCursorPos(9,3)
- term.write(num)
- end
- function StartScreen()
- term.clear()
- term.setCursorPos(1,1)
- print([[
- |||||| || |||||| |||||| ||||||
- || || || || || ||
- |||||| || || || || ||||||
- || || || || || ||
- |||||| |||||| |||||| || ||||||
- Press [ENTER] To Continue
- ]])
- while true do
- event, param1, param2, param3 = os.pullEvent()
- if event == "key" and param1 == 28 then
- if fs.exists("disk/casinoid") then
- local id = fs.open("disk/casinoid", "r")
- local idinfo = id.readAll()
- name,pass = string.match(idinfo, "([^,]+),(%d+)")
- if CheckID(name, pass) == true then
- term.clear()
- term.setCursorPos(1,1)
- playing = true
- inactivity = os.startTimer(timeout)
- Slots()
- break
- else
- BadID()
- break
- end
- else
- BadID()
- break
- end
- end
- end
- end
- StartScreen()
- while playing == true do
- event, param1, param2, param3 = os.pullEvent()
- if event == "char" and string.lower(param1) == "s" then
- term.setCursorPos(1,7)
- term.clearLine()
- slot1 = results[math.random(1,#results)]
- slot2 = results[math.random(1,#results)]
- slot3 = results[math.random(1,#results)]
- print(" -"..FitText(12, slot1).."-"..FitText(12, slot2).."-"..FitText(12, slot3).."-")
- inactivity = os.startTimer(timeout)
- num = num-bet
- term.setCursorPos(9,3)
- term.write(num.." ")
- rednet.send(idServer, "creditupdate,"..user..",".."num")
- if payouts[slot1..","..slot2..","..slot3] ~= nil then
- term.setCursorPos(9,3)
- num = tonumber(num)+payouts[slot1..","..slot2..","..slot3]*bet
- term.write(num.." ")
- end
- end
- if event == "char" and string.lower(param1) == "q" then
- playing = false
- StartScreen()
- end
- if event == "char" and (param1=="1" or param1=="2" or param1=="3") then
- local bets = {"[1] 2 3", "1 [2] 3", "1 2 [3]"}
- bet = tonumber(param1)
- term.setCursorPos(1,16)
- term.clearLine()
- print(bets[bet])
- inactivity = os.startTimer(timeout)
- end
- if event == "disk_eject" then
- playing = false
- BadID()
- end
- if event == "timer" and param1 == inactivity then
- disk.eject("right")
- end
- end
Add Comment
Please, Sign In to add comment