Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Mira's Slot Machine ]]--
- function onLoad(save_state)
- -- begin config --
- bag = getObjectFromGUID("903a88")
- colTok = getObjectFromGUID("f696c4")
- randRup = getObjectFromGUID("ea79f0")
- randPup = getObjectFromGUID("737b2a")
- dailyTok = getObjectFromGUID("b5d1b0")
- --Trophies
- devil = getObjectFromGUID("b81e2c")
- gold = getObjectFromGUID("8a9b91")
- silver = getObjectFromGUID("92be74")
- bronze = getObjectFromGUID("11479f")
- rigged = false
- rigOne = 9
- rigTwo = 9
- rigThree = 9
- instant = true
- rollDelayTick = 0.04
- rollDelay = 0.15
- rollAmount = 25
- rollOffset = 10
- requiresTurn = true
- requiresToken = true
- --affects the speed at which the individual slots slow down
- --rollCurveMult*rollCurveExp^(-0.7*i+1)+1 where rollCurveExp is 1 or greater and i is the amount of roll ticks left
- --https://www.desmos.com/calculator/uckzjegsoz
- rollCurveMult = 1.8*0.4
- rollCurveExp = 1.3
- spawnLoc = self.getPosition()
- spawnLoc.x = spawnLoc.x + 4
- spawnLoc.y = spawnLoc.y + 0
- spawnLoc.z = spawnLoc.z + 0
- turnsPerRegen = 12
- minutesPerRegen = 20 --how long it takes to regen turns
- turnsPerDay = 9999
- -- end config --
- save = {} --{{playerSaves},{statistics}}
- playerSaves = {} --{steam_id={dateLastPlayed, turnsLeft, turnRegensLeft}}
- statistics = {} --{lastDatePlayed, lastTimePlayed, turnsLeft, turnRegensLeft}
- plays = 0
- tokensPaid = 0
- pupsPaid = 0
- rupsPaid = 0
- dailysPaid = 0
- jackpot = 0
- mjackpot = 0
- save = JSON.decode(save_state)
- if #save == 2 then
- playerSaves = save[1]
- statistics = save[2]
- if statistics.plays ~= nil then plays = statistics.plays end
- if statistics.tokensPaid ~= nil then tokensPaid = statistics.tokensPaid end
- if statistics.pupsPaid ~= nil then pupsPaid = statistics.pupsPaid end
- if statistics.rupsPaid ~= nil then rupsPaid = statistics.rupsPaid end
- if statistics.dailysPaid ~= nil then dailysPaid = statistics.dailysPaid end
- if statistics.jackpot ~= nil then jackpot = statistics.jackpot end
- if statistics.mjackpot ~= nil then mjackpot = statistics.mjackpot end
- else
- print("Error finding Slot Machine save_state.\nsave_state is empty or wrong size: #save="..#save)
- end
- payoutIcon = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
- [21] = "♤", -- Blackjack/21
- [22] = "☠", -- Bust
- [100] = "♛", -- Joker
- [110] = "♛♛", -- Double Joker
- [111] = "♛♛♛", -- Triple Joker
- [222] = "♠♠♠", -- Triple Spade
- [333] = "♣♣♣", -- Triple Club
- [444] = "♥♥♥", -- Triple Heart
- [555] = "♦♦♦", -- Triple Diamond
- [666] = "☠☠☠", -- Triple Six
- [777] = "➐➐➐", -- Triple Seven
- [888] = "Ⅲ", -- Three of a Kind
- ["?"] = "?", -- This shouldn't happen
- [1012] = "⑫", [1013] = "⑬", [1014] = "⑭", [1015] = "⑮", [1016] = "⑯", [1017] = "⑰", [1018] = "⑱", [1019] = "⑲", [1020] = "⑳", [1021] = "㉑"
- }
- local suit = {"A",2,3,4,5,6,7,8,9,10,"J","Q","K"}
- local suitTitle = {"♠","♣","♥","♦"} -- joker ♛
- deck = {}
- for ii, title in ipairs(suitTitle) do
- for i, card in ipairs(suit) do
- table.insert(deck, suitTitle[ii]..suit[i])
- if tostring(suitTitle[ii]..suit[i]) == "♣K" or tostring(suitTitle[ii]..suit[i]) == "♦K" then
- table.insert(deck, "♛")
- end
- end
- end
- running = false
- max = #deck
- btnmgr = self
- btnmgr.createButton({ label="Play", click_function="null", function_owner=self, tooltip = "", position={-0.9,1.2,1.3}, rotation = {0,90,-20}, height=0, width=0, font_size=80, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({ label="", click_function="start", function_owner=self, tooltip = "Play", position={-0.9,1.2,1.3}, rotation = {0,90,-20}, height=200, width=300, font_size=80, color = {r=1, g=1, b=1, a=0.1}})
- btnmgr.createButton({ label="♛", click_function="null", function_owner=self, tooltip = "reward", position={-0.9,1.2,-0.13}, rotation = {0,90,-20}, height=0, width=0, font_size=160, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({ label="", click_function="null", function_owner=self, tooltip = "Payout", position={-0.9,1.2,-0.13}, rotation = {0,90,-20}, height=240, width=500, font_size=80, color = {r=203/255, g=163/255, b=233/255, a=0.1}})
- btnmgr.createButton({ label="x0", click_function="null", function_owner=self, tooltip = "x#", position={-0.9,1.2,-1.39}, rotation = {0,90,-20}, height=0, width=0, font_size=80, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({ label="", click_function="null", function_owner=self, tooltip = "Plays Left", position={-0.9,1.2,-1.39}, rotation = {0,90,-20}, height=200, width=220, font_size=80, color = {r=1, g=1, b=1, a=0.1}})
- local baseAngle = 74
- local rowOffset = 0.24
- local slotHeightMid = 2.16
- local slotOffsetMid = -0.17
- local slotHeightTop = slotHeightMid + rowOffset
- local slotOffsetTop = slotOffsetMid+2*(slotHeightTop-slotHeightMid)/math.tan(math.rad(baseAngle))/2
- local slotHeightBot = slotHeightMid - rowOffset
- local slotOffsetBot = slotOffsetMid-2*(slotHeightMid-slotHeightBot)/math.tan(math.rad(baseAngle))/2
- local slotRowLeft = -0.57
- local slotRowMid = 0
- local slotRowRight = 0.57
- local bkgHeight = 430
- local bkgWidth = 235
- local slotFontSize = 120
- baseAngle = baseAngle * -1
- --white bkg
- btnmgr.createButton({label="", click_function="null", function_owner=self, tooltip = self.getName(), position={slotOffsetMid,slotHeightMid,slotRowLeft}, rotation = {0,90,baseAngle}, height=bkgHeight, width=bkgWidth, font_size=80, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({label="", click_function="null", function_owner=self, tooltip = self.getName(), position={slotOffsetMid,slotHeightMid,slotRowMid}, rotation = {0,90,baseAngle}, height=bkgHeight, width=bkgWidth, font_size=80, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({ label="", click_function="null", function_owner=self, tooltip = self.getName(), position={slotOffsetMid,slotHeightMid,slotRowRight}, rotation = {0,90,baseAngle}, height=bkgHeight, width=bkgWidth, font_size=80, color = {r=1, g=1, b=1, a=1}})
- --slots top to bottom, left to right 789, 456, 123
- btnmgr.createButton({label="1", click_function="null", function_owner=self, tooltip = "1", position={slotOffsetBot,slotHeightBot,slotRowLeft}, rotation = {0,90,baseAngle}, height=0, width=0, font_size=slotFontSize, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({label="2", click_function="null", function_owner=self, tooltip = "2", position={slotOffsetBot,slotHeightBot,slotRowMid}, rotation = {0,90,baseAngle}, height=0, width=0, font_size=slotFontSize, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({label="3", click_function="null", function_owner=self, tooltip = "3", position={slotOffsetBot,slotHeightBot,slotRowRight}, rotation = {0,90,baseAngle}, height=0, width=0, font_size=slotFontSize, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({label="4", click_function="null", function_owner=self, tooltip = "4", position={slotOffsetMid,slotHeightMid,slotRowLeft}, rotation = {0,90,baseAngle}, height=0, width=0, font_size=slotFontSize, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({label="5", click_function="null", function_owner=self, tooltip = "5", position={slotOffsetMid,slotHeightMid,slotRowMid}, rotation = {0,90,baseAngle}, height=0, width=0, font_size=slotFontSize, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({label="6", click_function="null", function_owner=self, tooltip = "6", position={slotOffsetMid,slotHeightMid,slotRowRight}, rotation = {0,90,baseAngle}, height=0, width=0, font_size=slotFontSize, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({label="7", click_function="null", function_owner=self, tooltip = "7", position={slotOffsetTop,slotHeightTop,slotRowLeft}, rotation = {0,90,baseAngle}, height=0, width=0, font_size=slotFontSize, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({label="8", click_function="null", function_owner=self, tooltip = "8", position={slotOffsetTop,slotHeightTop,slotRowMid}, rotation = {0,90,baseAngle}, height=0, width=0, font_size=slotFontSize, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({label="9", click_function="null", function_owner=self, tooltip = "9", position={slotOffsetTop,slotHeightTop,slotRowRight}, rotation = {0,90,baseAngle}, height=0, width=0, font_size=slotFontSize, color = {r=1, g=1, b=1, a=1}})
- if jackpot == nil or jackpot == 0 or jackpot == "0" then
- jackpot = 50
- end
- if mjackpot == nil or mjackpot == 0 or mjackpot == "0" then
- mjackpot = 20
- end
- btnmgr.createButton({label=jackpot.."x", click_function="null", function_owner=self, tooltip = "Jackpot", position={-0.4,1.53,-1.2}, height=0, width=0, rotation = {0,90,baseAngle}, font_size=120, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({label="", click_function="null", function_owner=self, tooltip = "Jackpot", position={-0.4,1.53,-1.2}, height=300, width=600, rotation = {0,90,baseAngle}, font_size=120, color = {r=1, g=1, b=1, a=0}})
- btnmgr.createButton({label=mjackpot.."x", click_function="null", function_owner=self, tooltip = "Mini Jackpot", position={-0.4,1.53,1.25}, height=0, width=0, rotation = {0,90,baseAngle}, font_size=120, color = {r=1, g=1, b=1, a=1}})
- btnmgr.createButton({label="", click_function="null", function_owner=self, tooltip = "Mini Jackpot", position={-0.4,1.53,1.25}, height=300, width=600, rotation = {0,90,baseAngle}, font_size=120, color = {r=1, g=1, b=1, a=0}})
- if instant then
- rollDelayTick = 0.04
- rollDelay = 0.15
- rollAmount = 3
- rollOffset = 1
- end
- minute = 60
- hour = minute*60
- day = hour*24
- regenTime = minutesPerRegen*minute
- desc = "Payouts are processed in the order listed:\n[ffffff]Joker [-][CAA2E8]|[-][ffffff] 2:1[-]\n[ffffff]Double Joker [-][CAA2E8]|[-][12930F] 10:1[-]\n[ffffff]Triple Joker [-][CAA2E8]|[-][12930F] Jackpot x2[-]\n[ffffff]666 [-][CAA2E8]|[-][930F0F] Lose[-]\n[ffffff]777 [-][CAA2E8]|[-][12930F] Jackpot[-]\n[ffffff]3-17 [-][CAA2E8]|[-][930F0F] Lose[-] [ffffff] or Other Reward[-]\n[ffffff]18-21 [-][CAA2E8]|[-][ffffff] 2:1 or Other Reward[-]\n[ffffff]22-29 [-][CAA2E8]|[-][930F0F] Lose[-]\n[ffffff]30 [-][CAA2E8]|[-][ffffff] Push[-]\n\n[ffffff]Hands that are 21 and under also qualify for:[-]\n[ffffff]Three of a Kind [-][CAA2E8]|[-][12930F] Mini Jackpot[-]\n[ffffff]Triple Spades [-][CAA2E8]|[-][ffffff] 20 Powerups[-]\n[ffffff]Triple Clubs [-][CAA2E8]|[-][ffffff] 8 Rupee Pulls[-]\n[ffffff]Triple Hearts [-][CAA2E8]|[-][ffffff] 1:1, 5 Powerups, 5 Rupee Pulls, 1 Daily[-]\n[ffffff]Triple Diamonds [-][CAA2E8]|[-][ffffff] 4 Daily Tokens[-]"
- self.setDescription(desc)
- end
- function onSave()
- statistics = {plays = plays, tokensPaid = tokensPaid, pupsPaid = pupsPaid, rupsPaid = rupsPaid, dailysPaid = dailysPaid, jackpot = jackpot, mjackpot = mjackpot}
- return JSON.encode({playerSaves, statistics})
- end
- function start(container, color)
- if not running then
- col = color
- if bag == nil then printToAll("Slot Machine Error: Please assign a valid GUID to bag at the top of the config.", {1,1,1}) end
- if colTok == nil then printToAll("Slot Machine Error: Please assign a valid GUID to colTok at the top of the config.", {1,1,1}) end
- if randRup == nil then printToAll("Slot Machine Error: Please assign a valid GUID to randRup at the top of the config.", {1,1,1}) end
- if randPup == nil then printToAll("Slot Machine Error: Please assign a valid GUID to randPup at the top of the config.", {1,1,1}) end
- if dailyTok == nil then printToAll("Slot Machine Error: Please assign a valid GUID to dailyTok at the top of the config.", {1,1,1}) end
- if devil == nil then printToAll("Slot Machine Error: Please assign a valid GUID to devil at the top of the config.", {1,1,1}) end
- if gold == nil then printToAll("Slot Machine Error: Please assign a valid GUID to gold at the top of the config.", {1,1,1}) end
- if silver == nil then printToAll("Slot Machine Error: Please assign a valid GUID to silver at the top of the config.", {1,1,1}) end
- if bronze == nil then printToAll("Slot Machine Error: Please assign a valid GUID to bronze at the top of the config.", {1,1,1}) end
- if self.getDescription() == "i shouldn't do this unless i know i have to" then --not recommended
- playerSaves = {}
- plays = 0
- tokensPaid = 0
- pupsPaid = 0
- rupsPaid = 0
- dailysPaid = 0
- jackpot = 50
- mjackpot = 20
- broadcastToAll("Slot Machine has been manually reset by an admin.", {1,1,1})
- end
- if self.getDescription() == "reset" or self.getDescription() == "reset save" then --use this first if you have issues with saves or turns
- playerSaves = {}
- broadcastToAll("Slot Machine saves have been manually reset by an admin.", {1,1,1})
- end
- if self.getDescription() == "max jackpots" then --use this first if you have issues with saves or turns
- jackpot = 200
- mjackpot = 50
- broadcastToAll("Slot Machine Jackpots have been given a huge boost!", {1,1,1})
- end
- if self.getDescription() == "stats" then
- broadcastToColor("Plays: "..plays, col, {1,1,1})
- broadcastToColor("Tokens Paid: "..tokensPaid, col, {1,1,1})
- broadcastToColor("Pups Paid: "..pupsPaid, col, {1,1,1})
- broadcastToColor("Rups Paid: "..rupsPaid, col, {1,1,1})
- broadcastToColor("Dailys Paid: "..dailysPaid, col, {1,1,1})
- end
- if self.getDescription() ~= desc then
- self.setDescription(desc)
- end
- if hasTurn() then
- btnmgr.editButton({index = 4, label = "x"..playerSaves[Player[col].steam_id].turnsLeft})
- btnmgr.editButton({index = 5, tooltip = Player[col].steam_name.."'s Turns Left"})
- if insertToken() then
- running = true
- startLuaCoroutine(self, "play")
- else
- broadcastToColor(tostring("Please insert 1x Collectable Token or Daily Login Token."), col, {1,0.25,0.25})
- end
- end
- else
- broadcastToColor(tostring("Slot machine is already running."), color, {1,0.25,0.25})
- end
- end
- function play()
- plays = plays + 1
- loss = false
- rollSlots(newSlots())
- local payout = tostring(checkPayout())
- local payoutInt = tonumber(payout)
- btnmgr.editButton({index = 2, label = payoutIcon[payoutInt]})
- if payoutInt > 1000 then
- payoutInt = payoutInt - 1000
- payout = tostring(payoutInt - 1000)
- end
- if payout == "21" then
- broadcastToColor(tostring("You got 21! 2:1 Payout"), col, {1,1,1})
- spawnItems(self, colTok, 2)
- elseif payoutInt < 18 then
- loss = true
- broadcastToColor(tostring("You lost with "..payoutInt.."."), col, {1,1,1})
- elseif payoutInt < 21 then
- broadcastToColor(tostring("You got "..payoutInt..". 2:1 Payout"), col, {1,1,1})
- spawnItems(self, colTok, 2)
- elseif payout == "22" then --oof
- loss = true
- broadcastToColor(tostring("You bust!"), col, {1,1,1})
- elseif payout == "100" then
- broadcastToColor(tostring("You got a Joker! 2:1 Payout"), col, {1,1,1})
- spawnItems(self, colTok, 2)
- elseif payout == "110" then
- broadcastToColor(tostring("You got a Double Joker! 10:1 Payout"), col, {1,1,1})
- spawnTrophy(self, bronze, 0, col, "Bronze")
- spawnItems(self, colTok, 10)
- waitTime(1)
- payoutbag.unlock()
- elseif payout == "111" then
- broadcastToAll(Player[col].steam_name.." hit the Mega Jackpot of "..math.floor(jackpot*2).." Collectable Tokens!", {1,1,1})
- spawnTrophy(self, gold, 0, col, "Mega Jackpot")
- spawnItems(self, colTok, math.floor(jackpot*2))
- waitTime(1)
- payoutbag.unlock()
- jackpot = 50
- elseif payout == "30" then
- broadcastToColor(tostring("You pushed with a 30. 1:1 Payout"), col, {1,1,1})
- spawnItems(self, colTok, 1)
- elseif payout == "222" then
- broadcastToColor(tostring("You got Triple Spades! 20 Random Powerups"), col, {1,1,1})
- spawnItem(self, bag, 0, col, "Triple Spades")
- spawnItems(self, randPup, 20)
- waitTime(1)
- payoutbag.unlock()
- elseif payout == "333" then
- broadcastToColor(tostring("You got Triple Clubs! 8 Random Rupee Pulls"), col, {1,1,1})
- spawnItem(self, bag, 0, col, "Triple Clubs")
- spawnItems(self, randRup, 8)
- waitTime(1)
- payoutbag.unlock()
- elseif payout == "444" then
- broadcastToColor(tostring("You got Triple Hearts!\n5 Random Powerups, 5 Random Rupee Pulls, 1:1 Payout, and 1 Daily Login Token"), col, {1,1,1})
- spawnItem(self, bag, 0, col, "Triple Hearts")
- spawnItems(self, randPup, 5)
- spawnItems(self, randRup, 5)
- spawnItems(self, colTok, 1)
- spawnItems(self, dailyTok, 1)
- waitTime(1)
- payoutbag.unlock()
- elseif payout == "555" then
- broadcastToColor(tostring("You got Triple Diamonds! 4 Daily Login Tokens"), col, {1,1,1})
- spawnItem(self, bag, 0, col, "Triple Diamonds")
- spawnItems(self, dailyTok, 4)
- waitTime(1)
- payoutbag.unlock()
- elseif payout == "666" then --oof
- broadcastToColor(tostring("You lost with a 666!"), col, {1,1,1})
- spawnTrophy(self, devil, 0, col, "Devil")
- payoutbag.unlock()
- elseif payout == "777" then
- broadcastToAll(Player[col].steam_name.." hit the Jackpot of "..math.floor(jackpot).." Collectable Tokens!", {1,1,1})
- spawnTrophy(self, gold, 0, col, "Jackpot")
- spawnItems(self, colTok, math.floor(jackpot))
- waitTime(1)
- payoutbag.unlock()
- jackpot = 50
- elseif payout == "888" then
- broadcastToAll(Player[col].steam_name.." hit the Mini Jackpot of "..math.floor(mjackpot).." Collectable Tokens!", {1,1,1})
- spawnTrophy(self, silver, 0, col, "Mini Jackpot")
- spawnItems(self, colTok, math.floor(mjackpot))
- payoutbag.unlock()
- waitTime(1)
- mjackpot = 20
- elseif payout == "?" then
- broadcastToColor(tostring("??? We're not sure what you rolled.\nPlease send this to the Developer with a screenshot of the slot machine.\nBet returned."), col, {1,1,1})
- spawnItems(self, colTok, 1)
- else
- broadcastToColor(tostring("!!! We're not sure what you rolled.\nPlease send this to the Developer with a screenshot of the slot machine.\nBet returned."), col, {1,1,1})
- spawnItems(self, colTok, 1)
- end
- if loss then
- if jackpot < 200 then
- jackpot = jackpot + 0.1
- end
- if mjackpot < 25 then
- mjackpot = mjackpot + 0.1
- end
- end
- if requiresTurn then
- playerSaves[Player[col].steam_id].lastDatePlayed = os.date("%m%d")
- playerSaves[Player[col].steam_id].lastTimePlayed = os.time()
- playerSaves[Player[col].steam_id].turnsLeft = playerSaves[Player[col].steam_id].turnsLeft - 1
- end
- btnmgr.editButton({index = 4, label = "x"..playerSaves[Player[col].steam_id].turnsLeft})
- btnmgr.editButton({index = 5, tooltip = Player[col].steam_name.."'s Plays Left"})
- btnmgr.editButton({index = 18, label=math.floor(jackpot).."x"})
- btnmgr.editButton({index = 20, label=math.floor(mjackpot).."x"})
- running = false
- return 1
- end
- function checkPayout()
- local hasAce = false
- local isSoft = false
- local aa = string.sub(a, 1, 1)
- local ab = string.sub(a, 2, 2)
- local ba = string.sub(b, 1, 1)
- local bb = string.sub(b, 2, 2)
- local ca = string.sub(c, 1, 1)
- local cb = string.sub(c, 2, 2)
- if a == "♛" or b == "♛" or c == "♛" then
- if a == "♛" and b == "♛" and c == "♛" then return 111
- elseif (a == "♛" and b == "♛") or (b == "♛" and c == "♛") or (a == "♛" and c == "♛") then return 110
- else return 100 end
- elseif ab == "6" and bb == "6" and cb == "6" then return 666
- elseif ab == "7" and bb == "7" and cb == "7" then return 777 end
- if ab == "A" and bb == "A" and cb == "A" then return 888
- if ab == "A" then ab = 11; hasAce = true end
- if bb == "A" and hasAce == true then bb = 1 end
- if bb == "A" and hasAce == false then bb = 11; hasAce = true end
- if cb == "A" and hasAce == true then cb = 1 end
- if cb == "A" and hasAce == false then cb = 11; hasAce = true end
- if ab == "1" then ab = 10
- elseif ab == "J" then ab = 10
- elseif ab == "Q" then ab = 10
- elseif ab == "K" then ab = 10 end
- if bb == "1" then bb = 10
- elseif bb == "J" then bb = 10
- elseif bb == "Q" then bb = 10
- elseif bb == "K" then bb = 10 end
- if cb == "1" then cb = 10
- elseif cb == "J" then cb = 10
- elseif cb == "Q" then cb = 10
- elseif cb == "K" then cb = 10 end
- abc = ab + bb + cb
- if abc > 21 then if hasAce then abc = abc - 10; isSoft = true end end
- if abc > 29 then return 30
- elseif abc > 21 then return 22
- elseif ab == bb and ab == cb and abc < 21 then return 888
- elseif aa == "♠" and ba == "♠" and ca == "♠" then return 222
- elseif aa == "♣" and ba == "♣" and ca == "♣" then return 333
- elseif aa == "♥" and ba == "♥" and ca == "♥" then return 444
- elseif aa == "♦" and ba == "♦" and ca == "♦" then return 555
- elseif abc == 21 then return 21
- elseif abc > 0 and abc < 21 then
- if isSoft then
- return 1000 + abc
- else
- return abc
- end
- else
- return "?"
- end
- end
- function newSlots()
- local four = 0
- local five = 0
- local six = 0
- if rigged then
- four = rigOne
- five = rigTwo
- six = rigThree
- else
- four = math.random(max)
- five = math.random(max)
- six = math.random(max)
- end
- return four, five, six
- end
- function rollSlots(four, five, six)
- local iFour = rollAmount - rollOffset
- local iFive = rollAmount
- local iSix = rollAmount + rollOffset
- local lastIFour = iFour
- local lastIFive = iFive
- local lastISix = iSix
- local delayMultFour = os.time()-1
- local delayMultFive = os.time()-1
- local delayMultSix = os.time()-1
- while iSix ~= 0 do
- if iFour > 0 and os.time() > delayMultFour then
- delayMultFourOverflow = os.time() - delayMultFour
- iFour = iFour - 1
- delayMultFour = rollCurveMult*rollCurveExp^(-0.7*iFour+1)+1
- if delayMultFour > 20 then
- delayMultFour = 20 * rollDelay
- else
- delayMultFour = delayMultFour * rollDelay
- end
- delayMultFour = delayMultFour + os.time() - delayMultFourOverflow
- lastIFour = iFour
- end
- if iFive > 0 and os.time() > delayMultFive then
- delayMultFiveOverflow = os.time() - delayMultFive
- iFive = iFive - 1
- delayMultFive = rollCurveMult*rollCurveExp^(-0.7*iFive+1)+1
- if delayMultFive > 20 then
- delayMultFive = 20 * rollDelay
- else
- delayMultFive = delayMultFive * rollDelay
- end
- delayMultFive = delayMultFive + os.time() - delayMultFiveOverflow
- lastIFive = iFive
- end
- if iSix > 0 and os.time() > delayMultSix then
- delayMultSixOverflow = os.time() - delayMultSix
- iSix = iSix - 1
- delayMultSix = rollCurveMult*rollCurveExp^(-0.7*iSix+1)+1
- if delayMultSix > 20 then
- delayMultSix = 20 * rollDelay
- else
- delayMultSix = delayMultSix * rollDelay
- end
- delayMultSix = delayMultSix + os.time() - delayMultSixOverflow
- lastISix = iSix
- end
- if lastIFour == iFour or lastIFive == iFive or lastISix == iSix then
- setSlots(getSlotDisplay(four+iFour, five+iFive, six+iSix))
- end
- waitTime(rollDelayTick)
- end
- end
- function getSlotDisplay(four, five, six)
- if four > max then
- four = four % max
- elseif four == 0 then
- four = max
- end
- if five > max then
- five = five % max
- elseif five == 0 then
- five = max
- end
- if six > max then
- six = six % max
- elseif six == 0 then
- six = max
- end
- local one = ""
- local seven = ""
- if four + 1 > max then one = 1 else one = four + 1 end
- if four - 1 == 0 then seven = max else seven = four - 1 end
- local two = ""
- local eight = ""
- if five + 1 > max then two = 1 else two = five + 1 end
- if five - 1 == 0 then eight = max else eight = five - 1 end
- local three = ""
- local nine = ""
- if six + 1 > max then three = 1 else three = six + 1 end
- if six - 1 == 0 then nine = max else nine = six - 1 end
- return one, two, three, four, five, six, seven, eight, nine
- end
- function setSlots(one, two, three, four, five, six, seven, eight, nine)
- a, b, c = deck[four], deck[five], deck[six]
- btnmgr.editButton({index = 9, label = deck[one]})
- btnmgr.editButton({index = 10, label = deck[two]})
- btnmgr.editButton({index = 11, label = deck[three]})
- btnmgr.editButton({index = 12, label = deck[four]})
- btnmgr.editButton({index = 13, label = deck[five]})
- btnmgr.editButton({index = 14, label = deck[six]})
- btnmgr.editButton({index = 15, label = deck[seven]})
- btnmgr.editButton({index = 16, label = deck[eight]})
- btnmgr.editButton({index = 17, label = deck[nine]})
- end
- function spawnItems(targetZone, item, amount)
- if item == colTok then
- tokensPaid = tokensPaid + amount
- end
- if item == randRup then
- pupsPaid = pupsPaid + amount
- end
- if item == randPup then
- rupsPaid = rupsPaid + amount
- end
- if item == dailyTok then
- dailysPaid = dailysPaid + amount
- end
- local params = {}
- params.smooth = false
- params.position = targetZone.getPosition()
- params.position.x = spawnLoc.x
- params.position.y = params.position.y + 3
- params.position.z = spawnLoc.z
- for i=1,amount,1 do
- params.position.y = params.position.y
- takenObject = item.takeObject(params)
- waitTime(0.1)
- end
- end
- function spawnItem(targetZone, item, heightOffset, color, title)
- local params = {}
- params.smooth = false
- params.position = targetZone.getPosition()
- params.position.x = spawnLoc.x
- params.position.y = params.position.y + (heightOffset or 0) - 1
- params.position.z = spawnLoc.z
- takenObject = item.takeObject(params)
- if color ~= "" and color ~= nil then
- takenObject.setColorTint(stringColorToRGB(color))
- if string.sub(Player[col].steam_name, -1) == 's' then
- takenObject.setName(tostring(Player[col].steam_name).."' "..tostring(title).." Bag")
- else
- takenObject.setName(tostring(Player[col].steam_name).."'s "..tostring(title).." Bag")
- end
- end
- if item == bag then
- payoutbag = takenObject
- payoutbag.lock()
- takenObject.setDescription(tostring(Player[col].steam_id))
- end
- waitTime(1)
- end
- function spawnTrophy(targetZone, item, heightOffset, color, title)
- local params = {}
- params.smooth = false
- params.position = targetZone.getPosition()
- params.position.x = spawnLoc.x
- params.position.y = params.position.y + (heightOffset or 0) - 1
- params.position.z = spawnLoc.z
- print(item)
- payoutbag = item.takeObject(params)
- payoutbag.lock()
- payoutbag.setDescription(tostring(Player[col].steam_id))
- waitTime(1)
- end
- function insertToken()
- if not requiresToken then
- return true
- end
- for i, obj in pairs(self.getObjects()) do
- if obj.name == "Collectable Token" or obj.name == "Daily Login Token" then
- local params = {}
- params.guid = obj.guid
- params.smooth = true
- params.position = self.getPosition()
- params.position.y = params.position.y + 4
- takenObject = self.takeObject(params)
- takenObject.destruct()
- return true
- end
- end
- return false
- end
- function hasTurn()
- if not requiresTurn then
- return true
- end
- if playerSaves[Player[col].steam_id] ~= nil and playerSaves[Player[col].steam_id] ~= "" and playerSaves[Player[col].steam_id] ~= {} then --does save exists
- if playerSaves[Player[col].steam_id].lastDatePlayed ~= os.date("%m%d") then --has not played today
- playerSaves[Player[col].steam_id].turnsLeft = turnsPerRegen
- playerSaves[Player[col].steam_id].turnRegensLeft = turnsPerDay - turnsPerRegen
- return true
- else
- if playerSaves[Player[col].steam_id].turnsLeft ~= nil and playerSaves[Player[col].steam_id].turnsLeft ~= "" and playerSaves[Player[col].steam_id].turnsLeft ~= {} and playerSaves[Player[col].steam_id].turnsLeft > 0 then --has turns
- return true
- else
- if playerSaves[Player[col].steam_id].lastTimePlayed + regenTime > os.time() then --can't regen turns
- if playerSaves[Player[col].steam_id].turnRegensLeft >= turnsPerRegen then --has turn regens left
- broadcastToColor("You don't have any turns left!\nYou'll get "..turnsPerRegen.." more in "..timeTillNextTurn()..".", col, {1,0.25,0.25})
- return false
- else --get more next day
- broadcastToColor("You ran out of turns for the day!\nYou'll get more in "..timeTillNextDay()..".", col, {1,0.25,0.25})
- return false
- end
- else
- if playerSaves[Player[col].steam_id].turnRegensLeft >= turnsPerRegen then --has turn regens
- playerSaves[Player[col].steam_id].turnsLeft = turnsPerRegen
- playerSaves[Player[col].steam_id].turnRegensLeft = playerSaves[Player[col].steam_id].turnRegensLeft - turnsPerRegen
- return true
- else
- broadcastToColor("You ran out of turns for the day!\nYou'll get more in "..timeTillNextDay()".", col, {1,0.25,0.25})
- return false
- end
- end
- end
- end
- end
- playerSaves[Player[col].steam_id] = {}
- playerSaves[Player[col].steam_id].turnsLeft = turnsPerRegen
- playerSaves[Player[col].steam_id].turnRegensLeft = turnsPerDay - turnsPerRegen
- return true
- end
- function timeTillNextDay()
- local timeTill = ""
- if tonumber(os.date("%H")) < 23 then
- timeTill = timeTill..23-os.date("%H").." hours, "
- end
- if tonumber(os.date("%M")) < 59 then
- timeTill = timeTill..59-os.date("%M").." minutes and "
- end
- timeTill = timeTill..60-os.date("%S").." seconds"
- return timeTill
- end
- function timeTillNextTurn()
- local timeTill = (playerSaves[Player[col].steam_id].lastTimePlayed + regenTime) - os.time()
- local formattedTimeTill = ""
- if timeTill > 60 then
- formattedTimeTill = formattedTimeTill..((timeTill-(timeTill%60))/60).." minutes and "
- end
- formattedTimeTill = formattedTimeTill..(math.floor(timeTill%60)).." seconds"
- return formattedTimeTill
- end
- function waitTime(tm)
- local endTime = os.time() + tm
- while os.time() < endTime do
- coroutine.yield(0)
- end
- end
- function null()
- end
- ----
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement