Advertisement
Guest User

Untitled

a guest
Apr 26th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.75 KB | None | 0 0
  1. --[[ Mira's Slot Machine ]]--
  2.  
  3. function onLoad(save_state)
  4. -- begin config --
  5.  
  6. bag = getObjectFromGUID("903a88")
  7. colTok = getObjectFromGUID("f696c4")
  8. randRup = getObjectFromGUID("ea79f0")
  9. randPup = getObjectFromGUID("737b2a")
  10. dailyTok = getObjectFromGUID("b5d1b0")
  11. --Trophies
  12. devil = getObjectFromGUID("b81e2c")
  13. gold = getObjectFromGUID("8a9b91")
  14. silver = getObjectFromGUID("92be74")
  15. bronze = getObjectFromGUID("11479f")
  16.  
  17. rigged = false
  18. rigOne = 9
  19. rigTwo = 9
  20. rigThree = 9
  21.  
  22. instant = true
  23. rollDelayTick = 0.04
  24. rollDelay = 0.15
  25. rollAmount = 25
  26. rollOffset = 10
  27.  
  28. requiresTurn = true
  29. requiresToken = true
  30.  
  31. --affects the speed at which the individual slots slow down
  32. --rollCurveMult*rollCurveExp^(-0.7*i+1)+1 where rollCurveExp is 1 or greater and i is the amount of roll ticks left
  33. --https://www.desmos.com/calculator/uckzjegsoz
  34. rollCurveMult = 1.8*0.4
  35. rollCurveExp = 1.3
  36. spawnLoc = self.getPosition()
  37. spawnLoc.x = spawnLoc.x + 4
  38. spawnLoc.y = spawnLoc.y + 0
  39. spawnLoc.z = spawnLoc.z + 0
  40.  
  41. turnsPerRegen = 12
  42. minutesPerRegen = 20 --how long it takes to regen turns
  43. turnsPerDay = 9999
  44.  
  45. -- end config --
  46.  
  47. save = {} --{{playerSaves},{statistics}}
  48. playerSaves = {} --{steam_id={dateLastPlayed, turnsLeft, turnRegensLeft}}
  49. statistics = {} --{lastDatePlayed, lastTimePlayed, turnsLeft, turnRegensLeft}
  50. plays = 0
  51. tokensPaid = 0
  52. pupsPaid = 0
  53. rupsPaid = 0
  54. dailysPaid = 0
  55. jackpot = 0
  56. mjackpot = 0
  57. save = JSON.decode(save_state)
  58. if #save == 2 then
  59. playerSaves = save[1]
  60. statistics = save[2]
  61. if statistics.plays ~= nil then plays = statistics.plays end
  62. if statistics.tokensPaid ~= nil then tokensPaid = statistics.tokensPaid end
  63. if statistics.pupsPaid ~= nil then pupsPaid = statistics.pupsPaid end
  64. if statistics.rupsPaid ~= nil then rupsPaid = statistics.rupsPaid end
  65. if statistics.dailysPaid ~= nil then dailysPaid = statistics.dailysPaid end
  66. if statistics.jackpot ~= nil then jackpot = statistics.jackpot end
  67. if statistics.mjackpot ~= nil then mjackpot = statistics.mjackpot end
  68. else
  69. print("Error finding Slot Machine save_state.\nsave_state is empty or wrong size: #save="..#save)
  70. end
  71.  
  72. payoutIcon = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,
  73. [21] = "♤", -- Blackjack/21
  74. [22] = "☠", -- Bust
  75. [100] = "♛", -- Joker
  76. [110] = "♛♛", -- Double Joker
  77. [111] = "♛♛♛", -- Triple Joker
  78. [222] = "♠♠♠", -- Triple Spade
  79. [333] = "♣♣♣", -- Triple Club
  80. [444] = "♥♥♥", -- Triple Heart
  81. [555] = "♦♦♦", -- Triple Diamond
  82. [666] = "☠☠☠", -- Triple Six
  83. [777] = "➐➐➐", -- Triple Seven
  84. [888] = "Ⅲ", -- Three of a Kind
  85. ["?"] = "?", -- This shouldn't happen
  86. [1012] = "⑫", [1013] = "⑬", [1014] = "⑭", [1015] = "⑮", [1016] = "⑯", [1017] = "⑰", [1018] = "⑱", [1019] = "⑲", [1020] = "⑳", [1021] = "㉑"
  87. }
  88.  
  89. local suit = {"A",2,3,4,5,6,7,8,9,10,"J","Q","K"}
  90. local suitTitle = {"♠","♣","♥","♦"} -- joker ♛
  91. deck = {}
  92. for ii, title in ipairs(suitTitle) do
  93. for i, card in ipairs(suit) do
  94. table.insert(deck, suitTitle[ii]..suit[i])
  95. if tostring(suitTitle[ii]..suit[i]) == "♣K" or tostring(suitTitle[ii]..suit[i]) == "♦K" then
  96. table.insert(deck, "♛")
  97. end
  98. end
  99. end
  100. running = false
  101. max = #deck
  102. btnmgr = self
  103. 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}})
  104. 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}})
  105.  
  106. 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}})
  107. 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}})
  108.  
  109. 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}})
  110. 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}})
  111. local baseAngle = 74
  112. local rowOffset = 0.24
  113. local slotHeightMid = 2.16
  114. local slotOffsetMid = -0.17
  115. local slotHeightTop = slotHeightMid + rowOffset
  116. local slotOffsetTop = slotOffsetMid+2*(slotHeightTop-slotHeightMid)/math.tan(math.rad(baseAngle))/2
  117. local slotHeightBot = slotHeightMid - rowOffset
  118. local slotOffsetBot = slotOffsetMid-2*(slotHeightMid-slotHeightBot)/math.tan(math.rad(baseAngle))/2
  119. local slotRowLeft = -0.57
  120. local slotRowMid = 0
  121. local slotRowRight = 0.57
  122. local bkgHeight = 430
  123. local bkgWidth = 235
  124. local slotFontSize = 120
  125.  
  126. baseAngle = baseAngle * -1
  127. --white bkg
  128. 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}})
  129. 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}})
  130. 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}})
  131.  
  132. --slots top to bottom, left to right 789, 456, 123
  133. 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}})
  134. 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}})
  135. 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}})
  136. 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}})
  137. 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}})
  138. 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}})
  139. 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}})
  140. 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}})
  141. 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}})
  142.  
  143.  
  144. if jackpot == nil or jackpot == 0 or jackpot == "0" then
  145. jackpot = 50
  146. end
  147. if mjackpot == nil or mjackpot == 0 or mjackpot == "0" then
  148. mjackpot = 20
  149. end
  150. 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}})
  151. 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}})
  152. 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}})
  153. 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}})
  154.  
  155. if instant then
  156. rollDelayTick = 0.04
  157. rollDelay = 0.15
  158. rollAmount = 3
  159. rollOffset = 1
  160. end
  161.  
  162. minute = 60
  163. hour = minute*60
  164. day = hour*24
  165. regenTime = minutesPerRegen*minute
  166.  
  167. 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[-]"
  168. self.setDescription(desc)
  169. end
  170.  
  171. function onSave()
  172. statistics = {plays = plays, tokensPaid = tokensPaid, pupsPaid = pupsPaid, rupsPaid = rupsPaid, dailysPaid = dailysPaid, jackpot = jackpot, mjackpot = mjackpot}
  173. return JSON.encode({playerSaves, statistics})
  174. end
  175.  
  176. function start(container, color)
  177. if not running then
  178. col = color
  179. 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
  180. 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
  181. 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
  182. 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
  183. 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
  184. 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
  185. 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
  186. 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
  187. 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
  188. if self.getDescription() == "i shouldn't do this unless i know i have to" then --not recommended
  189. playerSaves = {}
  190. plays = 0
  191. tokensPaid = 0
  192. pupsPaid = 0
  193. rupsPaid = 0
  194. dailysPaid = 0
  195. jackpot = 50
  196. mjackpot = 20
  197. broadcastToAll("Slot Machine has been manually reset by an admin.", {1,1,1})
  198. end
  199. if self.getDescription() == "reset" or self.getDescription() == "reset save" then --use this first if you have issues with saves or turns
  200. playerSaves = {}
  201. broadcastToAll("Slot Machine saves have been manually reset by an admin.", {1,1,1})
  202. end
  203. if self.getDescription() == "max jackpots" then --use this first if you have issues with saves or turns
  204. jackpot = 200
  205. mjackpot = 50
  206. broadcastToAll("Slot Machine Jackpots have been given a huge boost!", {1,1,1})
  207. end
  208. if self.getDescription() == "stats" then
  209. broadcastToColor("Plays: "..plays, col, {1,1,1})
  210. broadcastToColor("Tokens Paid: "..tokensPaid, col, {1,1,1})
  211. broadcastToColor("Pups Paid: "..pupsPaid, col, {1,1,1})
  212. broadcastToColor("Rups Paid: "..rupsPaid, col, {1,1,1})
  213. broadcastToColor("Dailys Paid: "..dailysPaid, col, {1,1,1})
  214. end
  215. if self.getDescription() ~= desc then
  216. self.setDescription(desc)
  217. end
  218. if hasTurn() then
  219. btnmgr.editButton({index = 4, label = "x"..playerSaves[Player[col].steam_id].turnsLeft})
  220. btnmgr.editButton({index = 5, tooltip = Player[col].steam_name.."'s Turns Left"})
  221. if insertToken() then
  222. running = true
  223. startLuaCoroutine(self, "play")
  224. else
  225. broadcastToColor(tostring("Please insert 1x Collectable Token or Daily Login Token."), col, {1,0.25,0.25})
  226. end
  227. end
  228. else
  229. broadcastToColor(tostring("Slot machine is already running."), color, {1,0.25,0.25})
  230. end
  231. end
  232.  
  233. function play()
  234. plays = plays + 1
  235. loss = false
  236. rollSlots(newSlots())
  237. local payout = tostring(checkPayout())
  238. local payoutInt = tonumber(payout)
  239. btnmgr.editButton({index = 2, label = payoutIcon[payoutInt]})
  240. if payoutInt > 1000 then
  241. payoutInt = payoutInt - 1000
  242. payout = tostring(payoutInt - 1000)
  243. end
  244. if payout == "21" then
  245. broadcastToColor(tostring("You got 21! 2:1 Payout"), col, {1,1,1})
  246. spawnItems(self, colTok, 2)
  247. elseif payoutInt < 18 then
  248. loss = true
  249. broadcastToColor(tostring("You lost with "..payoutInt.."."), col, {1,1,1})
  250. elseif payoutInt < 21 then
  251. broadcastToColor(tostring("You got "..payoutInt..". 2:1 Payout"), col, {1,1,1})
  252. spawnItems(self, colTok, 2)
  253. elseif payout == "22" then --oof
  254. loss = true
  255. broadcastToColor(tostring("You bust!"), col, {1,1,1})
  256. elseif payout == "100" then
  257. broadcastToColor(tostring("You got a Joker! 2:1 Payout"), col, {1,1,1})
  258. spawnItems(self, colTok, 2)
  259. elseif payout == "110" then
  260. broadcastToColor(tostring("You got a Double Joker! 10:1 Payout"), col, {1,1,1})
  261. spawnTrophy(self, bronze, 0, col, "Bronze")
  262. spawnItems(self, colTok, 10)
  263. waitTime(1)
  264. payoutbag.unlock()
  265. elseif payout == "111" then
  266. broadcastToAll(Player[col].steam_name.." hit the Mega Jackpot of "..math.floor(jackpot*2).." Collectable Tokens!", {1,1,1})
  267. spawnTrophy(self, gold, 0, col, "Mega Jackpot")
  268. spawnItems(self, colTok, math.floor(jackpot*2))
  269. waitTime(1)
  270. payoutbag.unlock()
  271. jackpot = 50
  272. elseif payout == "30" then
  273. broadcastToColor(tostring("You pushed with a 30. 1:1 Payout"), col, {1,1,1})
  274. spawnItems(self, colTok, 1)
  275. elseif payout == "222" then
  276. broadcastToColor(tostring("You got Triple Spades! 20 Random Powerups"), col, {1,1,1})
  277. spawnItem(self, bag, 0, col, "Triple Spades")
  278. spawnItems(self, randPup, 20)
  279. waitTime(1)
  280. payoutbag.unlock()
  281. elseif payout == "333" then
  282. broadcastToColor(tostring("You got Triple Clubs! 8 Random Rupee Pulls"), col, {1,1,1})
  283. spawnItem(self, bag, 0, col, "Triple Clubs")
  284. spawnItems(self, randRup, 8)
  285. waitTime(1)
  286. payoutbag.unlock()
  287. elseif payout == "444" then
  288. 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})
  289. spawnItem(self, bag, 0, col, "Triple Hearts")
  290. spawnItems(self, randPup, 5)
  291. spawnItems(self, randRup, 5)
  292. spawnItems(self, colTok, 1)
  293. spawnItems(self, dailyTok, 1)
  294. waitTime(1)
  295. payoutbag.unlock()
  296. elseif payout == "555" then
  297. broadcastToColor(tostring("You got Triple Diamonds! 4 Daily Login Tokens"), col, {1,1,1})
  298. spawnItem(self, bag, 0, col, "Triple Diamonds")
  299. spawnItems(self, dailyTok, 4)
  300. waitTime(1)
  301. payoutbag.unlock()
  302. elseif payout == "666" then --oof
  303. broadcastToColor(tostring("You lost with a 666!"), col, {1,1,1})
  304. spawnTrophy(self, devil, 0, col, "Devil")
  305. payoutbag.unlock()
  306. elseif payout == "777" then
  307. broadcastToAll(Player[col].steam_name.." hit the Jackpot of "..math.floor(jackpot).." Collectable Tokens!", {1,1,1})
  308. spawnTrophy(self, gold, 0, col, "Jackpot")
  309. spawnItems(self, colTok, math.floor(jackpot))
  310. waitTime(1)
  311. payoutbag.unlock()
  312. jackpot = 50
  313. elseif payout == "888" then
  314. broadcastToAll(Player[col].steam_name.." hit the Mini Jackpot of "..math.floor(mjackpot).." Collectable Tokens!", {1,1,1})
  315. spawnTrophy(self, silver, 0, col, "Mini Jackpot")
  316. spawnItems(self, colTok, math.floor(mjackpot))
  317. payoutbag.unlock()
  318. waitTime(1)
  319. mjackpot = 20
  320. elseif payout == "?" then
  321. 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})
  322. spawnItems(self, colTok, 1)
  323. else
  324. 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})
  325. spawnItems(self, colTok, 1)
  326. end
  327. if loss then
  328. if jackpot < 200 then
  329. jackpot = jackpot + 0.1
  330. end
  331. if mjackpot < 25 then
  332. mjackpot = mjackpot + 0.1
  333. end
  334. end
  335. if requiresTurn then
  336. playerSaves[Player[col].steam_id].lastDatePlayed = os.date("%m%d")
  337. playerSaves[Player[col].steam_id].lastTimePlayed = os.time()
  338. playerSaves[Player[col].steam_id].turnsLeft = playerSaves[Player[col].steam_id].turnsLeft - 1
  339. end
  340. btnmgr.editButton({index = 4, label = "x"..playerSaves[Player[col].steam_id].turnsLeft})
  341. btnmgr.editButton({index = 5, tooltip = Player[col].steam_name.."'s Plays Left"})
  342. btnmgr.editButton({index = 18, label=math.floor(jackpot).."x"})
  343. btnmgr.editButton({index = 20, label=math.floor(mjackpot).."x"})
  344. running = false
  345. return 1
  346. end
  347.  
  348. function checkPayout()
  349. local hasAce = false
  350. local isSoft = false
  351. local aa = string.sub(a, 1, 1)
  352. local ab = string.sub(a, 2, 2)
  353. local ba = string.sub(b, 1, 1)
  354. local bb = string.sub(b, 2, 2)
  355. local ca = string.sub(c, 1, 1)
  356. local cb = string.sub(c, 2, 2)
  357. if a == "♛" or b == "♛" or c == "♛" then
  358. if a == "♛" and b == "♛" and c == "♛" then return 111
  359. elseif (a == "♛" and b == "♛") or (b == "♛" and c == "♛") or (a == "♛" and c == "♛") then return 110
  360. else return 100 end
  361. elseif ab == "6" and bb == "6" and cb == "6" then return 666
  362. elseif ab == "7" and bb == "7" and cb == "7" then return 777 end
  363. if ab == "A" and bb == "A" and cb == "A" then return 888
  364. if ab == "A" then ab = 11; hasAce = true end
  365. if bb == "A" and hasAce == true then bb = 1 end
  366. if bb == "A" and hasAce == false then bb = 11; hasAce = true end
  367. if cb == "A" and hasAce == true then cb = 1 end
  368. if cb == "A" and hasAce == false then cb = 11; hasAce = true end
  369. if ab == "1" then ab = 10
  370. elseif ab == "J" then ab = 10
  371. elseif ab == "Q" then ab = 10
  372. elseif ab == "K" then ab = 10 end
  373. if bb == "1" then bb = 10
  374. elseif bb == "J" then bb = 10
  375. elseif bb == "Q" then bb = 10
  376. elseif bb == "K" then bb = 10 end
  377. if cb == "1" then cb = 10
  378. elseif cb == "J" then cb = 10
  379. elseif cb == "Q" then cb = 10
  380. elseif cb == "K" then cb = 10 end
  381. abc = ab + bb + cb
  382. if abc > 21 then if hasAce then abc = abc - 10; isSoft = true end end
  383. if abc > 29 then return 30
  384. elseif abc > 21 then return 22
  385. elseif ab == bb and ab == cb and abc < 21 then return 888
  386. elseif aa == "♠" and ba == "♠" and ca == "♠" then return 222
  387. elseif aa == "♣" and ba == "♣" and ca == "♣" then return 333
  388. elseif aa == "♥" and ba == "♥" and ca == "♥" then return 444
  389. elseif aa == "♦" and ba == "♦" and ca == "♦" then return 555
  390. elseif abc == 21 then return 21
  391. elseif abc > 0 and abc < 21 then
  392. if isSoft then
  393. return 1000 + abc
  394. else
  395. return abc
  396. end
  397. else
  398. return "?"
  399. end
  400. end
  401.  
  402. function newSlots()
  403. local four = 0
  404. local five = 0
  405. local six = 0
  406. if rigged then
  407. four = rigOne
  408. five = rigTwo
  409. six = rigThree
  410. else
  411. four = math.random(max)
  412. five = math.random(max)
  413. six = math.random(max)
  414. end
  415. return four, five, six
  416. end
  417.  
  418. function rollSlots(four, five, six)
  419. local iFour = rollAmount - rollOffset
  420. local iFive = rollAmount
  421. local iSix = rollAmount + rollOffset
  422. local lastIFour = iFour
  423. local lastIFive = iFive
  424. local lastISix = iSix
  425. local delayMultFour = os.time()-1
  426. local delayMultFive = os.time()-1
  427. local delayMultSix = os.time()-1
  428. while iSix ~= 0 do
  429. if iFour > 0 and os.time() > delayMultFour then
  430. delayMultFourOverflow = os.time() - delayMultFour
  431. iFour = iFour - 1
  432. delayMultFour = rollCurveMult*rollCurveExp^(-0.7*iFour+1)+1
  433. if delayMultFour > 20 then
  434. delayMultFour = 20 * rollDelay
  435. else
  436. delayMultFour = delayMultFour * rollDelay
  437. end
  438. delayMultFour = delayMultFour + os.time() - delayMultFourOverflow
  439. lastIFour = iFour
  440. end
  441. if iFive > 0 and os.time() > delayMultFive then
  442. delayMultFiveOverflow = os.time() - delayMultFive
  443. iFive = iFive - 1
  444. delayMultFive = rollCurveMult*rollCurveExp^(-0.7*iFive+1)+1
  445. if delayMultFive > 20 then
  446. delayMultFive = 20 * rollDelay
  447. else
  448. delayMultFive = delayMultFive * rollDelay
  449. end
  450. delayMultFive = delayMultFive + os.time() - delayMultFiveOverflow
  451. lastIFive = iFive
  452. end
  453. if iSix > 0 and os.time() > delayMultSix then
  454. delayMultSixOverflow = os.time() - delayMultSix
  455. iSix = iSix - 1
  456. delayMultSix = rollCurveMult*rollCurveExp^(-0.7*iSix+1)+1
  457. if delayMultSix > 20 then
  458. delayMultSix = 20 * rollDelay
  459. else
  460. delayMultSix = delayMultSix * rollDelay
  461. end
  462. delayMultSix = delayMultSix + os.time() - delayMultSixOverflow
  463. lastISix = iSix
  464. end
  465. if lastIFour == iFour or lastIFive == iFive or lastISix == iSix then
  466. setSlots(getSlotDisplay(four+iFour, five+iFive, six+iSix))
  467. end
  468. waitTime(rollDelayTick)
  469. end
  470. end
  471.  
  472. function getSlotDisplay(four, five, six)
  473. if four > max then
  474. four = four % max
  475. elseif four == 0 then
  476. four = max
  477. end
  478. if five > max then
  479. five = five % max
  480. elseif five == 0 then
  481. five = max
  482. end
  483. if six > max then
  484. six = six % max
  485. elseif six == 0 then
  486. six = max
  487. end
  488. local one = ""
  489. local seven = ""
  490. if four + 1 > max then one = 1 else one = four + 1 end
  491. if four - 1 == 0 then seven = max else seven = four - 1 end
  492. local two = ""
  493. local eight = ""
  494. if five + 1 > max then two = 1 else two = five + 1 end
  495. if five - 1 == 0 then eight = max else eight = five - 1 end
  496. local three = ""
  497. local nine = ""
  498. if six + 1 > max then three = 1 else three = six + 1 end
  499. if six - 1 == 0 then nine = max else nine = six - 1 end
  500. return one, two, three, four, five, six, seven, eight, nine
  501. end
  502.  
  503. function setSlots(one, two, three, four, five, six, seven, eight, nine)
  504. a, b, c = deck[four], deck[five], deck[six]
  505. btnmgr.editButton({index = 9, label = deck[one]})
  506. btnmgr.editButton({index = 10, label = deck[two]})
  507. btnmgr.editButton({index = 11, label = deck[three]})
  508. btnmgr.editButton({index = 12, label = deck[four]})
  509. btnmgr.editButton({index = 13, label = deck[five]})
  510. btnmgr.editButton({index = 14, label = deck[six]})
  511. btnmgr.editButton({index = 15, label = deck[seven]})
  512. btnmgr.editButton({index = 16, label = deck[eight]})
  513. btnmgr.editButton({index = 17, label = deck[nine]})
  514. end
  515.  
  516. function spawnItems(targetZone, item, amount)
  517. if item == colTok then
  518. tokensPaid = tokensPaid + amount
  519. end
  520. if item == randRup then
  521. pupsPaid = pupsPaid + amount
  522. end
  523. if item == randPup then
  524. rupsPaid = rupsPaid + amount
  525. end
  526. if item == dailyTok then
  527. dailysPaid = dailysPaid + amount
  528. end
  529. local params = {}
  530. params.smooth = false
  531. params.position = targetZone.getPosition()
  532. params.position.x = spawnLoc.x
  533. params.position.y = params.position.y + 3
  534. params.position.z = spawnLoc.z
  535. for i=1,amount,1 do
  536. params.position.y = params.position.y
  537. takenObject = item.takeObject(params)
  538. waitTime(0.1)
  539. end
  540. end
  541.  
  542. function spawnItem(targetZone, item, heightOffset, color, title)
  543. local params = {}
  544. params.smooth = false
  545. params.position = targetZone.getPosition()
  546. params.position.x = spawnLoc.x
  547. params.position.y = params.position.y + (heightOffset or 0) - 1
  548. params.position.z = spawnLoc.z
  549. takenObject = item.takeObject(params)
  550. if color ~= "" and color ~= nil then
  551. takenObject.setColorTint(stringColorToRGB(color))
  552. if string.sub(Player[col].steam_name, -1) == 's' then
  553. takenObject.setName(tostring(Player[col].steam_name).."' "..tostring(title).." Bag")
  554. else
  555. takenObject.setName(tostring(Player[col].steam_name).."'s "..tostring(title).." Bag")
  556. end
  557. end
  558. if item == bag then
  559. payoutbag = takenObject
  560. payoutbag.lock()
  561. takenObject.setDescription(tostring(Player[col].steam_id))
  562. end
  563. waitTime(1)
  564. end
  565.  
  566. function spawnTrophy(targetZone, item, heightOffset, color, title)
  567. local params = {}
  568. params.smooth = false
  569. params.position = targetZone.getPosition()
  570. params.position.x = spawnLoc.x
  571. params.position.y = params.position.y + (heightOffset or 0) - 1
  572. params.position.z = spawnLoc.z
  573. print(item)
  574. payoutbag = item.takeObject(params)
  575. payoutbag.lock()
  576. payoutbag.setDescription(tostring(Player[col].steam_id))
  577. waitTime(1)
  578. end
  579.  
  580. function insertToken()
  581. if not requiresToken then
  582. return true
  583. end
  584. for i, obj in pairs(self.getObjects()) do
  585. if obj.name == "Collectable Token" or obj.name == "Daily Login Token" then
  586. local params = {}
  587. params.guid = obj.guid
  588. params.smooth = true
  589. params.position = self.getPosition()
  590. params.position.y = params.position.y + 4
  591. takenObject = self.takeObject(params)
  592. takenObject.destruct()
  593. return true
  594. end
  595. end
  596. return false
  597. end
  598.  
  599. function hasTurn()
  600. if not requiresTurn then
  601. return true
  602. end
  603. if playerSaves[Player[col].steam_id] ~= nil and playerSaves[Player[col].steam_id] ~= "" and playerSaves[Player[col].steam_id] ~= {} then --does save exists
  604. if playerSaves[Player[col].steam_id].lastDatePlayed ~= os.date("%m%d") then --has not played today
  605. playerSaves[Player[col].steam_id].turnsLeft = turnsPerRegen
  606. playerSaves[Player[col].steam_id].turnRegensLeft = turnsPerDay - turnsPerRegen
  607. return true
  608. else
  609. 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
  610. return true
  611. else
  612. if playerSaves[Player[col].steam_id].lastTimePlayed + regenTime > os.time() then --can't regen turns
  613. if playerSaves[Player[col].steam_id].turnRegensLeft >= turnsPerRegen then --has turn regens left
  614. broadcastToColor("You don't have any turns left!\nYou'll get "..turnsPerRegen.." more in "..timeTillNextTurn()..".", col, {1,0.25,0.25})
  615. return false
  616. else --get more next day
  617. broadcastToColor("You ran out of turns for the day!\nYou'll get more in "..timeTillNextDay()..".", col, {1,0.25,0.25})
  618. return false
  619. end
  620. else
  621. if playerSaves[Player[col].steam_id].turnRegensLeft >= turnsPerRegen then --has turn regens
  622. playerSaves[Player[col].steam_id].turnsLeft = turnsPerRegen
  623. playerSaves[Player[col].steam_id].turnRegensLeft = playerSaves[Player[col].steam_id].turnRegensLeft - turnsPerRegen
  624. return true
  625. else
  626. broadcastToColor("You ran out of turns for the day!\nYou'll get more in "..timeTillNextDay()".", col, {1,0.25,0.25})
  627. return false
  628. end
  629. end
  630. end
  631. end
  632. end
  633. playerSaves[Player[col].steam_id] = {}
  634. playerSaves[Player[col].steam_id].turnsLeft = turnsPerRegen
  635. playerSaves[Player[col].steam_id].turnRegensLeft = turnsPerDay - turnsPerRegen
  636. return true
  637. end
  638.  
  639. function timeTillNextDay()
  640. local timeTill = ""
  641. if tonumber(os.date("%H")) < 23 then
  642. timeTill = timeTill..23-os.date("%H").." hours, "
  643. end
  644. if tonumber(os.date("%M")) < 59 then
  645. timeTill = timeTill..59-os.date("%M").." minutes and "
  646. end
  647. timeTill = timeTill..60-os.date("%S").." seconds"
  648. return timeTill
  649. end
  650.  
  651. function timeTillNextTurn()
  652. local timeTill = (playerSaves[Player[col].steam_id].lastTimePlayed + regenTime) - os.time()
  653. local formattedTimeTill = ""
  654. if timeTill > 60 then
  655. formattedTimeTill = formattedTimeTill..((timeTill-(timeTill%60))/60).." minutes and "
  656. end
  657. formattedTimeTill = formattedTimeTill..(math.floor(timeTill%60)).." seconds"
  658. return formattedTimeTill
  659. end
  660.  
  661. function waitTime(tm)
  662. local endTime = os.time() + tm
  663. while os.time() < endTime do
  664. coroutine.yield(0)
  665. end
  666. end
  667.  
  668. function null()
  669. end
  670. ----
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement