· 7 years ago · Nov 15, 2018, 08:36 PM
1--[[Global variables--]]
2lastCollectTime = 0
3quickConvertPlayerChips = false
4quickConvertPlayerTime = nil
5quickConvertPlayersPlayer = nil
6quickConvertPlayersObject = nil
7createSidepotPl = nil
8createSidepotOb = nil
9convertfailcountlimit = 50 -- when bets are converted to pot, the number of failed attempts allowed before it falls back to move bets (it makes one attempt every two frames)
10sidepotfailcountlimit = 50 --
11sidepotfailcount = 0
12splitPotPlayers = 0 -- Numbers of Players where the split pot should be created
13splitPotZone = {} -- Contains the Zone for splitpotaction
14splitPotObject = {}
15
16--[[ Customizable variables --]]
17options = {
18
19 ["dealdelay1"] = 0.1, -- delay (in seconds) used when dealing players their hands
20 ["dealdelay2"] = 0.4, -- delay (in seconds) used when dealing community cards
21 ["blindsskipafk"] = false, -- If false, afk players still pay blindss when it's their time. Change to true if you want blinds to skip afk players.
22 ["actiontoggle"] = true, -- toggle whether the game displays actiontext. set this to false if you want to have it off by default
23 ["playerclickaction"] = true, -- toggle whether action button stays in place (false) or moves from player to player (true)
24 ["gamemode"] = 'texas', -- Game mode (currently supports Texas Hold'em ('texas'), Pineapple ('pineapple'), and Omaha Hold'em ('omaha'))
25 ["collectmethod"] = 'move', -- method used by collect bets. options: 'move': moves bets; 'convert': converts bets up, 'hybrid': starts with move, changes to convert when pot>hybridthreshold
26 ["hybridthreshold"] = 10000, -- used with hybrid collection, the point above which collection switches from move to convert
27 ["convertstackheight"] = 1, -- contains the height of the stacks for the convert method
28 ["enforcedoubleraise"] = true, -- if true, does not let a player pass action if their raise is less than double the current bet and they are not all in.
29 ["enforcepotlimit"] = false, -- if true, does not let a player pass action if they bet too much for pot limit. the bet limit is calculated as: pot + currentbet + (currentbet - action player's bet)
30 ["enforcedfoldinturn"] = false, -- if true, players may not use the fold hand buttons to fold out of turn
31 ["clocktime"] = 30,
32 ["autoclock"] = false,
33 ["autofold"] = false,
34 ["autoclocktime"] = 10,
35 ["clockpausebutton"] = false,
36 ["currencies"] = 'default_10', -- contains the index of different currencies
37 ["stacklayout"] = 'default_10', -- contains the index of different currencies template
38 ["chatoptions"] =
39 {
40 ["actionmessage"] = true, -- print "Action on player" message in chat
41 ["actionbroadcast"] = true, -- broadcast "Action on you!" to the current player
42 ["currentbetmessage"] = true, -- broadcast when the current bet changes
43 ["better"] = true, -- include the player who made or raised in the above message
44 ["potmessage"] = 2, -- 0 = never, 1 = on collect bets only, 2 = any time it changes as well as on collection
45 ["allinbroadcast"] = true, -- broadcast when a player is all in
46 ["stage"] = true -- flop, turn, river broadcasts
47 },
48
49 ["displayplayerbet"] = true, --
50 ["displayplayermoney"] = true,
51 ["playerbuttons"] =
52 {
53 ["Call"] = true,
54 ["Bet"] = true,
55 ["sortchips"] = true,
56 ["convert"] = true,
57 ["allin"] = true,
58 ["afk"] = true,
59 ["loadsavebag"] = false,
60 },
61 ["changemachine"] = true,
62}
63--[[starteramount = 10000
64autosaveandload = true
65chips = {}
66--[[ other variables and tables --]]
67onecard = false -- used when dealing one card from options menu (for determining starting dealer, etc)
68handsshown = {} -- table of hands that have been shown and evaluated by the script this round
69handinprogress = false -- used to prevent change of gamemode during a hand
70convertfailcount = 0
71holedealt = false -- whether or not players have been dealt their hole cards
72holecards = {['White'] = {}, ['Pink'] = {}, ['Red'] = {}, ['Orange'] = {}, ['Yellow'] = {}, ['Green'] = {}, ['Teal'] = {}, ['Blue'] = {}} -- table of players' hole cards, used for hand evaluations
73revealedcards = {['White'] = {}, ['Pink'] = {}, ['Red'] = {}, ['Orange'] = {}, ['Yellow'] = {}, ['Green'] = {}, ['Teal'] = {}, ['Blue'] = {}} -- table of players' hole cards which have been revealed
74dealing = false -- set to true while cards are being dealt to prevent double-clicking
75players = {} -- table of seated players used for dealing cards and actions
76actionon = nil -- Player whose turn it is to act
77playerbets = {} -- Table of players' bets
78currentbet = 0 -- highest bet from the playerbets table
79mainpotchips = {} -- table containing information regarding stacks of chips in the main pot(initialized in initializePot() function)
80printstring = '' -- string referenced by printMessages function to know which messages to print.
81pot = 0 -- total amount in pot (including current players' bets)
82cardtint = 1 -- used anti-grouping measure
83sidepotcalculatet = false -- contains information if sidepot was calculated, stops all actions except dealing
84themeindex = 1
85subthemeindex = 1
86chiptints = {['White'] = {1, 1, 0.99}, ['Brown'] = {1, 0.99, 1}, ['Red'] = {1, 0.99, 0.99}, ['Orange'] = {0.99, 1, 1}, ['Yellow'] = {0.99, 1, 0.99}, ['Green'] = {0.99, 0.99, 1}, ['Teal'] = {0.99, 0.99, 0.99}, ['Blue'] = {1, 1, 0.98}, ['Pink'] = {1, 0.98, 0.99}}
87betzonechiptints = {['White'] = {1, 0.98, 0.98}, ['Brown'] = {0.99, 0.99, 0.98}, ['Red'] = {0.98, 0.98, 0.99}, ['Orange'] = {0.98, 0.98, 0.98}, ['Yellow'] = {1, 1, 0.97}, ['Green'] = {1, 0.97, 1}, ['Teal'] = {1, 0.97, 0.99}, ['Blue'] = {1, 0.97, 0.98}, ['Pink'] = {0.97, 1, 1}}
88
89
90
91--[[ Object references and GUIDs --]]
92afkClock = {}
93potsplitter = {}
94actionbutton = {}
95actionbuttonGUID = '08f4c2'
96backtablezones = {}
97backtablezoneGUIDs = {'39fd59', '39fd59', '39fd59', '39fd59', '39fd59', '39fd59', '39fd59', '39fd59', '39fd59'}
98betzones = {} -- scripting zones for the betting areas for each player. Order must correspond to colors table
99betzoneGUIDs = {'420cfb', '3a8997', '7d419f', '332aa4', '0377d5', '8a2729', 'db2d03', 'b93bb7', '39fd59'}
100boardobject = {} -- 3d model used for the board
101boardobjectGUID = '48721b'
102boardzone = {} -- scripting zone on the board where community cards are dealt
103boardzoneGUID = '5a1d5c'
104collectbutton = {} -- button to collect bets
105collectbuttonGUID = 'e801e4'
106clock = null
107dealbutton = {} -- button to deal cards
108dealbuttonGUID = '1745d7'
109deck = {} -- deck
110deckGUID = '1b1565' -- the deck's GUID which is saved on the table
111muck = {} -- the muck object that is used to determine where burn cards are dealt
112muckGUID = 'be42ca'
113newdeckbutton = {} -- button to spawn a new deck
114newdeckbuttonGUID = 'ea1c95'
115cleanmuckbutton = {}
116cleanmuckbuttonGUID = 'de8b4b'
117potobject = {}
118potobjectGUID = '6a79c6'
119resetbutton = {} -- button to reset the game
120resetbuttonGUID = 'c3b0f3'
121sidepotbutton = {}
122sidepotbuttonGUID = 'f1421a'
123tablezones = {}
124tablezoneGUIDs = {'420cfb', '3a8997', '7d419f', '332aa4', '0377d5', '8a2729', 'db2d03', 'b93bb7', '39fd59'}
125
126infiniteMoneyBag = {}
127
128
129
130colors = {"White", "Pink", "Red", "Orange", "Yellow", "Green", "Teal", "Blue"} --list of all colors, in order
131fontcolors = {}
132
133 for i, v in ipairs (colors) do
134 fontcolors[v] = {}
135 end
136
137 fontcolors.White.r = 1
138 fontcolors.White.g = 1
139 fontcolors.White.b = 1
140 fontcolors.White.bbcode = '[ffffff]'
141
142 --[[fontcolors.Brown.r = 0.443
143 fontcolors.Brown.g = 0.231
144 fontcolors.Brown.b = 0.09
145 fontcolors.Brown.bbcode = '[713b17]'--]]
146
147 fontcolors.Pink.r = 0.96
148 fontcolors.Pink.g = 0.439
149 fontcolors.Pink.b = 0.807
150 fontcolors.Pink.bbcode = '[f570ce]'
151
152 fontcolors.Red.r = 0.856
153 fontcolors.Red.g = 0.1
154 fontcolors.Red.b = 0.094
155 fontcolors.Red.bbcode = '[da1918]'
156
157 fontcolors.Orange.r = 0.956
158 fontcolors.Orange.g = 0.392
159 fontcolors.Orange.b = 0.113
160 fontcolors.Orange.bbcode = '[f4641d]'
161
162 fontcolors.Yellow.r = 0.905
163 fontcolors.Yellow.g = 0.898
164 fontcolors.Yellow.b = 0.172
165 fontcolors.Yellow.bbcode = '[e7e52c]'
166
167 fontcolors.Green.r = 0.192
168 fontcolors.Green.g = 0.701
169 fontcolors.Green.b = 0.168
170 fontcolors.Green.bbcode = '[31b32b]'
171
172 fontcolors.Teal.r = 0.129
173 fontcolors.Teal.g = 0.694
174 fontcolors.Teal.b = 0.607
175 fontcolors.Teal.bbcode = '[21b19b]'
176
177 fontcolors.Blue.r = 0.118
178 fontcolors.Blue.g = 0.53
179 fontcolors.Blue.b = 1
180 fontcolors.Blue.bbcode = '[1f87ff]'
181
182 fontcolors.Pink.r = 0.96
183 fontcolors.Pink.g = 0.439
184 fontcolors.Pink.b = 0.807
185 fontcolors.Pink.bbcode = '[f570ce]'
186
187potzones = {}
188mainpotzoneGUID = 'a20d35'
189sidepotzoneGUIDs = {'a93f95', '6cf2bc', 'c9aaae', '454945', '558225'}
190--pottext = {}
191--pottextGUID = 'a5130f'
192mainpottext = {}
193mainpottextGUID = '476499'
194bettext = {} -- textes for current player bets
195bettextGUIDs = {'8133a5', '433f14', 'b57079', '86e377', '9d612a', 'da0c91', '8a8de0', '121b10', 'f7f532'}
196--tablezonetext = {}
197
198sidepottext = {} -- textes for current player bets
199sidepottextGUIDs = {}
200--currenbettext = {}
201--currentbettextGUID = 'ed7b0b'
202colorball = null
203overlay = {}
204overlayGUID = '290051'
205actiontext = {}
206actiontextGUID = '20e11d'
207optionspanel = nil
208optionsbutton = {}
209optionsbuttonGUID = '6e1caf'
210scripts = {} -- Scripts copied from objects in onload, used when 'Reset Objects' is clicked.
211activeplayers = {['White'] = nil, ['Pink'] = nil, ['Red'] = nil, ['Orange'] = nil, ['Yellow'] = nil, ['Green'] = nil, ['Teal'] = nil, ['Blue'] = nil}
212
213savebag = {}
214savebagGUID = '6215eb'
215newsavebagbutton = {}
216newsavebagbuttonGUID = '6aa67a'
217
218saves = {['White'] = nil, ['Pink'] = nil, ['Red'] = nil, ['Orange'] = nil, ['Yellow'] = nil, ['Green'] = nil, ['Teal'] = nil, ['Blue'] = nil}
219
220
221-- Currencies
222currenciesSelection = -- Includes all different type of chips, last entry will be used as dummy entry for unknown chips
223{
224
225 ['Default/Cash Stacks - $10'] =
226 {
227 {
228 ["value"] = 1000, -- Value of the Chip
229 ["name"] = "$1000", -- Name of the chip
230 ["label"] = "$1000", -- Label used for converting machine
231 ["standard"] = true, -- Standard tabletop chips (1000, 500, 100, 50, 10)
232 ["height"] = 0.15,
233 ["params"] =
234 {
235 ["rotation"] = {0, 270, 0}, -- rotation of the object (in relation to the machine) when it spawns
236 ["scale"] = {1,1,1} -- the scale at which to spawn the object
237 },
238 ["stack"] = "5" -- spot position for collecting/spawning (potzone and betting zone on sidepot)
239 },
240 {
241 ["value"] = 500, -- Value of the Chip
242 ["name"] = "$500", -- Name of the chip
243 ["label"] = "$500", -- Label used for converting machine
244 ["standard"] = true, -- Standard tabletop chips true/false
245 ["height"] = 0.15,
246 ["params"] =
247 {
248 ["rotation"] = {0, 270, 0}, -- rotation of the object (in relation to the machine) when it spawns
249 ["scale"] = {1,1,1} -- the scale at which to spawn the object
250 },
251 ["stack"] = "4" -- stack where the chips are put in
252 },
253 {
254 ["value"] = 100, -- Value of the Chip
255 ["name"] = "$100", -- Name of the chip
256 ["label"] = "$100", -- Label used for converting machine
257 ["standard"] = true, -- Standard tabletop chips true/false
258 ["height"] = 0.15,
259 ["params"] =
260 {
261 ["rotation"] = {0, 270, 0}, -- rotation of the object (in relation to the machine) when it spawns
262 ["scale"] = {1,1,1} -- the scale at which to spawn the object
263 },
264 ["stack"] = "3" -- stack where the chips are put in
265 },
266 {
267 ["value"] = 50, -- Value of the Chip
268 ["name"] = "$50", -- Name of the chip
269 ["label"] = "$50", -- Label used for converting machine
270 ["standard"] = true, -- Standard tabletop chips true/false
271 ["height"] = 0.15,
272 ["params"] =
273 {
274 ["rotation"] = {0, 270, 0}, -- rotation of the object (in relation to the machine) when it spawns
275 ["scale"] = {1,1,1} -- the scale at which to spawn the object
276 },
277 ["stack"] = "2" -- stack where the chips are put in
278 },
279 {
280 ["value"] = 10, -- Value of the Chip
281 ["name"] = "$10", -- Name of the chip
282 ["label"] = "$10", -- Label used for converting machine
283 ["standard"] = true, -- Standard tabletop chips true/false
284 ["height"] = 0.15,
285 ["params"] =
286 {
287 ["rotation"] = {0, 270, 0}, -- rotation of the object (in relation to the machine) when it spawns
288 ["scale"] = {1,1,1} -- the scale at which to spawn the object
289 },
290 ["stack"] = "1" -- stack where the chips are put in
291 }
292
293 ,-- dummy for unknown chips
294
295 {
296 ["value"] = -1, -- Value of the Chip
297 ["name"] = "unknown", -- Name of the chip
298 ["standard"] = false, -- Standard tabletop chips true/false
299 ["label"] = "dummy", -- Label used for converting machine
300 ["height"] = 0.3,
301 ["params"] =
302 {
303 ["rotation"] = {0, 270, 0}, -- rotation of the object (in relation to the machine) when it spawns
304 ["scale"] = {1,1,1} -- the scale at which to spawn the object
305 },
306 ["stack"] = "10" -- stack where the chips are put in
307 }
308
309 },
310
311
312 }
313
314
315
316
317
318stacklayout =
319{
320
321
322 ['5-2-2'] =
323 {
324 ["1"] =
325 {
326 ["xoffset"] = 3.05,
327 ["yoffset"] = 0.0825, -- half of the object's height to put its bottom on the surface
328 ["zoffset"] = -1.10,
329 ["height"] = 0, -- height of current stack
330 ["x"] = 0, -- coordinates of stack relative to the spawned objects
331 ["y"] = 0,
332 ["z"] = 0
333 },
334 ["2"] =
335 {
336 ["xoffset"] = 1.375,
337 ["yoffset"] = 0.0825,
338 ["zoffset"] = -1.10,
339 ["height"] = 0,
340 ["x"] = 0,
341 ["y"] = 0,
342 ["z"] = 0
343 },
344 ["3"] =
345 {
346 ["xoffset"] = -0.30,
347 ["yoffset"] = 0.0825,
348 ["zoffset"] = -1.10,
349 ["height"] = 0,
350 ["x"] = 0,
351 ["y"] = 0,
352 ["z"] = 0
353 },
354 ["4"] =
355 {
356 ["xoffset"] = -1.975,
357 ["yoffset"] = 0.0825,
358 ["zoffset"] = -1.10,
359 ["height"] = 0,
360 ["x"] = 0,
361 ["y"] = 0,
362 ["z"] = 0
363 },
364 ["5"] =
365 {
366 ["xoffset"] = -3.65,
367 ["yoffset"] = 0.0825,
368 ["zoffset"] = -1.10,
369 ["height"] = 0,
370 ["x"] = 0,
371 ["y"] = 0,
372 ["z"] = 0
373 }
374 ,
375 ["6"] =
376 {
377 ["xoffset"] = 1.50,
378 ["yoffset"] = 0.2,
379 ["zoffset"] = 0.60,
380 ["height"] = 0,
381 ["x"] = 0,
382 ["y"] = 0,
383 ["z"] = 0
384 }
385 ,
386 ["7"] =
387 {
388 ["xoffset"] = -2.42,
389 ["yoffset"] = 0.2,
390 ["zoffset"] = 0.60,
391 ["height"] = 0,
392 ["x"] = 0,
393 ["y"] = 0,
394 ["z"] = 0
395 }
396 ,
397
398 ["8"] =
399 {
400 ["xoffset"] = 1.50,
401 ["yoffset"] = 0.2,
402 ["zoffset"] = 2.20,
403 ["height"] = 0,
404 ["x"] = 0,
405 ["y"] = 0,
406 ["z"] = 0
407 }
408 ,
409 ["misc"] =
410 {
411 ["xoffset"] = -2.70 ,
412 ["yoffset"] = 0.2,
413 ["zoffset"] = 2.40,
414 ["height"] = 0,
415 ["x"] = 0,
416 ["y"] = 0,
417 ["z"] = 0
418 }
419
420 },
421
422}
423
424
425currenciesSelectionStacklayout =
426
427{
428 ["Default/Cash Stacks - $10"] = { "5-2-2" },
429
430}
431
432currencies = {}
433
434--[[ Overlay images --]]
435themes =
436{
437
438 { -- themeindex 3
439 ["label"] = 'Other',
440
441 { -- subthemeindex 4
442 ["label"] = 'Square1',
443 {
444 ["label"] = 'Grey In - Blue Out',
445 ["diffuse"] = 'https://i.imgur.com/AYO5wbC.jpg'
446 },
447 {
448 ["label"] = 'Grey in - Red Out',
449 ["diffuse"] = 'https://i.imgur.com/hCd0guQ.jpg'
450 },
451 {
452 ["label"] = 'Grey out - Blue in',
453 ["diffuse"] = 'https://i.imgur.com/6r9z5E9.jpg'
454 },
455 {
456 ["label"] = 'Blue',
457 ["diffuse"] = 'https://i.imgur.com/H1uK45i.jpg'
458 },
459 {
460 ["label"] = 'Grey',
461 ["diffuse"] = 'https://i.imgur.com/N0O6aqj.jpg'
462 },
463 {
464 ["label"] = 'Pink',
465 ["diffuse"] = 'https://i.imgur.com/mtBlNyb.jpg'
466 },
467 {
468 ["label"] = 'Green1',
469 ["diffuse"] = 'https://i.imgur.com/dAIZPHY.jpg'
470 },
471 {
472 ["label"] = 'Green2',
473 ["diffuse"] = 'https://i.imgur.com/eHXDjyy.jpg'
474 },
475 {
476 ["label"] = 'Red',
477 ["diffuse"] = 'https://i.imgur.com/DbPelDi.jpg'
478 }
479 }
480 }
481}
482
483--[[ onLoad function --]]
484
485function onload(save_state)
486 local saveddata = JSON.decode(save_state)
487
488 --[[ Get object references --]]
489 boardzone = getObjectFromGUID(boardzoneGUID)
490 newdeckbutton = getObjectFromGUID(newdeckbuttonGUID)
491 newsavebagbutton = getObjectFromGUID(newsavebagbuttonGUID)
492 dealbutton = getObjectFromGUID(dealbuttonGUID)
493 resetbutton = getObjectFromGUID(resetbuttonGUID)
494 sidepotbutton = getObjectFromGUID(sidepotbuttonGUID)
495 muckzone = getObjectFromGUID(muckzoneGUID)
496 collectbutton = getObjectFromGUID(collectbuttonGUID)
497 cleanmuckbutton = getObjectFromGUID(cleanmuckbuttonGUID)
498
499 for i, v in ipairs (colors) do
500 local playerhand = getPlayerHandPositionAndRotation(v)
501
502 betzones[v] = getObjectFromGUID(betzoneGUIDs[i])
503 tablezones[v] = getObjectFromGUID(tablezoneGUIDs[i])
504 backtablezones[v] = getObjectFromGUID(backtablezoneGUIDs[i])
505 bettext[v] = getObjectFromGUID(bettextGUIDs[i])
506 end
507 potzones[1] = getObjectFromGUID(mainpotzoneGUID)
508 for i, v in ipairs (sidepotzoneGUIDs) do
509 potzones[#potzones+1] = getObjectFromGUID(v)
510 end
511 actionbutton = getObjectFromGUID(actionbuttonGUID)
512 optionsbutton = getObjectFromGUID(optionsbuttonGUID)
513 sidepotbutton = getObjectFromGUID(sidepotbuttonGUID)
514 if saveddata == nil then
515 --[[ Initialize texts --]]
516 hideActionText()
517 --pottext.setPosition ({0, 1.33, 3})
518 --pottext.setRotation ({90, 180, 0})
519 --currentbettext.setPosition ({0, 1.33, 5})
520 --currentbettext.setRotation({90, 180, 0})
521 mainpotchips = initializePot()
522 else
523 if saveddata.options ~= nil then options = saveddata.options end
524
525 if saveddata.holedealt ~= nil then holedealt = saveddata.holedealt end
526 if saveddata.dealing ~= nil then dealing = saveddata.dealing end
527 if saveddata.players ~= nil then players = saveddata.players end
528 if saveddata.actionon ~= nil then actionon = saveddata.actionon end
529 if saveddata.playerbets ~= nil then playerbets = saveddata.playerbets end
530 if saveddata.currentbet ~= nil then currentbet = saveddata.currentbet end
531 if saveddata.mainpotchips ~= nil then mainpotchips = saveddata.mainpotchips end
532 if saveddata.pot ~= nil then pot = saveddata.pot end
533 if saveddata.collecting ~= nil then collecting = saveddata.collecting end
534 if saveddata.collectmethod ~= nil then collectmethod = saveddata.collectmethod end
535 if saveddata.convertstackheight ~= nil then convertstackheight = saveddata.convertstackheight end
536 if saveddata.hybridthreshold ~= nil then hybridthreshold = saveddata.hybridthreshold end
537 if saveddata.handinprogress ~= nil then handinprogress = saveddata.handinprogress end
538
539 if saveddata.savebagGUID ~= nil then savebagGUID = saveddata.savebagGUID end
540 if saveddata.deckGUID ~= nil then deckGUID = saveddata.deckGUID end
541 if saveddata.muckGUID ~= nil then muckGUID = saveddata.muckGUID end
542 if saveddata.potobjectGUID ~= nil then potobjectGUID = saveddata.potobjectGUID end
543 if saveddata.boardobjectGUID ~= nil then boardobjectGUID = saveddata.boardobjectGUID end
544 if saveddata.overlayGUID ~= nil then overlayGUID = saveddata.overlayGUID end
545 --if saveddata.pottextGUID ~= nil then pottextGUID = saveddata.pottextGUID end
546 --if saveddata.currentbettextGUID ~= nil then currentbettextGUID = saveddata.currentbettextGUID end
547 if saveddata.actiontextGUID ~= nil then actiontextGUID = saveddata.actiontextGUID end
548 if saveddata.revealedcards ~= nil then revealedcards = saveddata.revealedcards end
549 if saveddata.holecards ~= nil then holecards = saveddata.holecards end
550 if saveddata.handsshown ~= nil then handsshown = saveddata.handsshown end
551
552 if saveddata.bettext ~= nil then
553 bettext = JSON.decode(saveddata.bettext)
554 if saveddata.bettext ~= nil then
555 for i, v in ipairs(colors) do
556 bettext[v] = getObjectFromGUID(bettext[v])
557 end
558 end
559 end
560 if saveddata.sidepottext ~= nil then
561 sidepottext = JSON.decode(saveddata.sidepottext)
562 for i, v in ipairs(colors) do
563 sidepottext[v] = getObjectFromGUID(sidepottext[v])
564 end
565 end
566 --[[if saveddata.tablezonetext ~= nil then
567 tablezonetext = JSON.decode(saveddata.tablezonetext)
568 for i, v in ipairs(colors) do
569 tablezonetext[v] = getObjectFromGUID(tablezonetext[v])
570 end
571 end--]]
572
573 end
574
575 deck = getObjectFromGUID(deckGUID)
576 muck = getObjectFromGUID(muckGUID)
577 boardobject = getObjectFromGUID(boardobjectGUID)
578 potobject = getObjectFromGUID(potobjectGUID)
579 --pottext = getObjectFromGUID(pottextGUID)
580 --currentbettext = getObjectFromGUID(currentbettextGUID)
581 actiontext = getObjectFromGUID(actiontextGUID)
582 savebag = getObjectFromGUID(savebagGUID)
583 if options.displayplayerbet == nil then
584 options.displayplayerbet = true
585 end
586 if options.displayplayermoney == nil then
587 options.displayplayermoney = true
588 end
589 if options.playerbuttons == nil then
590 options["playerbuttons"] =
591 {
592 ["Call"] = true,
593 ["Bet"] = true,
594 ["sortchips"] = true,
595 ["convert"] = true,
596 ["allin"] = true,
597 ["afk"] = true,
598 ["loadsavebag"] = false
599 }
600 end
601 if options.playerbuttons == nil then
602 options.playerbuttons = {}
603 end
604 if options.playerbuttons.Call == nil then
605 options.playerbuttons.Call = true
606 end
607 if options.playerbuttons.Bet == nil then
608 options.playerbuttons.Bet = true
609 end
610 if options.playerbuttons.sortchips == nil then
611 options.playerbuttons.sortchips = true
612 end
613 if options.playerbuttons.convert == nil then
614 options.playerbuttons.convert = true
615 end
616 if options.playerbuttons.allin == nil then
617 options.playerbuttons.allin = true
618 end
619 if options.playerbuttons.afk == nil then
620 options.playerbuttons.afk = true
621 end
622 if options.playerbuttons.loadsavebag == nil then
623 options.playerbuttons.loadsavebag = false
624 end
625
626 if options.autoclocktime == nil then
627 options.autoclocktime = 5
628 options.autoclock = false
629 options.autofold = false
630 options.clockpausebutton = true
631 end
632 if options.convertstackheight == nil then
633 options.convertstackheight = 0
634 end
635 if options.currencies == nil or options.stacklayout == nil then
636 options.currencies = "default"
637 options.stacklayout = "default"
638 currencies = currenciesSelection[options.currencies]
639 else
640 currencies = currenciesSelection[options.currencies]
641
642 if currencies == nil then
643 options.currencies = "default"
644 options.stacklayout = "default"
645 currencies = currenciesSelection[options.currencies]
646 end
647 end
648
649
650
651 --[[ Create buttons --]]
652 local button = {}
653
654 --[[ use this button to assign a new deck --]]
655 button.label = 'New\nDeck'
656 button.click_function = "newDeck"
657 button.function_owner = nil
658 button.position = {0, 0.08, 0}
659 button.rotation = {0,180,0}
660 button.width = 525
661 button.height = 525
662 button.font_size = 150
663 button.color = {0,0,0}
664 button.font_color = {1,1,1}
665 newdeckbutton.createButton(button)
666
667 --[[ This button deals cards for each stage of the hand --]]
668 button.label = 'Deal'
669 button.click_function = "deal"
670 button.font_size = 150
671 dealbutton.createButton(button)
672
673
674 --[[ Resets deck and variables --]]
675 button.label = 'Reset'
676 button.click_function = "resetGame"
677 button.rotation = {0, 0, 0}
678 resetbutton.createButton(button)
679
680 --[[ Move bets to pot --]]
681 button.label = 'Collect\nBets'
682 button.click_function = "collectBets"
683 button.font_size = 150
684 collectbutton.createButton(button)
685
686
687 --[[ Move action text --]]
688 button.label = 'Done'
689 button.font_size = 150
690 button.click_function = "action"
691 actionbutton.createButton(button)
692
693 --[[ Open options menu --]]
694 button.label = 'Options'
695 --button.color = {0,0,0}
696 button.font_size = 150
697 --button.font_color = {1,1,1}
698 button.click_function = "spawnOptionsPanel"
699 optionsbutton.createButton(button)
700
701 --[[ Create Side Pots --]]
702 button.label= 'Create\nSidepot'
703 button.font_size = 150
704 button.click_function = "createSidepot"
705 sidepotbutton.createButton(button)
706
707
708 --[[ assign new savebag --]]
709 button.label= 'New\nSavebag'
710 button.font_size = 150
711 button.click_function = "newSavebag"
712 newsavebagbutton.createButton(button)
713
714 createPlayerButtons()
715
716
717 for i, v in ipairs(getAllObjects()) do
718 if v.getName() == 'Pot Splitter' then
719 button.rotation = {0,0,0}
720 button.width = 45
721 button.height = 45
722 button.font_size = 42
723 potsplitter[#potsplitter + 1] = v
724 p = v.getPosition()
725 button.position = {-0.40, 0.3, -0.95}
726 i = 2
727 while i < 11 do
728 button.click_function = "splitPot" .. i
729 button.label = tostring(i)
730 button.position[1] = button.position[1] + 0.08
731 v.createButton(button)
732 i = i + 1
733 end
734 end
735
736 if v.getName() == 'Back Table' and options.changemachine then
737 local offsetx = 2/#currencies
738 local button = {}
739 v.clearButtons()
740 local offsetx = 2/#currencies
741 local button = {}
742
743 if #currencies <= 10 then
744 offsetx = 1.65/(#currencies-2)
745 else
746 offsetx = 1.65/8
747 end
748 local offsety = 2/#currencies
749 button.font_size = 150
750 button.width = 450
751 button.height = 250
752 button.scale = {1/5, 1/5, 1/7.5}
753 button.position = {0.83, -0.1, -0.9}
754 button.rotation = {180, 0, 0}
755
756 for j, w in ipairs(currencies) do
757 if w.value ~= -1 then
758 button.label = w.label
759 button.click_function = 'changeMachineButton' .. j
760 v.createButton(button)
761 button.position[1] = button.position[1] - offsetx
762 end
763 if j == 9 then
764 if #currencies - 11 > 0 then
765 offsetx = 1.65/(#currencies-11)
766 button.position = {0.83, -0.1, -0.8} -- spawn 1 button in the center
767 else
768 button.position = {0, -0.1, -0.8} -- spawn 1 button in the center
769 end
770 end
771 end
772 end
773 end
774 --[[ Make non-interactable parts to non-interactable --]]
775 local custom = {}
776
777
778
779 for i, v in ipairs (getAllObjects()) do
780 if v.getName() == 'Bet Square' or v.getName() == 'Front Table' or v.getName() == 'Back Table' or v.getName() == 'Dealer Table' or v.getName() == 'Change Box' then
781 v.interactable = true
782 elseif v.getName() == 'Table Overlay' then
783 overlay = v
784 v.interactable = false
785 end
786 end
787
788 --muck.setColorTint(pottext.TextTool.getFontColor())
789 --boardobject.setColorTint(pottext.TextTool.getFontColor())
790
791 --[[ Copy scripts from objects. These are used when objects are respawned with 'Reset Objects' button on the options menu --]]
792 scripts[1] = muck.getLuaScript()
793 scripts[2] = boardobject.getLuaScript()
794 scripts[3] = potobject.getLuaScript()
795 scripts[4] = actiontext.getLuaScript()
796
797
798end
799
800function onSave()
801 --print ('saved')
802 local savebettext = {}
803 local savesidepottext = {}
804 --local savetablezonetext = {}
805 for i,v in pairs (colors) do
806 savebettext[v] = bettext[v].getGUID()
807 savesidepottext[v] = sidepottext[v].getGUID()
808 --savetablezonetext[v] = tablezonetext[v].getGUID()
809 end
810
811 if savebag ~= nil then
812 savebagGUID = savebag.getGUID()
813 end
814
815 local tosave = {
816 options = options,
817
818 holedealt = holedealt,
819 dealing = false,
820 players = players,
821 actionon = actionon,
822 playerbets = playerbets,
823 currentbet = currentbet,
824 mainpotchips = mainpotchips,
825 pot = pot,
826 collecting = false,
827 handinprogress = handinprogress,
828
829 deckGUID = deck.getGUID(),
830 muckGUID = muck.getGUID(),
831 potobjectGUID = potobject.getGUID(),
832 boardobjectGUID = boardobject.getGUID(),
833 overlayGUID = overlay.getGUID(),
834 --pottextGUID = pottext.getGUID(),
835 --currentbettextGUID = currentbettext.getGUID(),
836 actiontextGUID = actiontext.getGUID(),
837 holecards = holecards,
838 revealedcards = revealedcards,
839 handsshown = handsshown,
840 savebagGUID = savebagGUID,
841 bettext = JSON.encode(savebettext),
842 sidepottext = JSON.encode(savesidepottext),
843 --tablezonetext = JSON.encode(savetablezonetext)
844
845 }
846 return JSON.encode(tosave)
847
848end
849
850function createPlayerButtons()
851 --[[ Create sort Chips onPlayers --]]
852
853 button = {}
854
855 button.rotation = {0,180,180}
856 button.width = 250
857 button.height = 15
858 button.font_size = 50
859
860 for i, v in ipairs(getAllObjects()) do
861
862 posy = 0.75
863 if v.getName() == 'Front Table' then
864 v.clearButtons()
865 v.interactable = true
866
867 if options.playerbuttons.sortchips then
868 posy= posy-0.386
869 button.font_size = 50
870 button.height= 25
871 p = v.getPosition()
872 button.label= 'SortChips'
873 button.position = {0.75, -0.1, posy}
874 button.click_function = 'sortPlayerChips'
875 v.createButton(button)
876 end
877
878 if options.playerbuttons.convert then
879 posy= posy-0.3
880 p = v.getPosition()
881 button.label= 'Convert'
882 button.position = {0.75, -0.1, posy}
883 button.font_size = 50
884 button.height=25
885 button.click_function='quickConvertPlayerChips10_5'
886 v.createButton(button)
887 end
888
889
890 if options.playerbuttons.allin then
891 posy= posy-0.3
892 p = v.getPosition()
893 button.height = 15
894 button.font_size = 50
895 button.label= 'All In'
896 button.position = {0.75, -0.1, posy}
897 button.click_function = 'goAllIn'
898 v.createButton(button)
899 end
900
901 if options.playerbuttons.afk then
902 posy= posy-0.3
903 button.height = 15
904 button.font_size = 50
905 button.label= 'AFK'
906 button.position = {0.75, -0.1, posy}
907 button.click_function = 'goAFK'
908 v.createButton(button)
909 end
910
911 if options.playerbuttons.loadsavebag then
912 posy= posy-0.3
913 button.height = 15
914 button.font_size = 50
915 button.label= 'load save'
916 button.position = {0.75, -0.1, posy}
917 button.click_function = 'loadSaveBag'
918 v.createButton(button)
919 end
920
921 if options.playerbuttons.Call then
922 posy= posy-0.3
923 button.font_size = 50
924 button.height= 25
925 p = v.getPosition()
926 button.label= 'Call'
927 button.position = {-0.73, -0.1, 0.64}
928 button.click_function = 'quickCall'
929 v.createButton(button)
930 end
931 if options.playerbuttons.Bet then
932 button.font_size = 50
933 button.height = 25
934 p = v.getPosition()
935 button.label = 'Bet'
936 button.position = {-0.73, -0.1, 0}
937 button.click_function = 'quickBet'
938 --button.function_owner = v
939 v.createButton(button)
940 end
941 if options.playerbuttons.Bet then
942 print('creating')
943 local input_parameters = {}
944 input_parameters.input_function = 'nilFunc'
945 input_parameters.function_owner = v
946 input_parameters.label = 'Test'
947 input_parameters.position = {0, -0.1, 0}
948 input_parameters.rotation = {180,0,0}
949 input_parameters.scale = {1,1,1}
950 input_parameters.width = 300
951 input_parameters.height = 150
952 input_parameters.font_size = 50
953 input_parameters.font_color = {0,0,0}
954 v.createInput(input_parameters)
955 end
956 end
957 end
958end
959--[[function nilFunc(objectButtonClicked1, playerColorClicked1, input_value1, selected1)
960 local inputslist = self.getInputs()
961 print(inputslist)
962 local pos = string.find(inputslist[1].value, '\n')
963 print(pos)
964end--]]
965--[[ deal function: determines whether to deal players' hands, flop, turn, or river --]]
966
967function deal(ob, pl)
968 if not Player[pl].admin then
969 return 1
970 end
971
972 sidepotcalculated = false;
973
974 if deck == nil or deck == null then
975 for i, v in ipairs (getSeatedPlayers()) do
976 if Player[v].admin then
977 broadcastToColor('No deck assigned. Please assign a deck with the \'New Deck\' button.', v, {1, 0.3, 0.3})
978 end
979 end
980 return 1
981 end
982
983 if not dealing then
984 if not holedealt then
985 hole(pl)
986 addCount()
987 else
988 local cards = boardzone.getObjects()
989 local x = 0
990 for i, v in ipairs (cards) do
991 if v.tag == "Card" then
992 x = x+1
993 end
994 end
995
996 if x == 0 then
997 flop ()
998 elseif x == 3 then
999 turn ()
1000 elseif x == 4 then
1001 river ()
1002 elseif x == 5 then
1003 broadcastToAll('Showdown', {1, 1, 1})
1004 else
1005 broadcastToColor("[ff0000]Error:[ffffff] Invalid board", pl, {1, 1, 1})
1006 end
1007 end
1008 end
1009
1010end
1011
1012function addCount()
1013 dCounter = '930377'
1014 local dealCounter = getObjectFromGUID(dCounter)
1015 dealCounter.call('count')
1016end
1017
1018
1019function resetCount()
1020 local dealCounter = getObjectFromGUID(dCounter)
1021 dealCounter.call('reset')
1022end
1023
1024--[[ This function returns an ordered list of seated players who do not have an afk button or busted token.
1025 The first entry will be the player to the dealers left, and the dealer will be the last entry.
1026 If the dealer button is not found, returns nil. --]]
1027
1028function getOrderedListOfPlayers(pl)
1029
1030 local dealer = nil
1031 local afk = {} -- list of afk players
1032 local busted = {} -- list of busted players determined by busted tokens in their bet zones (when a player busts out, I usually make them sit out for a few hands before giving them more money)
1033 local objects = {} -- list of objects found in the dealerzones
1034 local dealerafk = false
1035 local bustedbombs = {}
1036
1037 -- First, look for the dealer button. Also, make list of afk players.
1038 for i, v in ipairs (colors) do
1039 objects = betzones[v].getObjects()
1040 for j, w in ipairs (objects) do
1041 if w.getName() == "Dealer" then
1042 dealer = v
1043 --print('Dealer is '..v)
1044 elseif w.getName() == "suffering" or w.getName() == "Busted" then
1045 if not objectExistsInList (busted, v) then
1046 busted[#busted+1] = v
1047 bustedbombs[#bustedbombs+1] = w
1048 end
1049 elseif w.getName() == 'AFK' then
1050 afk[#afk+1] = v
1051 end
1052 end
1053 end
1054
1055 -- return nil if dealer button not found
1056 if not dealer then
1057 broadcastToColor ('[ff0000]Error: [ffffff]Dealer button not found.', pl, {1, 1, 1})
1058 return nil
1059 end
1060
1061 for i, v in ipairs(bustedbombs) do
1062 v.destruct()
1063 end
1064
1065 local seatedplayers = getSeatedPlayers() -- list of seated players, in some random order
1066
1067 -- make sure dealer button is in front of a seated player
1068 for i, v in ipairs (seatedplayers) do
1069 if v == dealer then
1070 --print ('Dealer: '..dealer)
1071 break
1072 end
1073
1074 if i == #seatedplayers then
1075 broadcastToColor('[ff0000]Error:[ffffff] Dealer button not in front of a seated player.', pl, {1, 1, 1})
1076 return nil
1077 end
1078 end
1079
1080
1081 local playersx = {}
1082
1083 --sort the seatedplayers into playersx list
1084 for i, v in ipairs (colors) do
1085 for j, w in ipairs (seatedplayers) do
1086 if v == w then
1087 playersx[#playersx + 1] = w
1088 break
1089 end
1090 end
1091 end
1092
1093
1094 --rotate the list so the dealer is the last entry
1095 while playersx[#playersx] != dealer do
1096 playersx[#playersx+1] = playersx[1] -- copy first entry to end of table
1097 table.remove(playersx, 1) -- then remove first entry
1098 end
1099
1100 --print('Sorted Players: '..playersx[1]..playersx[2]..playersx[3]..playersx[4]..playersx[5]..playersx[6]..playersx[7]..playersx[8])
1101
1102 -- remove busted players from the table
1103 for i, v in ipairs (busted) do
1104 for j, w in ipairs (playersx) do
1105 if w == v then
1106 table.remove(playersx, j)
1107 end
1108 end
1109 end
1110
1111 -- lastly, remove afk players from the table
1112
1113 local actionoffset = 0
1114
1115 for i, v in ipairs(afk) do
1116 for j, w in ipairs (playersx) do
1117 if w == v then
1118 if actionoffset == 0 and j <= 2 then
1119 actionoffset = actionoffset + 1
1120 elseif actionoffset == 1 and j == 1 then
1121 actionoffset = actionoffset + 1
1122 end
1123 --print ('Removing afk player: '..playersx[j])
1124 table.remove(playersx, j)
1125 if w == dealer then
1126 dealerafk = true
1127 end
1128 break
1129 end
1130 end
1131 end
1132
1133 for i, v in ipairs (playersx) do
1134 playerbets[i] = 0
1135 end
1136
1137 if options.blindsskipafk then
1138 actionoffset = 0
1139 end
1140
1141 if actionoffset < 2 then
1142 actionon = playersx[2-actionoffset]
1143 else
1144 actionon = playersx[#playersx]
1145 end
1146
1147 -- set action on the dealer in a heads-up match
1148 if #playersx == 2 and not dealerafk then
1149 actionon = playersx[1]
1150 end
1151
1152 --return the final table
1153 return playersx
1154
1155end
1156
1157
1158--[[ deal hole --]]
1159
1160function hole (pl)
1161
1162 players = getOrderedListOfPlayers(pl)
1163
1164 if not players then
1165 return 1 -- abort if dealer button is not in front of a seat
1166 else
1167 dealing = true
1168 handinprogress = true
1169 hideActionText()
1170 calculatePots()
1171 startLuaCoroutine(nil, 'holeCoroutine')
1172 end
1173
1174end
1175
1176function holeCoroutine()
1177
1178 local deckpos = deck.getPosition()
1179 local cards = 0
1180
1181 if options.gamemode == 'fivestud' or onecard then
1182 cards = 1
1183 elseif options.gamemode == 'texas' or options.gamemode == 'sevenstud' then
1184 cards = 2
1185 elseif options.gamemode == 'pineapple' then
1186 cards = 3
1187 elseif options.gamemode == 'omaha' then
1188 cards = 4
1189 elseif options.gamemode == 'fivedraw' then
1190 cards = 5
1191 end
1192
1193 deck.setPosition({-7.8, 1.4,-5.0}) -- set the deck to the center of the table so dealt cards don't get intercepted by unintended hands
1194 cardpos1 = -1.15
1195 for i = 1, cards do
1196 for i, v in ipairs (players) do
1197 local t = os.clock()
1198 --deck.dealToColor(1, players[i])
1199 deck.dealToColorWithOffset({cardpos1,1,5.8}, false, players[i])
1200 --while os.clock() < (t + options.dealdelay1) do
1201 while (os.clock() - t) <= 0.5 do
1202 coroutine.yield(0)
1203 end
1204 end
1205 cardpos1 = cardpos1 + 2.3
1206 end
1207
1208 deck.setPosition(deckpos)
1209
1210 if onecard then
1211 onecard = false
1212 dealing = false
1213 if not handinprogress then
1214 players = {}
1215 end
1216 return 1
1217 end
1218
1219--[[ This loop exists to delay the call of the function action()
1220 I was having problems with a player (the dealer) being folded due to the cards not reaching the hand
1221 before the function was called. --]]
1222 t = os.clock()
1223 while os.clock() < (t + 1) do
1224 coroutine.yield(0)
1225 end
1226
1227 holedealt = true
1228 dealing = false
1229
1230 action()
1231
1232 for i, v in ipairs (players) do
1233 local cards = Player[v].getHandObjects()
1234 for j, w in ipairs (cards) do
1235 if w.tag == 'Card' then
1236 w.setColorTint({1, 1, cardtint})
1237 cardtint = cardtint - 0.01
1238 end
1239 end
1240 end
1241 getPlayersHoleCards()
1242
1243 return 1
1244
1245end
1246
1247
1248--[[ deal flop --]]
1249
1250function flop ()
1251
1252 dealing = true
1253 actionon = nil
1254 resetBets()
1255 hideActionText()
1256
1257 if options.chatoptions.stage then
1258 broadcastToAll('Flop', {0, 1, 1})
1259 end
1260
1261 startLuaCoroutine(nil, 'flopCoroutine')
1262
1263end
1264
1265function flopCoroutine ()
1266
1267 local muckpos = muck.getPosition()
1268 local muckrot = muck.getRotation()
1269
1270 muckpos.y = muckpos.y + 0.5
1271 muckrot.x = muckrot.x + 180
1272
1273 local params = {}
1274
1275 params.position = muckpos
1276 params.rotation = muckrot
1277 deck.takeObject(params)
1278
1279 for i = 1, 3 do
1280 local t = os.clock()
1281 while os.clock () < t + options.dealdelay2 do
1282 coroutine.yield(0)
1283 end
1284 params.position = getCardPosition(i)
1285 params.rotation = boardobject.getRotation()
1286 local card = deck.takeObject(params)
1287 card.setColorTint({1, 1, cardtint})
1288 cardtint = cardtint - 0.01
1289 end
1290
1291 t = os.clock()
1292 while os.clock() < (t + 1) do
1293 coroutine.yield(0)
1294 end
1295
1296 dealing = false
1297
1298 action()
1299
1300 return (1)
1301
1302end
1303
1304--[[ deal turn --]]
1305
1306function turn ()
1307
1308 dealing = true
1309 actionon = nil
1310 resetBets()
1311 calculatePots()
1312 hideActionText()
1313
1314 if options.chatoptions.stage then
1315 broadcastToAll('Turn', {0, 1, 1})
1316 end
1317
1318 startLuaCoroutine(nil, 'turnCoroutine')
1319
1320end
1321
1322function turnCoroutine ()
1323
1324 local muckpos = muck.getPosition()
1325 local muckrot = muck.getRotation()
1326
1327 muckpos.y = muckpos.y + 0.5
1328 muckrot.x = muckrot.x + 180
1329
1330 local params = {}
1331
1332 params.position = muckpos
1333 params.rotation = muckrot
1334 deck.takeObject(params)
1335
1336 local t = os.clock()
1337 while os.clock() < (t + options.dealdelay2) do
1338 coroutine.yield(0)
1339 end
1340
1341 params.position = getCardPosition(4)
1342 params.rotation = boardobject.getRotation()
1343 local card = deck.takeObject(params)
1344 card.setColorTint({1, 1, cardtint})
1345 cardtint = cardtint - 0.01
1346
1347 t = os.clock()
1348 while os.clock() < (t + 1) do
1349 coroutine.yield(0)
1350 end
1351
1352 dealing = false
1353
1354 action()
1355
1356 return (1)
1357
1358end
1359
1360--[[ deal river --]]
1361
1362function river ()
1363
1364 dealing = true
1365 actionon = nil
1366 resetBets()
1367 calculatePots()
1368 hideActionText()
1369
1370 if options.chatoptions.stage then
1371 broadcastToAll('River', {0, 1, 1})
1372 end
1373
1374 startLuaCoroutine(nil, 'riverCoroutine')
1375
1376end
1377
1378function riverCoroutine ()
1379
1380 local muckpos = muck.getPosition()
1381 local muckrot = muck.getRotation()
1382
1383 muckpos.y = muckpos.y + 0.5
1384 muckrot.x = muckrot.x + 180
1385
1386 local params = {}
1387
1388 params.position = muckpos
1389 params.rotation = muckrot
1390 deck.takeObject(params)
1391
1392 local t = os.clock()
1393 while os.clock() < (t + options.dealdelay2) do
1394 coroutine.yield(0)
1395 end
1396
1397 params.position = getCardPosition(5)
1398 params.rotation = boardobject.getRotation()
1399 local card = deck.takeObject(params)
1400 card.setColorTint({1, 1, cardtint})
1401 cardtint = cardtint - 0.01
1402
1403 t = os.clock()
1404 while os.clock() < (t + 1) do
1405 coroutine.yield(0)
1406 end
1407
1408 dealing = false
1409
1410 action()
1411
1412 return (1)
1413
1414end
1415
1416--[[ returns the card position based on the position and rotation of the boardobject model--]]
1417
1418function getCardPosition(n)
1419 local p = boardobject.getPosition()
1420 local r = boardobject.getRotation()
1421 local s = boardobject.getScale()
1422 n = 3 - n
1423
1424 p.x = p.x - ((math.cos(math.rad(r.y))*2.75) * n) * s.x
1425 p.z = p.z + ((math.sin(math.rad(r.y))*2.75) * n) * s.z
1426 p.y = p.y + 0.5
1427
1428 return p
1429end
1430--[[ looks for a deck of 52 cards in the specified scripting zone (I used the white player's bet zone) and makes it the new deck object --]]
1431function newDeck (ob, pl)
1432
1433 if not Player[pl].admin then
1434 return 1
1435 end
1436
1437 obj = betzones.White.getObjects()
1438 for i, v in ipairs (obj) do
1439 if v.tag == "Deck" then
1440 if v.getQuantity() <= 52 then
1441 deck = {}
1442 deck = getObjectFromGUID(v.getGUID())
1443 print ("New deck assigned.")
1444 return 1
1445 end
1446 end
1447 end
1448
1449 broadcastToColor ("Valid deck not found. Please place a 52-card poker deck inside the white player's bet square try again.", pl, {1, 0.3, 0.3}) -- it only gets to this line if a deck isn't found in the above loop
1450
1451
1452end
1453
1454
1455function newSavebag (ob, pl)
1456
1457 if not Player[pl].admin then
1458 return 1
1459 end
1460
1461 obj = betzones.White.getObjects()
1462 for i, v in ipairs (obj) do
1463 if v.tag == "Bag" then
1464 savebag = {}
1465 savebag = getObjectFromGUID(v.getGUID())
1466 print ("New savebag assigned.")
1467 return 1
1468 end
1469 end
1470
1471 broadcastToColor ("No savebag found. Please put a bag inside the white player's bet square try again.", pl, {1, 0.3, 0.3}) -- it only gets to this line if a deck isn't found in the above loop
1472
1473
1474end
1475
1476--[[ reset the deck and variables --]]
1477
1478function resetGame (ob, pl)
1479
1480 if not Player[pl].admin then
1481 return 1
1482 end
1483
1484 sidepotcalculated = false
1485
1486 if deck == nil or deck == null then
1487 broadcastToColor('No deck is currently assigned. Please assign a new deck and try again.', pl, {1, 0.3, 0.3})
1488 return 0
1489 end
1490 --[[if pottext == nil or pottext == null then
1491 checkAndRespawnObjects()
1492 end--]]
1493
1494 --[[if currentbettext == nil or currentbettext == null then
1495 checkAndRespawnObjects()
1496 end--]]
1497
1498 if actiontext == nil or actiontext == null then
1499 checkAndRespawnObjects()
1500 end
1501
1502 mainpotchips = initializePot()
1503 afk = {}
1504 dealing = true
1505 for i, v in ipairs (colors) do
1506 for j, w in ipairs (Player[v].getHandObjects()) do
1507 w.setRotation({180, 0, 0})
1508 w.setColorTint({1, 1, 1})
1509 end
1510 bettext[v].setValue(" ")
1511 sidepottext[v].setValue(" ")
1512 if options.displayplayermoney then
1513 local chips = {}
1514 money = getChipValues(tablezones[v],chips)
1515 --tablezonetext[v].setValue("$" .. money)
1516 end
1517 end
1518
1519
1520 cardtint = 1
1521 holedealt = false
1522 handinprogress = false
1523 players = {}
1524 actionon = nil
1525 currentbet = 0
1526 pot = 0
1527 --pottext.setValue('Pot: $'.. tostring(pot))
1528 --currentbettext.setValue('Current bet: $'..tostring(currentbet))
1529 handsshown = {}
1530 playerbets = {}
1531 hideActionText()
1532 holecards = {['White'] = {}, ['Pink'] = {}, ['Red'] = {}, ['Orange'] = {}, ['Yellow'] = {}, ['Green'] = {}, ['Teal'] = {}, ['Blue'] = {}}
1533 revealedcards = {['White'] = {}, ['Pink'] = {}, ['Red'] = {}, ['Orange'] = {}, ['Yellow'] = {}, ['Green'] = {}, ['Teal'] = {}, ['Blue'] = {}}
1534 if clock ~= nil and clock ~= null then
1535 clock.destruct()
1536 end
1537
1538 -- destroy Sidepotmarke
1539 for i, v in ipairs(getAllObjects()) do
1540 if v.getName() == "Sidepotmarker" then
1541 v.destruct()
1542 end
1543 end
1544 startLuaCoroutine(nil, 'resetGameCoroutine')
1545
1546end
1547
1548function resetMuck(zone)
1549
1550 if not deck then
1551 return 1
1552 end
1553
1554 local obj = zone.getObjects()
1555 local deck_pos = deck.getPosition()
1556 local deck_rot = deck.getRotation()
1557
1558 deck_pos.y = deck_pos.y + 0.5
1559
1560 for i, v in ipairs (obj) do
1561 if v.tag == "Card" or v.tag == "Deck" then
1562 if v ~= deck then
1563 v.setColorTint({1, 1, 1})
1564 v.setPositionSmooth(deck_pos)
1565 v.setRotation(deck_rot)
1566 deck_pos.y = deck_pos.y + 0.1
1567 end
1568 end
1569 end
1570
1571 for i, v in ipairs(colors) do
1572 for j, w in ipairs (Player[v].getHandObjects()) do
1573 if w.tag == 'Card' then
1574 deck.putObject(w)
1575 end
1576 end
1577 end
1578 zone.destruct()
1579end
1580
1581function resetGameCoroutine()
1582
1583 local params = {}
1584 params.position = {0, 1, 0}
1585 params.rotation = {0, 0, 0}
1586 params.scale = {70, 1, 27}
1587 params.type = "ScriptingTrigger"
1588 params.callback = "resetMuck"
1589 params.params = {zone}
1590
1591 local zone = spawnObject(params)
1592
1593 local t = os.clock()
1594
1595
1596 --[[ Print an error and unassign deck if it doesn't have 52 cards after 3 seconds --]]
1597 while deck.getQuantity() < 52 do
1598 if os.clock() > (t + 3) then
1599 for i, v in ipairs (getSeatedPlayers()) do
1600 if Player[v].admin then
1601 broadcastToColor('Error: Deck missing cards. Unassigned current deck. Please assign new deck', v, {1, 0.3, 0.3})
1602 end
1603 end
1604 deck = nil
1605 dealing = false
1606 return 1
1607 end
1608 coroutine.yield(0)
1609 end
1610
1611 --[[ Print an error and unassign deck if it has more than 52 cards --]]
1612 if deck.getQuantity() > 52 then
1613 for i, v in ipairs (getSeatedPlayers()) do
1614 if Player[v].admin then
1615 broadcastToColor('Error: Too many cards in deck. Unassigned current deck. Please assign new deck.', v, {1, 0.3, 0.3})
1616 end
1617 end
1618
1619 deck = nil
1620 dealing = false
1621 return 1
1622 end
1623
1624 deck.shuffle()
1625
1626 t = os.clock()
1627 while os.clock() < (t + 1) do
1628 coroutine.yield(0)
1629 end
1630
1631 dealing = false
1632
1633 return (1)
1634
1635end
1636
1637--[[ move all chips in bet zones into the main pot --]]
1638
1639function collectBets(ob, pl)
1640
1641 --[[ Only host and promoted players can click this button --]]
1642 if not Player[pl].admin then
1643 return 1
1644 end
1645
1646 sidepotcalculated = false
1647 --[[ Make sure the potobject exists before running function --]]
1648 if potobject == nil or potobject == null then
1649 --print ('The pot object has been lost. Please click the \'Reset Objects\' button on the options panel to reassign.')
1650 checkAndRespawnObjects()
1651 --return 1
1652 end
1653
1654 printstring = printstring..'collect'
1655
1656 if clock ~= nil and clock ~= null then
1657 clock.destruct()
1658 end
1659
1660 -- prevents button spamming
1661 if (os.time() - lastCollectTime) < 2 then
1662 printToColor("You cant collect bets multiple times within 2 seconds", pl, {1,1,0} )
1663 return 1
1664 else
1665 lastCollectTime = os.time()
1666 end
1667
1668 if options.collectmethod == 'move' then
1669 startLuaCoroutine(nil, 'moveBetsToPot')
1670 elseif options.collectmethod == 'convert' then
1671 startLuaCoroutine(nil, 'convertBetsToPot')
1672 elseif options.collectmethod == 'hybrid' then
1673 if pot <= options.hybridthreshold then
1674 startLuaCoroutine(nil, 'moveBetsToPot')
1675 else
1676 startLuaCoroutine(nil, 'convertBetsToPot')
1677 end
1678 end
1679end
1680
1681function moveBetsToPot()
1682
1683 local objects = {} -- table of all objects
1684 local stacks = {}
1685 local chips = {}
1686 local h = {}
1687 --bets = getChipValues(potzones[1], chips)
1688 bets = 0
1689 for i, v in pairs (potzones) do
1690 bets = bets + getChipValues(v, chips)
1691 end
1692
1693 for i, v in ipairs (chips) do
1694 v.setColorTint({1,1,1})
1695 end
1696
1697 moveChips(chips, potobject.getPosition(), potobject.getRotation())
1698 for i = 1, 5 do
1699 coroutine.yield(0)
1700 end
1701 calculatePots()
1702 return 1
1703end
1704
1705
1706function convertBetsToPot()
1707
1708 if convertfailcount > convertfailcountlimit then
1709 convertfailcount = 0
1710 startLuaCoroutine (nil, 'moveBetsToPot')
1711 return 1
1712 end
1713
1714 --[[ Get chip values in bet zones --]]
1715
1716 local objects = {}
1717 local chips1 = {}
1718 local positions1 = {}
1719 local rotations1 = {}
1720
1721 objects = {}
1722 objects = potzones[1].getObjects()
1723 for j, w in ipairs (objects) do
1724 if w.tag == 'Chip' then
1725 if w.getValue() or tonumber(w.getName()) != nil then
1726 chips1[#chips1 + 1] = w
1727 end
1728 end
1729 end
1730
1731
1732 for i, v in pairs (betzones) do
1733 objects = {}
1734 objects = v.getObjects()
1735 for j, w in ipairs (objects) do
1736 if w.tag == 'Chip' then
1737 if w.getValue() or tonumber(w.getName()) != nil then
1738 chips1[#chips1 + 1] = w
1739 end
1740 end
1741 end
1742 end
1743
1744 for i, v in ipairs (chips1) do
1745 positions1[#positions1 + 1] = v.getPosition()
1746 rotations1[#rotations1 + 1] = v.getRotation()
1747 end
1748
1749 for i = 1, 2 do
1750 coroutine.yield(0)
1751 end
1752
1753 objects = {}
1754 local chips2 = {}
1755 local positions2 = {}
1756 local rotations2 = {}
1757
1758 objects = {}
1759 objects = potzones[1].getObjects()
1760 for j, w in ipairs (objects) do
1761 if w.tag == 'Chip' then
1762 if w.getValue() or tonumber(w.getName()) != nil then
1763 chips2[#chips2 + 1] = w
1764 end
1765 end
1766 end
1767
1768
1769 for i, v in pairs (betzones) do
1770 objects = {}
1771 objects = v.getObjects()
1772 for j, w in ipairs (objects) do
1773 if w.tag == 'Chip' then
1774 if w.getValue() or tonumber(w.getName()) != nil then
1775 chips2[#chips2 + 1] = w
1776 end
1777 end
1778 end
1779 end
1780
1781 if #chips2 ~= #chips1 then
1782 convertfailcount = convertfailcount + 1
1783 startLuaCoroutine(nil, 'convertBetsToPot')
1784 return 1
1785 end
1786
1787 for i, v in ipairs (chips2) do
1788 positions2[#positions2 + 1] = v.getPosition()
1789 rotations2[#rotations2 + 1] = v.getRotation()
1790 end
1791
1792 --[[ Check chip positions --]]
1793 for i, v in ipairs(positions1) do
1794 if v.x ~= positions2[i].x or v.y ~= positions2[i].y or v.z ~= positions2[i].z then
1795 convertfailcount = convertfailcount + 1
1796 startLuaCoroutine(nil, 'convertBetsToPot')
1797 return 1
1798 end
1799 end
1800
1801 --[[ Check chip rotations --]]
1802 for i, v in pairs(rotations1) do
1803 if v.x ~= rotations2[i].x or v.y ~= rotations2[i].y or v.z ~= rotations2[i].z then
1804 convertfailcount = convertfailcount + 1
1805 startLuaCoroutine(nil, 'convertBetsToPot')
1806 return 1
1807 end
1808 end
1809
1810 local chips = {}
1811 local bets = 0
1812
1813 for i, v in pairs (betzones) do
1814 bets = bets + getChipValues(v, chips)
1815 end
1816
1817 bets = bets + getChipValues(potzones[1], chips)
1818
1819 --[[ Spawn new chips in pot --]]
1820
1821
1822 --[[ Destroy old chips --]]
1823 for i, v in ipairs (chips) do
1824 v.destruct()
1825 end
1826
1827 --[[ Wait five frames to allow chips to spawn destruct themself --]]
1828 for i = 1, 10 do
1829 coroutine.yield(0)
1830 end
1831
1832
1833 spawnChips(bets, potobject.getPosition(), potobject.getRotation(), options.convertstackheight)
1834
1835
1836 --[[ Wait five frames to allow chips to spawn before updating pot values --]]
1837 for i = 1, 5 do
1838 coroutine.yield(0)
1839 end
1840
1841 calculatePots()
1842
1843 convertfailcount = 0
1844
1845 return 1
1846end
1847
1848function objectExistsInList(list, object)
1849 if list != nil then
1850 for i, v in ipairs(list) do
1851 if v == object then
1852 return true
1853 end
1854 end
1855 return false
1856 end
1857 return false
1858end
1859
1860function action (ob, pl)
1861
1862 if pl then
1863 if not Player[pl].admin and pl ~= actionon then
1864 return 1
1865 end
1866 end
1867
1868 if sidepotcalculated then
1869 return 1
1870 end
1871
1872 if actiontext == nil or actiontext == null then
1873 checkAndRespawnObjects()
1874 --print ('The action text has been deleted. Please click the \'Reset Objects\' button on the options panel to respawn.')
1875 --return 0
1876 end
1877
1878 calculatePots()
1879
1880 -- abort function if action toggled off
1881 if not options.actiontoggle then
1882 return 1
1883 end
1884
1885 --[[ Check action player's bet to make sure it's greater than or equal to current bet --]]
1886 --[[if actionon and actionon == pl then
1887 if getChipValues(betzones[actionon], {}) < currentbet and getChipValues(tablezones[actionon], {}) > 0 and Player[actionon].getHandObjects()[1] then
1888 broadcastToColor('You must match or raise the current bet of $'..currentbet, actionon, {1, 1, 1})
1889 if not Player[pl].admin then
1890 return 1
1891 end
1892 end
1893 end--]]
1894
1895 --[[ Destroy the clock if it exists --]]
1896
1897 if clock ~= nil and clock ~= null then
1898 clock.destruct()
1899 clock = null
1900 end
1901
1902 --[[ abort function and hide text if no players --]]
1903
1904 if #players == 0 then
1905 hideActionText()
1906 return 1
1907 end
1908
1909 local cb = currentbet
1910
1911 --[[ Remove player from list if they don't have cards --]]
1912
1913 if actionon then
1914
1915 for i, v in ipairs (players) do
1916 local cardcount = 0
1917 objects = betzones[v].getObjects()
1918 for j, w in ipairs (objects) do
1919 if w.tag == "Card" then
1920 --print('card')
1921 cardcount = cardcount + 1
1922 end
1923 end
1924 if cardcount < 2 then
1925 --print(v)
1926 for j, w in ipairs (players) do
1927 --print('In Hand: '..players[j])
1928 if v == actionon then
1929 --print('Removed: '..players[i])
1930 table.remove(players, i)
1931 if i > 1 then
1932 actionon = players[i-1]
1933 else
1934 actionon = players[#players]
1935 end
1936 break
1937 end
1938 end
1939 end
1940 end
1941
1942 --[[if not Player[actionon].getHandObjects()[1] then
1943 for i, v in ipairs (players) do
1944 if v == actionon then
1945 table.remove(players, i)
1946 if i > 1 then
1947 actionon = players[i-1]
1948 else
1949 actionon = players[#players]
1950 end
1951 break
1952 end
1953 end
1954 end--]]
1955
1956 --[[ or if they have no money (all in) --]]
1957 --[[if actionon then
1958 if getChipValues(tablezones[actionon], {}) == 0 then
1959 printstring = printstring..'allin'..actionon
1960 if getChipValues(betzones[actionon], {}) > cb then
1961 cb = getChipValues(betzones[actionon], {})
1962 end
1963 for i, v in ipairs (players) do
1964 if v == actionon then
1965 table.remove(players, i)
1966 if i > 1 then
1967 actionon = players[i-1]
1968 else
1969 actionon = players[#players]
1970 end
1971 break
1972 end
1973 end
1974 end
1975 if not actionon then
1976 hideActionText()
1977 return 1
1978 end
1979 end
1980 if #players == 0 then
1981 return 1
1982 end--]]
1983 end
1984
1985 -- set actionon to next player
1986 if not actionon then
1987 actionon = players[1]
1988 else
1989 for i, v in ipairs (players) do
1990 if actionon == v then
1991 if players[i+1] then
1992 actionon = players[i+1]
1993 else
1994 actionon = players[1]
1995 end
1996 break
1997 end
1998 end
1999 end
2000
2001 -- check new player's hand for cards. remove from list if none and run function again.
2002 if actionon then
2003 for i, v in ipairs (players) do
2004 local cardcount = 0
2005 objects = betzones[v].getObjects()
2006 for j, w in ipairs (objects) do
2007 if w.tag == "Card" then
2008 cardcount = cardcount + 1
2009 end
2010 end
2011 if cardcount < 2 then
2012 for j, w in ipairs (players) do
2013 if v == actionon then
2014 --print('Removed2: '..players[i])
2015 table.remove(players, i)
2016 if i > 1 then
2017 actionon = players[i-1]
2018 else
2019 actionon = players[#players]
2020 end
2021 action()
2022 return 1
2023 end
2024 end
2025 end
2026 end
2027 end
2028
2029 --[[if actionon then
2030 if not Player[actionon].getHandObjects()[1] then
2031 for i, v in ipairs (players) do
2032 if v == actionon then
2033 table.remove(players, i)
2034 if i > 1 then
2035 actionon = players[i-1]
2036 else
2037 actionon = players[#players]
2038 end
2039 action()
2040 return 1
2041 end
2042 end
2043 end
2044 end--]]
2045
2046 --[[ Hide text and abort if there is one player and no bet to call --]]
2047
2048 if #players == 1 and getChipValues(betzones[actionon], {}) >= cb then
2049 hideActionText()
2050 return 1
2051 end
2052
2053 printstring = printstring..'action'
2054
2055 -- move actiontext to front of player
2056
2057 local playerhand = getPlayerHandPositionAndRotation(actionon)
2058 actiontext.setValue('Action') -- set action text to say "Action" in case it gets changed (sometimes it changes to "Type here" for some reason)
2059 actiontext.TextTool.setFontColor(fontcolors[actionon]) -- change color of "Action" to player's color
2060
2061 actiontext.setPosition({playerhand['pos_x'], -1.45, playerhand['pos_z']})
2062 actiontext.setRotation({90, playerhand['rot_y'], 0})
2063
2064 -- move action button to player if playerclickaction is toggled
2065 if options.playerclickaction then
2066 actionbutton.setPosition({playerhand['pos_x'], 0.45, playerhand['pos_z']})
2067 actionbutton.setRotation({180, playerhand['rot_y'] + 90, 0})
2068 end
2069
2070 -- spawn clock if autoclock
2071 if options.autoclock then
2072 spawnClock()
2073 end
2074end
2075
2076function actionToggle(ob, pl)
2077 if not Player[pl].admin then
2078 return 1
2079 end
2080
2081 if options.actiontoggle then
2082 options.actiontoggle = false
2083 hideActionText()
2084 print ('Action text toggled off. The button can still be used to update pot and current bet values.')
2085 else
2086 options.actiontoggle = true
2087 print ('Action text toggled on. It will reappear next time action is passed.')
2088 end
2089
2090 optionsHost()
2091end
2092
2093function hideActionText()
2094 actiontext.setPosition({0, -2, 0})
2095end
2096
2097function calculatePots()
2098 --[[if pottext == nil or pottext == null then
2099 checkAndRespawnObjects()
2100 return 0
2101 end--]]
2102 if sidepotcalculated then
2103 return 0
2104 end
2105 --[[if currentbettext == nil or currentbettext == null then
2106 checkAndRespawnObjects()
2107 return 0
2108 end--]]
2109 startLuaCoroutine(nil, 'calculatePotsCoroutine')
2110end
2111
2112function calculatePotsCoroutine ()
2113
2114 local p = potobject.getPosition()
2115 local r = potobject.getRotation()
2116
2117 p.y = p.y + 10
2118
2119 potzones[1].setPosition (p)
2120 potzones[1].setRotation (r)
2121 potzones[1].setScale({9.5, 20, 6})
2122
2123 for i = 1, 3 do
2124 coroutine.yield(0)
2125 end
2126
2127 local bets = 0
2128 local mainpot = 0
2129 local prevpot = pot
2130 local prevbet = currentbet
2131 currentbet = 0
2132 local chips = {}
2133 local better = ''
2134 for i, v in ipairs (colors) do
2135 playerbets[i] = getChipValues(betzones[v], chips)
2136
2137 if playerbets[i] > currentbet then
2138 currentbet = playerbets[i]
2139 better = v
2140 end
2141 if options.displayplayerbet then
2142 if playerbets[i] > 0 then
2143 bettext[v].setValue('$' .. tostring(playerbets[i]))
2144 else
2145 bettext[v].setValue(' ')
2146 end
2147 else
2148 bettext[v].setValue(' ')
2149 end
2150 sidepottext[v].setValue(" ")
2151 if options.displayplayermoney then
2152 money = getChipValues(tablezones[v],chips)
2153 --tablezonetext[v].setValue("$" .. money)
2154 bets = bets + playerbets[i]
2155 end
2156 end
2157
2158 for i, v in ipairs (potzones) do
2159 mainpot = mainpot + getChipValues(v, chips)
2160 end
2161 --mainpot = getChipValues(potzones[1], chips)
2162
2163 pot = bets + mainpot
2164
2165 -- print the pot value in chat
2166 if pot > prevpot then
2167 printstring = printstring..'pot'
2168 end
2169
2170 -- print the current bet in chat
2171 if currentbet > prevbet then
2172
2173 if prevbet == 0 then
2174 printstring = printstring..'bet'..better
2175 else
2176 printstring = printstring..'raise'..better
2177 end
2178
2179 end
2180
2181 -- display pot value on 3dtexts
2182
2183 --pottext.setValue('Pot: $'..tostring(pot))
2184 --currentbettext.setValue('Current bet: $'..tostring(currentbet))
2185
2186 printMessages()
2187
2188 return 1
2189
2190end
2191
2192function getChipValues(zone, chips)
2193
2194 local objects = zone.getObjects()
2195 local x = 0
2196
2197 for j, w in ipairs (objects) do
2198 if w.tag == 'Chip' and not objectExistsInList(chips, w) then
2199 if w.getQuantity() < 0 then
2200 if w.getValue() then
2201 x = x + w.getValue()
2202 chips[#chips+1] = w
2203 elseif tonumber(w.getName()) then
2204 x = x + tonumber(w.getName())
2205 chips[#chips+1] = w
2206 end
2207 else
2208 if w.getValue() then
2209 x = x + (w.getValue() * w.getQuantity())
2210 chips[#chips+1] = w
2211 elseif tonumber(w.getName()) then
2212 x = x + (tonumber(w.getName()) * w.getQuantity())
2213 chips[#chips+1] = w
2214 end
2215 end
2216 end
2217 end
2218
2219 return x
2220
2221end
2222
2223function resetBets()
2224 playerbets = {}
2225 for i, v in ipairs (players) do
2226 playerbets[i] = 0
2227 end
2228 currentbet = 0
2229end
2230
2231--[[ Spawn panel with host options buttons --]]
2232function spawnOptionsPanel(ob, pl)
2233
2234 if not Player[pl].admin then
2235 return 1
2236 end
2237
2238 if optionspanel then
2239 destroyOptionsPanel()
2240 return 1
2241 end
2242
2243 local params = {}
2244 params.type = 'Custom_Model'
2245 params.callback = 'optionsMain'
2246 params.position = {5.69, 2.99, -12.08}
2247 params.scale = {0.76, 1, 0.89}
2248 params.rotation = {68.94, 194.59, 0.03}
2249
2250 optionspanel = spawnObject(params)
2251
2252 local custom = {}
2253 custom.mesh = 'http://pastebin.com/raw/avCFwn0Y'
2254 custom.collider = 'http://pastebin.com/raw/avCFwn0Y'
2255 custom.specular_intensity = 0
2256 custom.type = 4
2257
2258 optionspanel.setCustomObject(custom)
2259 optionspanel.lock()
2260 optionspanel.interactable = false
2261 optionspanel.setColorTint({0, 0, 0})
2262
2263 startLuaCoroutine(nil, 'addSelfDestruct')
2264
2265end
2266
2267--[[ Add buttons to panel --]]
2268
2269function optionsMain(ob, pl)
2270
2271 if pl then
2272 if not Player[pl].admin then
2273 return 1
2274 end
2275 end
2276
2277 optionspanel.clearButtons()
2278
2279 if colorball ~= nil and colorball ~= null then
2280 colorball.destruct()
2281 end
2282
2283 local button = {}
2284
2285 button.width = 150
2286 button.height = 150
2287 button.label = '☒'
2288 button.font_size = 125
2289 button.click_function = 'destroyOptionsPanel'
2290 button.position = {1.75, 0.05, -1.8}
2291 optionspanel.createButton(button)
2292
2293 button.width = 1000
2294 button.height = 200
2295 button.label = 'Host Settings'
2296 button.click_function = 'optionsHost'
2297 button.font_size = 150
2298 button.position = {0, 0.05, -1.5}
2299
2300 optionspanel.createButton(button)
2301
2302 button.width = 1000
2303 button.height = 200
2304 button.label = 'Chat Settings'
2305 button.click_function = 'optionsChat'
2306 button.font_size = 150
2307 button.position = {0, 0.05, -1}
2308 optionspanel.createButton(button)
2309
2310 button.width = 1000
2311 button.height = 200
2312 button.label = 'Themes'
2313 button.click_function = 'optionsThemes'
2314 button.font_size = 150
2315 button.position = {0, 0.05, -0.5}
2316 optionspanel.createButton(button)
2317
2318 button.width = 1000
2319 button.height = 200
2320 button.label = 'Currencies'
2321 button.click_function = 'optionsCurrencies'
2322 button.font_size = 150
2323 button.position = {0, 0.05, 0}
2324 optionspanel.createButton(button)
2325
2326
2327
2328 button.label = 'Deal one card'
2329 button.width = 800
2330 button.font_size = 100
2331 button.position = {-1, 0.05, 0.5}
2332 button.click_function = 'dealOneCard'
2333 optionspanel.createButton(button)
2334
2335 button.label = 'Clock'
2336 button.width = 800
2337 button.font_size = 150
2338 button.position = {1, 0.05, 0.5}
2339 button.click_function = 'spawnClock'
2340 optionspanel.createButton(button)
2341
2342 button.label = '«'
2343 button.width = 100
2344 button.height = 100
2345 button.font_size = 100
2346 button.click_function = 'decreaseClockTime5'
2347 button.position = {0.4, 0.05, 0.85}
2348 optionspanel.createButton(button)
2349
2350 button.label = '‹'
2351 button.click_function = 'decreaseClockTime1'
2352 button.position = {0.6, 0.05, 0.85}
2353 optionspanel.createButton(button)
2354
2355 button.label = tostring(options.clocktime)
2356 button.width = 300
2357 button.click_function = 'doNothing'
2358 button.position = {1, 0.05, 0.85}
2359 optionspanel.createButton(button)
2360
2361 button.label = '›'
2362 button.width = 100
2363 button.click_function = 'increaseClockTime1'
2364 button.position = {1.4, 0.05, 0.85}
2365 optionspanel.createButton(button)
2366
2367 button.label = '»'
2368 button.click_function = 'increaseClockTime5'
2369 button.position = {1.6, 0.05, 0.85}
2370 optionspanel.createButton(button)
2371
2372 button.label = 'Fold Player'
2373 button.width = 800
2374 button.height = 200
2375 button.font_size = 150
2376 button.position = {1, 0.05, 1.5}
2377 button.click_function = 'foldPlayer'
2378 optionspanel.createButton(button)
2379
2380 button.label = 'Set player Afk'
2381 button.width = 800
2382 button.font_size = 100
2383 button.position = {-1, 0.05, 1}
2384 button.click_function = 'setPlayerAfk'
2385 optionspanel.createButton(button)
2386
2387 button.label = 'Reset Objects'
2388 button.font_size = 100
2389 button.click_function = 'checkAndRespawnObjects'
2390 button.position = {-1.0, 0.05, 1.5}
2391 optionspanel.createButton(button)
2392
2393
2394
2395
2396
2397end
2398
2399function dealOneCard(ob, pl)
2400 if pl then
2401 if not Player[pl].admin and pl ~= actionon then
2402 return 1
2403 end
2404 end
2405
2406 if deck == nil or deck == null then
2407 for i, v in ipairs (getSeatedPlayers()) do
2408 if Player[v].admin then
2409 broadcastToColor('No deck assigned. Please assign a deck with the \'New Deck\' button.', v, {1, 0.3, 0.3})
2410 end
2411 end
2412 return 1
2413 end
2414
2415 if not dealing then
2416 if not handinprogress then
2417 players = getOrderedListOfPlayers()
2418 end
2419
2420 if not players then
2421 return 1
2422 end
2423
2424 onecard = true
2425 dealing = true
2426 startLuaCoroutine(nil, 'holeCoroutine')
2427 end
2428end
2429
2430--[[ If the rewind button is used while the options menu is open, the black square will remain and be non-interactable. This script is added to it so it self-destructs in that event. --]]
2431function addSelfDestruct()
2432 for i = 1, 5 do
2433 coroutine.yield(0)
2434 end
2435 if optionspanel ~= nil and optionspanel ~= null then
2436 optionspanel.setLuaScript('function onload() self.destruct() end')
2437 end
2438 return 1
2439end
2440
2441function optionsHost(ob, pl)
2442 if pl then
2443 if not Player[pl].admin then
2444 return 1
2445 end
2446 end
2447
2448 optionspanel.clearButtons()
2449
2450 local button = {}
2451 local s = ''
2452
2453 button.width = 150
2454 button.height = 150
2455 button.label = '☒'
2456 button.font_size = 125
2457 button.click_function = 'destroyOptionsPanel'
2458 button.position = {1.75, 0.05, -1.8}
2459 optionspanel.createButton(button)
2460
2461 button.width = 150
2462 button.height = 150
2463 button.label = 'â—„'
2464 button.font_size = 125
2465 button.click_function = 'optionsMain'
2466 button.position = {-1.75, 0.05, -1.8}
2467 optionspanel.createButton(button)
2468
2469 if options.actiontoggle then
2470 button.label = '☑ Action'
2471 else
2472 button.label = 'â–¡ Action'
2473 end
2474 button.font_size = 75
2475 button.width = 350
2476 button.height = 100
2477 button.click_function = 'actionToggle'
2478 button.position = {-1.5, 0.05, -1.5}
2479 optionspanel.createButton(button)
2480
2481 if options.actiontoggle then
2482 if options.playerclickaction then
2483 button.label = '+Players'
2484 else
2485 button.label = '+Host'
2486 end
2487 button.width = 350
2488 button.font_size = 75
2489 button.click_function = 'togglePlayerClickAction'
2490 button.position = {-1.5, 0.05, -1.25}
2491 optionspanel.createButton(button)
2492
2493 if options.autoclock then
2494 button.label = '☑ Autoclock'
2495 else
2496 button.label = 'â–¡ Autoclock'
2497 end
2498 button.position = {-1.35, 0.05, -1.0}
2499 button.width = 500
2500 button.click_function = 'toggleAutoclock'
2501 optionspanel.createButton(button)
2502
2503 if options.autoclock then
2504 button.label = '‹'
2505 button.width = 100
2506 button.click_function = 'decreaseAutoclockTime'
2507 button.position = {-1.7, 0.05, -0.75}
2508 optionspanel.createButton(button)
2509
2510 button.label = tostring(options.autoclocktime)
2511 button.width = 200
2512 button.position = {-1.35, 0.05, -0.75}
2513 button.click_function = 'doNothing'
2514 optionspanel.createButton(button)
2515
2516 button.label = '›'
2517 button.width = 100
2518 button.click_function = 'increaseAutoclockTime'
2519 button.position = {-1.0, 0.05, -0.75}
2520 optionspanel.createButton(button)
2521
2522 if options.clockpausebutton then
2523 button.label = '☑ Pause button'
2524 else
2525 button.label = '□ Pause button'
2526 end
2527 button.width = 600
2528 button.position = {-1.35, 0.05, -0.5}
2529 button.click_function = 'toggleAutoclockPauseButton'
2530 optionspanel.createButton(button)
2531 end
2532
2533 if options.autofold then
2534 button.label = '☑ Autofold'
2535 else
2536 button.label = 'â–¡ Autofold'
2537 end
2538 button.width = 500
2539 button.position = {-0.35, 0.05, -1.0}
2540 button.click_function = 'toggleAutofold'
2541 optionspanel.createButton(button)
2542 end
2543
2544 if options.collectmethod == 'move' then
2545 button.label = 'Collect method: Move'
2546 button.width = 800
2547 elseif options.collectmethod == 'convert' then
2548 button.label = 'Collect method: Convert'
2549 button.width = 850
2550 elseif options.collectmethod == 'hybrid' then
2551 button.label = 'Collect method: Hybrid:'
2552 button.width = 850
2553 else
2554 button.label = options.collectmethod
2555 button.width = 800
2556 end
2557 button.click_function = 'changeCollectMethod'
2558 button.position = {-1, 0.05, 0}
2559 optionspanel.createButton(button)
2560
2561 if options.collectmethod == 'hybrid' then
2562 button.label = '«'
2563 button.width = 100
2564 button.click_function = 'decreaseHybridThreshold1000'
2565 button.position = {0.0, 0.05, 0}
2566 optionspanel.createButton(button)
2567
2568 button.label = '‹'
2569 button.click_function = 'decreaseHybridThreshold100'
2570 button.position = {0.2, 0.05, 0}
2571 optionspanel.createButton(button)
2572
2573 button.label = '$'..tostring(options.hybridthreshold)
2574 button.width = 350
2575 button.click_function = 'doNothing'
2576 button.position = {0.65, 0.05, 0}
2577 optionspanel.createButton(button)
2578
2579 button.label = '›'
2580 button.width = 100
2581 button.click_function = 'increaseHybridThreshold100'
2582 button.position = {1.1, 0.05, 0}
2583 optionspanel.createButton(button)
2584
2585 button.label = '»'
2586 button.click_function = 'increaseHybridThreshold1000'
2587 button.position = {1.3, 0.05, 0}
2588 optionspanel.createButton(button)
2589 end
2590
2591 if options.collectmethod == 'convert' or options.collectmethod=='hybrid' then
2592
2593 button.label = 'Minimum Stack Height:'
2594 button.width = 850
2595 button.click_function = 'doNothing'
2596 button.position = {-1, 0.05, 0.25}
2597 optionspanel.createButton(button)
2598
2599 button.width = 100
2600 button.label = '‹'
2601 button.click_function = 'decreaseConvertStackHeight1'
2602 button.position = {0.2, 0.05, 0.25}
2603 optionspanel.createButton(button)
2604
2605 button.label = tostring(options.convertstackheight)
2606 button.width = 350
2607 button.click_function = 'doNothing'
2608 button.position = {0.65, 0.05, 0.25}
2609 optionspanel.createButton(button)
2610
2611 button.label = '›'
2612 button.width = 100
2613 button.click_function = 'increaseConvertStackHeight1'
2614 button.position = {1.1, 0.05, 0.25}
2615 optionspanel.createButton(button)
2616 end
2617
2618
2619 if options.blindsskipafk then
2620 button.label = '☑ Blinds Skip AFK'
2621 else
2622 button.label = 'â–¡ Blinds Skip AFK'
2623 end
2624 button.width = 650
2625 button.click_function = 'toggleBlindsSkipAFK'
2626 button.position = {-0.375, 0.05, -1.5}
2627 optionspanel.createButton(button)
2628
2629 if options.gamemode == 'omaha' then
2630 s = 'â–º'
2631 else
2632 s = ''
2633 end
2634 button.label = s..'Omaha Hold\'em'
2635 button.width = 650
2636 button.click_function = 'setGameModeOmaha'
2637 button.position = {1.0, 0.05, -1.0}
2638 optionspanel.createButton(button)
2639
2640 if options.gamemode == 'pineapple' then
2641 s = 'â–º'
2642 else
2643 s = ''
2644 end
2645 button.label = s..'Pineapple'
2646 button.width = 700
2647 button.click_function = 'setGameModePineapple'
2648 button.position = {1.0, 0.05, -1.25}
2649 optionspanel.createButton(button)
2650
2651 if options.gamemode == 'texas' then
2652 s = 'â–º'
2653 else
2654 s = ''
2655 end
2656 button.label = s..'Texas Hold\'em'
2657 button.width = 600
2658 button.click_function = 'setGameModeTexas'
2659 button.position = {1.0, 0.05, -1.5}
2660 optionspanel.createButton(button)
2661
2662 if options.displayplayerbet then
2663 button.label = '☑ Display Player Bets'
2664 else
2665 button.label = 'â–¡ Display Player Bet'
2666 end
2667 button.width = 1000
2668 button.click_function = 'toggleDisplayPlayerBet'
2669 button.position = {-1, 0.05, 0.6}
2670 optionspanel.createButton(button)
2671
2672 if options.displayplayermoney then
2673 button.label = '☑ Display Player Money'
2674 else
2675 button.label = 'â–¡ Display Player Money'
2676 end
2677 button.width = 1000
2678 button.click_function = 'toggleDisplayPlayerMoney'
2679 button.position = {-1, 0.05, 0.8}
2680 optionspanel.createButton(button)
2681
2682 if options.changemachine then
2683 button.label = '☑ change Machine'
2684 else
2685 button.label = 'â–¡ change Machine'
2686 end
2687 button.width = 1000
2688 button.click_function = 'togglechangeMachine'
2689 button.position = {-1, 0.05, 1}
2690 optionspanel.createButton(button)
2691
2692
2693 if options.playerbuttons.sortchips then
2694 button.label = '☑ Display Sort Chips Button'
2695 else
2696 button.label = 'â–¡ Display Sort Chips Button'
2697 end
2698 button.width = 1000
2699 button.click_function = 'toggleDisplaySortChips'
2700 button.position = {1, 0.05, 0.6}
2701 optionspanel.createButton(button)
2702
2703
2704 if options.playerbuttons.convert then
2705 button.label = '☑ Display Convert Button'
2706 else
2707 button.label = 'â–¡ Display Convert Button'
2708 end
2709 button.width = 1000
2710 button.click_function = 'toggleDisplayConvert'
2711 button.position = {1, 0.05, 0.8}
2712 optionspanel.createButton(button)
2713
2714 if options.playerbuttons.allin then
2715 button.label = '☑ Display AllIn Button'
2716 else
2717 button.label = 'â–¡ Display AllIn Button'
2718 end
2719 button.width = 1000
2720 button.click_function = 'toggleDisplayAllIn'
2721 button.position = {1, 0.05, 1}
2722 optionspanel.createButton(button)
2723
2724 if options.playerbuttons.afk then
2725 button.label = '☑ Display AFK Button'
2726 else
2727 button.label = 'â–¡ Display AFK Button'
2728 end
2729 button.width = 1000
2730 button.click_function = 'toggleDisplayAFK'
2731 button.position = {1, 0.05, 1.2}
2732 optionspanel.createButton(button)
2733
2734
2735 if options.playerbuttons.loadsavebag then
2736 button.label = '☑ Display Load Save Button'
2737 else
2738 button.label = 'â–¡ Display Load Save Button'
2739 end
2740 button.width = 1000
2741 button.click_function = 'toggleLoadSaves'
2742 button.position = {1, 0.05, 1.4}
2743 optionspanel.createButton(button)
2744
2745end
2746
2747
2748
2749function optionsChat(ob, pl)
2750
2751 if pl then
2752 if not Player[pl].admin then
2753 return 1
2754 end
2755 end
2756
2757 optionspanel.clearButtons()
2758
2759 local button = {}
2760
2761 button.width = 150
2762 button.height = 150
2763 button.label = '☒'
2764 button.font_size = 125
2765 button.click_function = 'destroyOptionsPanel'
2766 button.position = {1.75, 0.05, -1.8}
2767 optionspanel.createButton(button)
2768
2769 button.width = 150
2770 button.height = 150
2771 button.label = 'â—„'
2772 button.font_size = 125
2773 button.click_function = 'optionsMain'
2774 button.position = {-1.75, 0.05, -1.8}
2775 optionspanel.createButton(button)
2776
2777 button.width = 650
2778 button.height = 150
2779 button.font_size = 75
2780 if options.chatoptions.actionmessage then
2781 button.label = '☑ Action message'
2782 else
2783 button.label = 'â–¡ Action message'
2784 end
2785 button.click_function = 'toggleActionMessage'
2786 button.position = {-1.0, 0.05, -1.5}
2787 optionspanel.createButton(button)
2788
2789 button.width = 700
2790 button.height = 150
2791 button.font_size = 75
2792 if options.chatoptions.actionbroadcast then
2793 button.label = '☑ Action broadcast'
2794 else
2795 button.label = 'â–¡ Action broadcast'
2796 end
2797 button.click_function = 'toggleActionBroadcast'
2798 button.position = {-1.0, 0.05, -1.25}
2799 optionspanel.createButton(button)
2800
2801 button.width = 600
2802 button.height = 150
2803 button.font_size = 75
2804 if options.chatoptions.currentbetmessage then
2805 button.label = '☑ Current bet'
2806 else
2807 button.label = 'â–¡ Current bet'
2808 end
2809 button.click_function = 'toggleCurrentBetMessage'
2810 button.position = {1.0, 0.05, -1.5}
2811 optionspanel.createButton(button)
2812
2813 button.width = 600
2814 button.height = 150
2815 button.font_size = 75
2816 if options.chatoptions.better then
2817 button.label = '☑ └Better/raiser'
2818 else
2819 button.label = 'â–¡ â””Better/raiser'
2820 end
2821 button.click_function = 'toggleBetter'
2822 button.position = {1.0, 0.05, -1.25}
2823 if options.chatoptions.currentbetmessage then
2824 optionspanel.createButton(button)
2825 end
2826
2827 button.width = 700
2828 button.height = 150
2829 button.font_size = 75
2830 if options.chatoptions.allinbroadcast then
2831 button.label = '☑ All-in broadcast'
2832 else
2833 button.label = 'â–¡ All-in broadcast'
2834 end
2835 button.click_function = 'toggleAllinBroadcast'
2836 button.position = {1.0, 0.05, -1.0}
2837 optionspanel.createButton(button)
2838
2839 button.height = 150
2840 button.font_size = 75
2841 if options.chatoptions.potmessage == 0 then
2842 button.width = 700
2843 button.label = 'Pot message: Off'
2844 elseif options.chatoptions.potmessage == 1 then
2845 button.width = 1000
2846 button.label = 'Pot message: On collect only'
2847 elseif options.chatoptions.potmessage == 2 then
2848 button.width = 900
2849 button.label = 'Pot message: On change'
2850 end
2851 button.click_function = 'togglePotMessage'
2852 button.position = {1.0, 0.05, -0.75}
2853 optionspanel.createButton(button)
2854
2855 button.width = 850
2856 button.height = 150
2857 button.font_size = 75
2858 if options.chatoptions.stage then
2859 button.label = '☑ Game stage broadcast'
2860 else
2861 button.label = 'â–¡ Game stage broadcast'
2862 end
2863 button.click_function = 'toggleStageBroadcast'
2864 button.position = {-1.0, 0.05, -1.0}
2865 optionspanel.createButton(button)
2866
2867end
2868
2869function optionsThemes(ob, pl)
2870 if pl then
2871 if not Player[pl].admin then
2872 return 1
2873 end
2874 end
2875 optionspanel.clearButtons()
2876
2877 local button = {}
2878
2879 button.width = 150
2880 button.height = 150
2881 button.label = '☒'
2882 button.font_size = 125
2883 button.click_function = 'destroyOptionsPanel'
2884 button.position = {1.75, 0.05, -1.8}
2885 optionspanel.createButton(button)
2886
2887 button.width = 150
2888 button.height = 150
2889 button.label = 'â—„'
2890 button.font_size = 125
2891 button.click_function = 'optionsMain'
2892 button.position = {-1.75, 0.05, -1.8}
2893 optionspanel.createButton(button)
2894
2895 button.label = 'Set Font Color'
2896 button.width = 600
2897 button.font_size = 75
2898 button.click_function = 'changeFontColor'
2899 button.position = {-0.75, 0.05, -1.75}
2900 optionspanel.createButton(button)
2901
2902 button.label = 'Set Overlay Color'
2903 button.width = 600
2904 button.click_function = 'changeTableColor'
2905 button.position = {0.75, 0.05, -1.75}
2906 optionspanel.createButton(button)
2907
2908 button.label = 'Darken Overlay'
2909 button.width = 600
2910 button.click_function = 'darkenOverlay'
2911 button.position = {-0.75, 0.05, -1.5}
2912 optionspanel.createButton(button)
2913
2914 button.label = 'Lighten Overlay'
2915 button.width = 600
2916 button.click_function = 'lightenOverlay'
2917 button.position = {0.75, 0.05, -1.5}
2918 optionspanel.createButton(button)
2919
2920
2921
2922 --[[ spawn theme buttons --]]
2923 for i, v in ipairs (themes) do
2924 local s = ''
2925 if i == themeindex then
2926 s = 'â–º'
2927 end
2928 button.width = (((string.len(themes[i].label) + string.len(s)) * 40) + 0 )
2929 button.height = 100
2930 button.font_size = 65
2931 button.label = themes[i].label..s
2932 button.click_function = 'setTheme'..tostring(i)
2933 button.position = {-1.75, 0.05, (-1 + ((i-1) * 0.25))}
2934 optionspanel.createButton(button)
2935 end
2936
2937 --[[ spawn subtheme buttons --]]
2938 for i, v in ipairs (themes[themeindex]) do
2939 local s = ''
2940 if i == subthemeindex then
2941 s = 'â–º'
2942 end
2943 button.width = (((string.len(themes[themeindex][i].label) + string.len(s)) * 40) + 0)
2944 button.height = 100
2945 button.label = themes[themeindex][i].label..s
2946 button.click_function = 'setSubtheme'..tostring(i)
2947 button.position = {-0.75, 0.05, (-1 + ((i-1) * 0.25))}
2948 optionspanel.createButton(button)
2949 end
2950
2951 --[[ spawn diffuse buttons --]]
2952 for i, v in ipairs (themes[themeindex][subthemeindex]) do
2953 button.width = ((string.len(themes[themeindex][subthemeindex][i].label) * 35) + 0)
2954 button.height = 100
2955 button.label = themes[themeindex][subthemeindex][i].label
2956 button.click_function = 'overlay'..tostring(i)
2957 button.position = {1, 0.05, (-1 + ((i-1) * 0.25))}
2958 optionspanel.createButton(button)
2959 end
2960
2961 if colorball == nil or colorball == null then
2962 local params = {}
2963 local p = optionspanel.getPosition()
2964 params.position = {p.x, p.y, p.z + 3.5}
2965 params.type = 'go_game_piece_white'
2966 params.scale = {0.5, 0.5, 0.5}
2967
2968 colorball = spawnObject(params)
2969 --local color = pottext.TextTool.getFontColor()
2970 colorball.lock()
2971 colorball.setColorTint(color)
2972 colorball.setDescription('Change my color tint, then click \'Font Color\' button to change color of text fonts.')
2973 end
2974
2975end
2976
2977function toggleDisplayConvert(ob,pl)
2978 if pl then
2979 if not Player[pl].admin then
2980 return 1
2981 end
2982 end
2983 options.playerbuttons.convert = not options.playerbuttons.convert
2984 createPlayerButtons()
2985 optionsHost()
2986end
2987
2988function toggleDisplaySortChips(ob,pl)
2989 if pl then
2990 if not Player[pl].admin then
2991 return 1
2992 end
2993 end
2994 options.playerbuttons.sortchips = not options.playerbuttons.sortchips
2995 createPlayerButtons()
2996 optionsHost()
2997end
2998
2999function toggleDisplayAllIn(ob,pl)
3000 if pl then
3001 if not Player[pl].admin then
3002 return 1
3003 end
3004 end
3005 options.playerbuttons.allin = not options.playerbuttons.allin
3006 createPlayerButtons()
3007 optionsHost()
3008end
3009
3010function toggleDisplayAFK(ob,pl)
3011 if pl then
3012 if not Player[pl].admin then
3013 return 1
3014 end
3015 end
3016 options.playerbuttons.afk = not options.playerbuttons.afk
3017 createPlayerButtons()
3018 optionsHost()
3019end
3020
3021function toggleDisplayPlayerBet(ob, pl)
3022 if pl then
3023 if not Player[pl].admin then
3024 return 1
3025 end
3026 end
3027 options.displayplayerbet = not options.displayplayerbet
3028 calculatePots()
3029 optionsHost()
3030end
3031
3032function toggleLoadSaves(ob, pl)
3033 if pl then
3034 if not Player[pl].admin then
3035 return 1
3036 end
3037 end
3038 options.playerbuttons.loadsavebag = not options.playerbuttons.loadsavebag
3039 createPlayerButtons()
3040 optionsHost()
3041end
3042
3043function togglechangeMachine(ob, pl)
3044 if pl then
3045 if not Player[pl].admin then
3046 return 1
3047 end
3048 end
3049 options.changemachine = not options.changemachine
3050
3051 for i, v in ipairs(getAllObjects()) do
3052 if v.getName() == 'Back Table' then
3053 v.clearButtons()
3054 if options.changemachine then
3055 local offsetx = 2/#currencies
3056 local button = {}
3057
3058 if #currencies <= 10 then
3059 offsetx = 1.65/(#currencies-2)
3060 else
3061 offsetx = 1.65/8
3062 end
3063 local offsety = 2/#currencies
3064 button.font_size = 150
3065 button.width = 450
3066 button.height = 250
3067 button.scale = {1/5, 1/5, 1/7.5}
3068 button.position = {0.83, -0.1, -0.9}
3069 button.rotation = {180, 0, 0}
3070
3071 for j, w in ipairs(currencies) do
3072 if w.value ~= -1 then
3073 button.label = w.label
3074 button.click_function = 'changeMachineButton' .. j
3075 v.createButton(button)
3076 button.position[1] = button.position[1] - offsetx
3077 end
3078 if j == 9 then
3079 if #currencies - 11 > 0 then
3080 offsetx = 1.65/(#currencies-11)
3081 button.position = {0.83, -0.1, -0.8} -- spawn 1 button in the center
3082 else
3083 button.position = {0, -0.1, -0.8} -- spawn 1 button in the center
3084 end
3085 end
3086 end
3087 end
3088 end
3089 end
3090
3091
3092 optionsHost()
3093end
3094
3095function toggleDisplayPlayerMoney(ob, pl)
3096 if pl then
3097 if not Player[pl].admin then
3098 return 1
3099 end
3100 end
3101 options.displayplayermoney = not options.displayplayermoney
3102
3103 if options.displayplayermoney then
3104 for i, v in ipairs (colors) do
3105 money = getChipValues(tablezones[v],chips)
3106 --tablezonetext[v].setValue("$" .. money)
3107
3108 end
3109 else
3110 for i, v in ipairs (colors) do
3111 --tablezonetext[v].setValue(" ")
3112 end
3113 end
3114 optionsHost()
3115end
3116
3117
3118
3119function optionsCurrencies(ob, pl)
3120 if pl then
3121 if not Player[pl].admin then
3122 return 1
3123 end
3124 end
3125 optionspanel.clearButtons()
3126
3127 local button = {}
3128
3129 button.width = 150
3130 button.height = 150
3131 button.label = '☒'
3132 button.font_size = 125
3133 button.click_function = 'destroyOptionsPanel'
3134 button.position = {1.75, 0.05, -1.8}
3135 optionspanel.createButton(button)
3136
3137 button.width = 150
3138 button.height = 150
3139 button.label = 'â—„'
3140 button.font_size = 125
3141 button.click_function = 'optionsMain'
3142 button.position = {-1.75, 0.05, -1.8}
3143 optionspanel.createButton(button)
3144
3145 --[[ spawn currencies buttons --]]
3146
3147 button.width = 500
3148 button.height = 100
3149 button.font_size = 100
3150 button.label = "Currency"
3151 button.click_function = 'doNothing'
3152 button.position = {-1.25, 0.05, -1.55 }
3153 optionspanel.createButton(button)
3154
3155 button.width = 500
3156 button.height = 100
3157 button.font_size = 100
3158 button.label = "Layout"
3159 button.click_function = 'doNothing'
3160 button.position = {1, 0.05, -1.55 }
3161 optionspanel.createButton(button)
3162
3163
3164 button.position = {-1.25, 0.05, -1.25 }
3165 local c = 0
3166 for i, v in pairs (currenciesSelectionStacklayout ) do
3167 c=c+1
3168 local s = ''
3169 if i == options.currencies then
3170 s = 'â–º'
3171 end
3172 button.width = (((string.len(i) + string.len(s)) * 30) + 40 )
3173 button.height = 100
3174 button.font_size = 65
3175 button.label = i..s
3176 button.click_function = 'changeCurrencies' .. c
3177 button.position[3] = button.position[3]+0.25
3178 optionspanel.createButton(button)
3179 if i == options.currencies then
3180 for j, w in ipairs (v) do
3181 local s = ''
3182 if w == options.stacklayout then
3183 s = 'â–º'
3184 end
3185 local button2 = {}
3186 button2.width = (((string.len(w) + string.len(s)) * 30) + 40)
3187 button2.font_size = 65
3188 button2.height = 100
3189 button2.label = w..s
3190 button2.click_function = 'setStacklayout' .. j
3191 button2.position = {1, 0.05, (-1 + ((j-1) * 0.25))}
3192 optionspanel.createButton(button2)
3193 end
3194 end
3195 end
3196end
3197
3198
3199
3200function setStacklayout1(ob, pl)
3201 if pl then
3202 if not Player[pl].admin then
3203 return 1
3204 end
3205 end
3206 options.stacklayout = currenciesSelectionStacklayout[options.currencies][1]
3207 optionsCurrencies()
3208end
3209
3210function setStacklayout2(ob, pl)
3211 if pl then
3212 if not Player[pl].admin then
3213 return 1
3214 end
3215 end
3216 options.stacklayout = currenciesSelectionStacklayout[options.currencies][2]
3217 optionsCurrencies()
3218end
3219
3220function setStacklayout3(ob, pl)
3221 if pl then
3222 if not Player[pl].admin then
3223 return 1
3224 end
3225 end
3226 options.stacklayout = currenciesSelectionStacklayout[options.currencies][3]
3227 optionsCurrencies()
3228end
3229
3230function setStacklayout4(ob, pl)
3231 if pl then
3232 if not Player[pl].admin then
3233 return 1
3234 end
3235 end
3236 options.stacklayout = currenciesSelectionStacklayout[options.currencies][4]
3237 optionsCurrencies()
3238end
3239function setStacklayout5(ob, pl)
3240 if pl then
3241 if not Player[pl].admin then
3242 return 1
3243 end
3244 end
3245 options.stacklayout = currenciesSelectionStacklayout[options.currencies][5]
3246 optionsCurrencies()
3247end
3248function setStacklayout6(ob, pl)
3249 if pl then
3250 if not Player[pl].admin then
3251 return 1
3252 end
3253 end
3254 options.stacklayout = currenciesSelectionStacklayout[options.currencies][6]
3255 optionsCurrencies()
3256end
3257function setStacklayout7(ob, pl)
3258 if pl then
3259 if not Player[pl].admin then
3260 return 1
3261 end
3262 end
3263 options.stacklayout = currenciesSelectionStacklayout[options.currencies][7]
3264 optionsCurrencies()
3265end
3266function setStacklayout8(ob, pl)
3267 if pl then
3268 if not Player[pl].admin then
3269 return 1
3270 end
3271 end
3272 options.stacklayout = currenciesSelectionStacklayout[options.currencies][8]
3273 optionsCurrencies()
3274end
3275
3276function setStacklayout9(ob, pl)
3277 if pl then
3278 if not Player[pl].admin then
3279 return 1
3280 end
3281 end
3282 options.stacklayout = currenciesSelectionStacklayout[options.currencies][9]
3283 optionsCurrencies()
3284end
3285
3286function setStacklayout10(ob, pl)
3287 if pl then
3288 if not Player[pl].admin then
3289 return 1
3290 end
3291 end
3292 options.stacklayout = currenciesSelectionStacklayout[options.currencies][10]
3293 optionsCurrencies()
3294end
3295
3296
3297function changeCurrencies1(ob, pl)
3298 if pl then
3299 if not Player[pl].admin then
3300 return 1
3301 end
3302 end
3303 changeCurrenciesCo(1)
3304end
3305
3306
3307
3308function changeCurrenciesCo(number)
3309 c=0
3310 for i, v in pairs (currenciesSelectionStacklayout ) do
3311 c=c+1
3312 if(c == number) then
3313 options.currencies = i
3314 options.stacklayout = v[1]
3315 currencies = currenciesSelection[i]
3316 end
3317 end
3318
3319 for i, v in ipairs(getAllObjects()) do
3320 -- Update Buttons
3321 if v.getName() == 'Back Table' then
3322 v.clearButtons()
3323 if options.changemachine then
3324 local offsetx = 2/#currencies
3325 local button = {}
3326
3327 if #currencies <= 10 then
3328 offsetx = 1.65/(#currencies-2)
3329 else
3330 offsetx = 1.65/8
3331 end
3332 local offsety = 2/#currencies
3333 button.font_size = 150
3334 button.width = 450
3335 button.height = 250
3336 button.scale = {1/5, 1/5, 1/7.5}
3337 button.position = {0.83, -0.1, -0.9}
3338 button.rotation = {180, 0, 0}
3339
3340 for j, w in ipairs(currencies) do
3341 if w.value ~= -1 then
3342 button.label = w.label
3343 button.click_function = 'changeMachineButton' .. j
3344 v.createButton(button)
3345 button.position[1] = button.position[1] - offsetx
3346 end
3347 if j == 9 then
3348 if #currencies - 11 > 0 then
3349 offsetx = 1.65/(#currencies-11)
3350 button.position = {0.83, -0.1, -0.8} -- spawn 1 button in the center
3351 else
3352 button.position = {0, -0.1, -0.8} -- spawn 1 button in the center
3353 end
3354 end
3355 end
3356 end
3357
3358 end
3359 -- Delete Old Infinite Money Bags
3360 if v.getDescription() == 'Infinite Money Bag' then
3361 v.destruct()
3362 end
3363 end
3364
3365
3366 -- spawn infinite Bags
3367 local params = {}
3368 local posx = 2
3369 local posy = 2.2
3370 local posz = -23
3371
3372 local offsetx = 4
3373 local offsetz = -1.7
3374
3375
3376 for i, v in ipairs (currencies) do
3377 if v.value == -1 then
3378 break -- no dummy chips spawn
3379 end
3380 if not v.standard then
3381 params.position = {}
3382 params.position.x = posx + offsetx * ((i-1) % 2)
3383 params.position.y = posy
3384 params.position.z = posz + offsetz * math.floor((i-1)/2)
3385 --rPrint(params.position,100,i .. ": ")
3386 params.position[1] = params.position.x
3387 params.position[2] = params.position.y
3388 params.position[3] = params.position.z
3389
3390
3391 params.rotation = v.params.rotation
3392 params.rotation[2] = (params.rotation[2] + 180) % 360
3393 params.scale = v.params.scale
3394 params.params = {v.name}
3395 params.type = 'Custom_Model'
3396 params.callback = ''
3397 params.callback_owner = Global
3398 custom = {}
3399 custom.mesh = v.custom.mesh
3400 custom.diffuse = v.custom.diffuse
3401 custom.type = 7 -- infinite
3402 custom.material = 1
3403
3404 obj = spawnObject(params)
3405 obj.setCustomObject(custom)
3406 obj.setName(v.name)
3407 obj.setDescription("Infinite Money Bag")
3408
3409
3410 -- let chip fall into bag
3411 params.position.y = posy + 3
3412 params.position[2] = posy + 3
3413 custom.type = 5 -- chip
3414 obj = spawnObject(params)
3415 obj.setCustomObject(custom)
3416 obj.setName(v.name)
3417 end
3418 end
3419
3420
3421
3422
3423
3424 optionsCurrencies()
3425end
3426
3427
3428function spawnClock(ob, pl)
3429 if pl then
3430 if not Player[pl].admin then
3431 return 1
3432 end
3433 end
3434
3435 if clock ~= nil and clock ~= null then
3436 if pl then
3437 clock.Clock.setValue(options.clocktime + 1)
3438 clock.Clock.pauseStart()
3439 clock.clearButtons()
3440 end
3441 return 1
3442 end
3443
3444 local params = {}
3445 if actionon then
3446 local playerhand = getPlayerHandPositionAndRotation(actionon)
3447
3448 params.position = {playerhand['pos_x'] + playerhand['trigger_forward_x'] * 8, 0.5, playerhand['pos_z'] + playerhand['trigger_forward_z'] * 8}
3449 params.rotation = {90, playerhand['rot_y'], 0}
3450 else
3451 params.position = {0, 0.5, -4}
3452 params.rotation = {90, 180, 0}
3453 end
3454
3455 params.type = 'Digital_Clock'
3456 params.callback = 'setClockTimer'
3457 if pl then
3458 params.params = {pl}
3459 else
3460 params.params = nil
3461 end
3462
3463 clock = spawnObject(params)
3464
3465end
3466
3467function setClockTimer(ob, pl)
3468 clock.lock()
3469
3470 if pl then
3471 clock.Clock.setValue(options.clocktime + 1)
3472 else
3473 clock.Clock.setValue(options.autoclocktime + 1)
3474 end
3475
3476 clock.Clock.pauseStart()
3477
3478 if options.autoclock and options.clockpausebutton and not pl then
3479 local button = {}
3480 button.rotation = {90, 180, 0}
3481 button.position = {-0.3, 0.5, -0.15}
3482 button.font_size = 60
3483 button.width = 200
3484 button.height = 50
3485 button.label = 'Pause'
3486 button.click_function = 'pauseClock'
3487 clock.createButton(button)
3488 end
3489 startLuaCoroutine(nil, 'setClockTimerCoroutine')
3490end
3491
3492function setClockTimerCoroutine()
3493
3494 local clockGUID = clock.getGUID()
3495
3496 while clock ~= nil and clock ~= null and clock.Clock.getValue() > 0 do
3497 coroutine.yield(0)
3498 end
3499
3500 local t = os.clock()
3501
3502 while os.clock() < t+1 do
3503 coroutine.yield(0)
3504 end
3505
3506 if clock ~= nil and clock ~= null then
3507 if clockGUID ~= clock.getGUID() then
3508 return 1
3509 end
3510 else
3511 return 1
3512 end
3513
3514 if options.autofold then
3515 foldPlayer()
3516 end
3517
3518 clock.destruct()
3519
3520 return 1
3521end
3522
3523function toggleAutoclock(ob, pl)
3524 if not Player[pl].admin then
3525 return 1
3526 end
3527
3528 options.autoclock = not options.autoclock
3529 optionsHost()
3530end
3531
3532function toggleAutofold(ob, pl)
3533 if not Player[pl].admin then
3534 return 1
3535 end
3536
3537 options.autofold = not options.autofold
3538 optionsHost()
3539end
3540
3541function decreaseAutoclockTime(ob, pl)
3542 if not Player[pl].admin then
3543 return 1
3544 end
3545
3546 if options.autoclocktime > 1 then
3547 options.autoclocktime = options.autoclocktime - 1
3548 end
3549 optionsHost()
3550end
3551
3552function increaseAutoclockTime(ob, pl)
3553 if not Player[pl].admin then
3554 return 1
3555 end
3556
3557 options.autoclocktime = options.autoclocktime + 1
3558 optionsHost()
3559end
3560
3561function toggleAutoclockPauseButton(ob, pl)
3562 if not Player[pl].admin then
3563 return 1
3564 end
3565
3566 options.clockpausebutton = not options.clockpausebutton
3567 optionsHost()
3568end
3569
3570function pauseClock(ob, pl)
3571 if not Player[pl].admin and pl ~= actionon then
3572 return 1
3573 end
3574
3575 clock.Clock.pauseStart()
3576end
3577
3578function decreaseClockTime5(ob, pl)
3579 if not Player[pl].admin then
3580 return 1
3581 end
3582
3583 if options.clocktime > 5 then
3584 options.clocktime = options.clocktime - 5
3585 else
3586 return 1
3587 end
3588
3589 optionsMain()
3590end
3591function decreaseClockTime1(ob, pl)
3592 if not Player[pl].admin then
3593 return 1
3594 end
3595
3596 if options.clocktime > 1 then
3597 options.clocktime = options.clocktime - 1
3598 else
3599 return 1
3600 end
3601
3602 optionsMain()
3603end
3604function increaseClockTime1(ob, pl)
3605 if not Player[pl].admin then
3606 return 1
3607 end
3608
3609 options.clocktime = options.clocktime + 1
3610
3611 optionsMain()
3612end
3613function increaseClockTime5(ob, pl)
3614 if not Player[pl].admin then
3615 return 1
3616 end
3617
3618 options.clocktime = options.clocktime + 5
3619
3620 optionsMain()
3621end
3622
3623function foldPlayer(ob, pl)
3624
3625 if pl then
3626 if not Player[pl].admin then
3627 return 1
3628 end
3629 end
3630
3631 if muck == nil or muck == null then
3632 checkAndRespawnObjects()
3633 --print ('The muck object has been lost. Please click the \'Reset Objects\' button on the options panel to reassign.')
3634 --return 1
3635 end
3636
3637 if actionon then
3638 local cards = Player[actionon].getHandObjects()
3639 local p = muck.getPosition()
3640 local r = muck.getRotation()
3641 p.y = p.y + 0.25
3642 r.x = 180
3643 r.z = 0
3644
3645 for i, v in ipairs (cards) do
3646 v.setRotation(r)
3647 v.setPosition(p)
3648 v.translate({0, 0.1, 0})
3649 p.y = p.y + 0.01
3650 end
3651 end
3652
3653 startLuaCoroutine(nil, 'delayedAction')
3654end
3655
3656function delayedAction()
3657 for i = 1, 2 do
3658 coroutine.yield(0)
3659 end
3660
3661 action()
3662 return 1
3663end
3664
3665function decreaseHybridThreshold1000(ob, pl)
3666 if not Player[pl].admin then
3667 return 1
3668 end
3669
3670 if options.hybridthreshold > 1000 then
3671 options.hybridthreshold = options.hybridthreshold - 1000
3672 end
3673
3674 optionsHost()
3675end
3676
3677function decreaseHybridThreshold100(ob, pl)
3678 if not Player[pl].admin then
3679 return 1
3680 end
3681
3682 if options.hybridthreshold > 100 then
3683 options.hybridthreshold = options.hybridthreshold - 100
3684 end
3685
3686 optionsHost()
3687end
3688
3689function increaseHybridThreshold100(ob, pl)
3690 if not Player[pl].admin then
3691 return 1
3692 end
3693
3694 options.hybridthreshold = options.hybridthreshold + 100
3695
3696 optionsHost()
3697end
3698
3699function increaseHybridThreshold1000(ob, pl)
3700 if not Player[pl].admin then
3701 return 1
3702 end
3703
3704 options.hybridthreshold = options.hybridthreshold + 1000
3705
3706 optionsHost()
3707end
3708
3709
3710function decreaseConvertStackHeight1(ob, pl)
3711 if not Player[pl].admin then
3712 return 1
3713 end
3714
3715 if options.convertstackheight > 1 then
3716 options.convertstackheight = options.convertstackheight - 1
3717 else
3718 options.convertstackheight = 0
3719 end
3720
3721 optionsHost()
3722end
3723
3724function increaseConvertStackHeight1(ob, pl)
3725 if not Player[pl].admin then
3726 return 1
3727 end
3728 options.convertstackheight = options.convertstackheight + 1
3729
3730 if options.convertstackheight >= 10 then
3731 options.convertstackheight = 10
3732 end
3733 optionsHost()
3734end
3735
3736
3737
3738
3739
3740
3741
3742function doNothing()
3743end
3744
3745function changeFontColor(ob, pl)
3746
3747 if not Player[pl].admin then
3748 return 1
3749 end
3750
3751 local color = colorball.getColorTint()
3752 --pottext.TextTool.setFontColor(color)
3753 --currentbettext.TextTool.setFontColor(color)
3754 muck.setColorTint(color)
3755 boardobject.setColorTint(color)
3756end
3757
3758function changeTableColor(ob, pl)
3759
3760 if not Player[pl].admin then
3761 return 1
3762 end
3763
3764 local color = colorball.getColorTint()
3765 overlay.setColorTint(color)
3766end
3767
3768function setGameModeTexas(ob, pl)
3769
3770 if not Player[pl].admin or options.gamemode == 'texas' then
3771 return 1
3772 end
3773
3774 options.gamemode = 'texas'
3775 printToAll('Game mode set to Texas Hold\'em. See rules in the notebook if you don\'t know how to play.', {1, 1, 1})
3776
3777 optionsHost()
3778end
3779function setGameModeOmaha(ob, pl)
3780
3781 if not Player[pl].admin or options.gamemode == 'omaha' then
3782 return 1
3783 end
3784
3785 options.gamemode = 'omaha'
3786 printToAll('Game mode set to Omaha Hold\'em. See rules in the notebook if you don\'t know how to play.', {1, 1, 1})
3787
3788 optionsHost()
3789end
3790function setGameModePineapple(ob, pl)
3791
3792 if not Player[pl].admin or options.gamemode == 'pineapple' then
3793 return 1
3794 end
3795
3796 options.gamemode = 'pineapple'
3797 printToAll('Game mode set to Pineapple. See rules in the notebook if you don\'t know how to play.', {1, 1, 1})
3798
3799 optionsHost()
3800end
3801function setGameModeFiveCard(ob, pl)
3802
3803 if not Player[pl].admin or options.gamemode == 'fivecard' then
3804 return 1
3805 end
3806
3807 options.gamemode = 'fivedraw'
3808 printToAll('Game mode set to Five Card Draw. See rules in the notebook if you don\'t know how to play.', {1, 1, 1})
3809
3810 optionsHost()
3811end
3812
3813function getParams(obj)
3814 local params = {}
3815 params.position = obj.getPosition()
3816 params.scale = obj.getScale()
3817 params.rotation = obj.getRotation()
3818
3819 return params
3820end
3821
3822function setTheme1(ob, pl)
3823
3824 if not Player[pl].admin then
3825 return 1
3826 end
3827
3828 themeindex = 1
3829 subthemeindex = 1
3830 optionsThemes()
3831end
3832
3833function setTheme2(ob, pl)
3834
3835 if not Player[pl].admin then
3836 return 1
3837 end
3838
3839 themeindex = 2
3840 subthemeindex = 1
3841 optionsThemes()
3842end
3843
3844function setTheme3(ob, pl)
3845
3846 if not Player[pl].admin then
3847 return 1
3848 end
3849
3850 themeindex = 3
3851 subthemeindex = 1
3852 optionsThemes()
3853end
3854
3855function setTheme4(ob, pl)
3856
3857 if not Player[pl].admin then
3858 return 1
3859 end
3860
3861 themeindex = 4
3862 subthemeindex = 1
3863 optionsThemes()
3864end
3865
3866function setTheme5(ob, pl)
3867
3868 if not Player[pl].admin then
3869 return 1
3870 end
3871
3872 themeindex = 5
3873 subthemeindex = 1
3874 optionsThemes()
3875end
3876
3877function setTheme6(ob, pl)
3878
3879 if not Player[pl].admin then
3880 return 1
3881 end
3882
3883 themeindex = 6
3884 subthemeindex = 1
3885 optionsThemes()
3886end
3887
3888function setTheme7(ob, pl)
3889
3890 if not Player[pl].admin then
3891 return 1
3892 end
3893
3894 themeindex = 7
3895 subthemeindex = 1
3896 optionsThemes()
3897end
3898
3899function setTheme8(ob, pl)
3900
3901 if not Player[pl].admin then
3902 return 1
3903 end
3904
3905 themeindex = 8
3906 subthemeindex = 1
3907 optionsThemes()
3908end
3909
3910function setTheme9(ob, pl)
3911
3912 if not Player[pl].admin then
3913 return 1
3914 end
3915
3916 themeindex = 9
3917 subthemeindex = 1
3918 optionsThemes()
3919end
3920
3921function setTheme10(ob, pl)
3922
3923 if not Player[pl].admin then
3924 return 1
3925 end
3926
3927 themeindex = 10
3928 subthemeindex = 1
3929 optionsThemes()
3930end
3931
3932function setTheme11(ob, pl)
3933
3934 if not Player[pl].admin then
3935 return 1
3936 end
3937
3938 themeindex = 11
3939 subthemeindex = 1
3940 optionsThemes()
3941end
3942
3943function setTheme12(ob, pl)
3944
3945 if not Player[pl].admin then
3946 return 1
3947 end
3948
3949 themeindex = 12
3950 subthemeindex = 1
3951 optionsThemes()
3952end
3953
3954function setSubtheme1(ob, pl)
3955
3956 if not Player[pl].admin then
3957 return 1
3958 end
3959
3960 subthemeindex = 1
3961 optionsThemes()
3962end
3963function setSubtheme2(ob, pl)
3964
3965 if not Player[pl].admin then
3966 return 1
3967 end
3968
3969 subthemeindex = 2
3970 optionsThemes()
3971end
3972function setSubtheme3(ob, pl)
3973
3974 if not Player[pl].admin then
3975 return 1
3976 end
3977
3978 subthemeindex = 3
3979 optionsThemes()
3980end
3981function setSubtheme4(ob, pl)
3982
3983 if not Player[pl].admin then
3984 return 1
3985 end
3986
3987 subthemeindex = 4
3988 optionsThemes()
3989end
3990function setSubtheme5(ob, pl)
3991
3992 if not Player[pl].admin then
3993 return 1
3994 end
3995
3996 subthemeindex = 5
3997 optionsThemes()
3998end
3999function setSubtheme6(ob, pl)
4000
4001 if not Player[pl].admin then
4002 return 1
4003 end
4004
4005 subthemeindex = 6
4006 optionsThemes()
4007end
4008function setSubtheme7(ob, pl)
4009
4010 if not Player[pl].admin then
4011 return 1
4012 end
4013
4014 subthemeindex = 7
4015 optionsThemes()
4016end
4017function setSubtheme8(ob, pl)
4018
4019 if not Player[pl].admin then
4020 return 1
4021 end
4022
4023 subthemeindex = 8
4024 optionsThemes()
4025end
4026function setSubtheme9(ob, pl)
4027
4028 if not Player[pl].admin then
4029 return 1
4030 end
4031
4032 subthemeindex = 9
4033 optionsThemes()
4034end
4035function setSubtheme10(ob, pl)
4036
4037 if not Player[pl].admin then
4038 return 1
4039 end
4040
4041 subthemeindex = 10
4042 optionsThemes()
4043end
4044function setSubtheme11(ob, pl)
4045
4046 if not Player[pl].admin then
4047 return 1
4048 end
4049
4050 subthemeindex = 11
4051 optionsThemes()
4052end
4053function setSubtheme12(ob, pl)
4054
4055 if not Player[pl].admin then
4056 return 1
4057 end
4058
4059 subthemeindex = 12
4060 optionsThemes()
4061end
4062
4063function overlay1 (ob, pl)
4064
4065 if not Player[pl].admin then
4066 return 1
4067 end
4068
4069 changeOverlay(themes[themeindex][subthemeindex][1].diffuse)
4070
4071end
4072function overlay2 (ob, pl)
4073
4074 if not Player[pl].admin then
4075 return 1
4076 end
4077
4078 changeOverlay(themes[themeindex][subthemeindex][2].diffuse)
4079
4080end
4081function overlay3 (ob, pl)
4082
4083 if not Player[pl].admin then
4084 return 1
4085 end
4086
4087 changeOverlay(themes[themeindex][subthemeindex][3].diffuse)
4088
4089end
4090function overlay4 (ob, pl)
4091
4092 if not Player[pl].admin then
4093 return 1
4094 end
4095
4096 changeOverlay(themes[themeindex][subthemeindex][4].diffuse)
4097
4098end
4099function overlay5 (ob, pl)
4100
4101 if not Player[pl].admin then
4102 return 1
4103 end
4104
4105 changeOverlay(themes[themeindex][subthemeindex][5].diffuse)
4106
4107end
4108function overlay6 (ob, pl)
4109
4110 if not Player[pl].admin then
4111 return 1
4112 end
4113
4114 changeOverlay(themes[themeindex][subthemeindex][6].diffuse)
4115
4116end
4117function overlay7 (ob, pl)
4118
4119 if not Player[pl].admin then
4120 return 1
4121 end
4122
4123 changeOverlay(themes[themeindex][subthemeindex][7].diffuse)
4124
4125end
4126function overlay8 (ob, pl)
4127
4128 if not Player[pl].admin then
4129 return 1
4130 end
4131
4132 changeOverlay(themes[themeindex][subthemeindex][8].diffuse)
4133
4134end
4135function overlay9 (ob, pl)
4136
4137 if not Player[pl].admin then
4138 return 1
4139 end
4140
4141 changeOverlay(themes[themeindex][subthemeindex][9].diffuse)
4142
4143end
4144function overlay10 (ob, pl)
4145
4146 if not Player[pl].admin then
4147 return 1
4148 end
4149
4150 changeOverlay(themes[themeindex][subthemeindex][10].diffuse)
4151
4152end
4153function overlay11 (ob, pl)
4154
4155 if not Player[pl].admin then
4156 return 1
4157 end
4158
4159 changeOverlay(themes[themeindex][subthemeindex][11].diffuse)
4160
4161end
4162function overlay12 (ob, pl)
4163
4164 if not Player[pl].admin then
4165 return 1
4166 end
4167
4168 changeOverlay(themes[themeindex][subthemeindex][12].diffuse)
4169
4170end
4171
4172function changeOverlay(diffuse)
4173
4174 local custom = overlay.getCustomObject()
4175 custom.diffuse = diffuse
4176
4177 overlay.setCustomObject(custom)
4178 overlay = overlay.reload()
4179 overlay.interactable = false
4180 overlay.setColorTint({1, 1, 1})
4181
4182end
4183
4184--[[ Destroy options panel --]]
4185function destroyOptionsPanel(ob, pl)
4186
4187 if pl and not Player[pl].admin then
4188 return 1
4189 end
4190
4191 optionspanel.clearButtons()
4192 optionspanel.destruct()
4193 optionspanel = nil
4194 if colorball ~= nil and colorball ~= null then
4195 colorball.destruct()
4196 end
4197end
4198
4199function toggleBlindsSkipAFK(ob, pl)
4200
4201 if not Player[pl].admin then
4202 return 1
4203 end
4204
4205 options.blindsskipafk = not options.blindsskipafk
4206
4207 optionsHost()
4208end
4209
4210function darkenOverlay(ob, pl)
4211
4212 if not Player[pl].admin then
4213 return 1
4214 end
4215
4216 local color = overlay.getColorTint()
4217 for i, v in pairs (color) do
4218 if v >= 0.05 then
4219 color[i] = v - 0.05
4220 else
4221 color[i] = 0
4222 end
4223 end
4224
4225 overlay.setColorTint(color)
4226end
4227
4228function lightenOverlay(ob, pl)
4229
4230 if not Player[pl].admin then
4231 return 1
4232 end
4233
4234 local color = overlay.getColorTint()
4235 for i, v in pairs (color) do
4236 if v <= 1.95 then
4237 color[i] = v + 0.05
4238 else
4239 color[i] = 2
4240 end
4241 end
4242
4243 overlay.setColorTint(color)
4244end
4245
4246function changeCollectMethod(ob, pl)
4247 if not Player[pl].admin then
4248 return 1
4249 end
4250
4251 if options.collectmethod == 'move' then
4252 options.collectmethod = 'convert'
4253 print('Collect method set to: Convert. Bets will now be converted up when collected. Bets will be convert with at least a height of ' .. options.convertstackheight)
4254 elseif options.collectmethod == 'convert' then
4255 options.collectmethod = 'hybrid'
4256 print('Collect method set to: Hybrid. Bets will be converted up once the pot is over $'..options.hybridthreshold..'.')
4257 elseif options.collectmethod == 'hybrid' then
4258 options.collectmethod = 'move'
4259 print('Collect method set to: Move. Bets will be moved into the pot.')
4260 else
4261 options.collectmethod = 'move'
4262 print('Unknown collect method found: Collect method set to: Move. Bets will be moved into the pot.')
4263 end
4264
4265 optionsHost()
4266end
4267
4268function checkAndRespawnObjects(ob, pl)
4269 if pl then
4270 if not Player[pl].admin then
4271 return 1
4272 end
4273 end
4274
4275 sidepotcalculated = false
4276
4277
4278 local meshes = {'http://pastebin.com/raw/133e1Z0L', 'http://pastebin.com/raw/U9rtcyua', 'http://pastebin.com/raw/uvvaV5Np', 'https://raw.githubusercontent.com/johnpenny/tts-poker-table-coverings/master/poker-table-boards.obj'}
4279 local diffuses = {'http://i.imgur.com/QinS8Hc.png', 'http://i.imgur.com/hIKi7Mq.png', 'http://i.imgur.com/novIseH.png', 'http://i.imgur.com/jPnTE9e.png'}
4280 local allobjects = getAllObjects()
4281 local objects = {'muck', 'boardobject', 'potobject', 'overlay'}
4282 local objectnames = {'Muck', 'Board', 'Pot', 'Overlay'}
4283 local objectexists = {false, false, false, false} -- muck, board, pot, overlay
4284 local positions = {{-9.175, 1.35, -1.9}, {0, 1.35, -2}, {0, 1.35, -7.5}, {0, 0.7, 0}}
4285 local custom = {}
4286 local params = {}
4287 local textparams = {}
4288 textparams.type = '3DText'
4289
4290 -- mark unlost objects as existing
4291 for i, v in ipairs (objects) do
4292 if Global.getVar(v) ~= nil and Global.getVar(v) ~= null then
4293 objectexists[i] = true
4294 --print (objectnames[i]..' exists.')
4295 end
4296 end
4297
4298 -- search for objects and reassign any that are found
4299 for i, v in ipairs (allobjects) do
4300 custom = v.getCustomObject()
4301 for j, w in ipairs (meshes) do
4302 if custom.mesh == w then
4303 if not objectexists[j] then
4304 Global.setVar(objects[j] , v)
4305 objectexists[j] = true
4306 print(objectnames[j]..' reassigned.')
4307 end
4308 end
4309 end
4310 end
4311
4312 -- respawn nonexistent objects
4313 for i, v in ipairs (objectexists) do
4314 if not v then
4315 params.type = 'Custom_Model'
4316 params.position = positions[i]
4317 params.rotation = {0, 0, 0}
4318
4319 custom.mesh = meshes[i]
4320 custom.diffuse = diffuses[i]
4321 custom.type = 4
4322
4323 local o = spawnObject(params)
4324 o.setCustomObject(custom)
4325
4326 if i ~= 4 then
4327 o.setLuaScript(scripts[i])
4328 else
4329 o.lock()
4330 o.interactable = false
4331 o.setName('Table Overlay')
4332 end
4333
4334 Global.setVar(objects[i], o)
4335
4336 print (objectnames[i]..' respawned.')
4337 end
4338 end
4339 local actionscript = "blubb"
4340
4341 --[[ Check and respawn texts --]]
4342 if actiontext == nil or actiontext == null then
4343 textparams.position = {0, 0, 0}
4344 textparams.rotation = {0, 0, 0}
4345 actiontext = spawnObject(textparams)
4346 actiontext.TextTool.setValue('Action')
4347 actiontext.TextTool.setFontSize(68)
4348 actiontext.setLuaScript(scripts[4])
4349 end
4350 --[[if pottext == nil or pottext == null then
4351 textparams.position = {0, 1.33, 0}
4352 textparams.callback = 'spawnTextCallback'
4353 pottext = spawnObject(textparams)
4354 pottext.TextTool.setFontSize(64)
4355 end--]]
4356 --[[if currentbettext == nil or currentbettext == null then
4357 textparams.position = {0, 1.33, 1}
4358 textparams.callback = 'spawnTextCallback'
4359 currentbettext = spawnObject(textparams)
4360 currentbettext.TextTool.setFontSize(64)
4361 end--]]
4362 for i, v in ipairs(colors) do
4363 if bettext[v] == nil or bettext[v] == null then
4364 local playerhand = Player[v].getHandTransform(1)
4365 textparams.position = {playerhand.position.x + playerhand.forward.x * 10 + playerhand.right.x * 4, 1.4, playerhand.position.z + playerhand.forward.z * 10 + playerhand.right.z * 4}
4366 textparams.callback = 'spawnTextCallback'
4367 bettext[v] = spawnObject(textparams)
4368 bettext[v].TextTool.setFontSize(64)
4369 bettext[v].TextTool.setFontColor(fontcolors[v])
4370 end
4371 if sidepottext[v] == nil or sidepottext[v] == null then
4372
4373 local playerhand = Player[v].getHandTransform(1)
4374 textparams.position = {playerhand.position.x + playerhand.forward.x * 10.8, 1.33, playerhand.position.z + playerhand.forward.z * 10.8}
4375 textparams.callback = 'spawnTextCallback'
4376 sidepottext[v] = spawnObject(textparams)
4377 sidepottext[v].TextTool.setFontSize(64)
4378 sidepottext[v].TextTool.setFontColor(fontcolors[v])
4379 sidepottext[v].setValue("spawned")
4380 end
4381 --[[if tablezonetext[v] == nil or tablezonetext[v] == null then
4382 local chips = {}
4383 local playerhand = Player[v].getHandTransform(1)
4384 textparams.position = {playerhand.position.x + playerhand.forward.x * -2.5 + playerhand.right.x * 4, 1.4, playerhand.position.z + playerhand.forward.z * -2.5 + playerhand.right.z * 4}
4385 textparams.callback = 'spawnTextCallback'
4386 tablezonetext[v] = spawnObject(textparams)
4387 tablezonetext[v].TextTool.setFontSize(64)
4388 tablezonetext[v].TextTool.setFontColor({1,1,1}) -- Black
4389
4390 if options.displayplayermoney then
4391 money = getChipValues(tablezones[v],chips)
4392 tablezonetext[v].setValue("$" .. money)
4393 else
4394 tablezonetext[v].setValue(" ")
4395 end
4396
4397 end--]]
4398
4399 end
4400
4401end
4402
4403function spawnTextCallback()
4404 check = true
4405 --[[if not (pottext == nil or pottext == null) then
4406 pottext.setRotation({90, 180, 0})
4407 else
4408 check = false
4409end--]]
4410 --[[if not (currentbettext == nil or currentbettext == null) then
4411 currentbettext.setRotation({90, 180, 0})
4412 else
4413 check = false
4414end--]]
4415 for i, v in ipairs(colors) do
4416 local playerhand = getPlayerHandPositionAndRotation(v)
4417 if not (bettext[v] == nil or bettext[v] == null) then
4418 bettext[v].setRotation({90, playerhand['rot_y'], 0})
4419 else
4420 check = false
4421 end
4422 if not (sidepottext[v] == nil or sidepottext[v] == null or type(sidepottext[v]) == "string") then
4423 sidepottext[v].setRotation({90, playerhand['rot_y'], 0})
4424 else
4425 check = false
4426 end
4427 --[[if not (tablezonetext[v] == nil or tablezonetext[v] == null) then
4428 tablezonetext[v].setRotation({90, playerhand['rot_y'], 0})
4429 else
4430 check = false
4431 end--]]
4432 end
4433 if check then
4434 calculatePots()
4435 end
4436end
4437
4438function togglePlayerClickAction(ob, pl)
4439 if not Player[pl].admin then
4440 return 1
4441 end
4442
4443 if options.playerclickaction then
4444 options.playerclickaction = false
4445 print ('The Action button will now remain in a static position for the host to click.')
4446
4447 local buttons = actionbutton.getButtons()
4448
4449 buttons[1].label = 'Action'
4450
4451 actionbutton.editButton(buttons[1])
4452 else
4453 options.playerclickaction = true
4454 print ('The action button will now be moved in front of the player whose turn it is to act.')
4455
4456 local buttons = actionbutton.getButtons()
4457
4458 buttons[1].label = 'Done'
4459
4460 actionbutton.editButton(buttons[1])
4461 end
4462
4463 optionsHost()
4464end
4465
4466function toggleEnforcePotLimit(ob, pl)
4467 if not Player[pl].admin then
4468 return 1
4469 end
4470
4471 options.enforcepotlimit = not options.enforcepotlimit
4472
4473 optionsHost()
4474end
4475
4476function toggleEnforceFoldInTurn(ob, pl)
4477 if not Player[pl].admin then
4478 return 1
4479 end
4480
4481 options.enforcefoldinturn = not options.enforcefoldinturn
4482
4483 optionsHost()
4484end
4485
4486function toggleEnforceDoubleRaise(ob, pl)
4487 if not Player[pl].admin then
4488 return 1
4489 end
4490
4491 options.enforcedoubleraise = not options.enforcedoubleraise
4492
4493 optionsHost()
4494end
4495
4496function toggleActionMessage(ob, pl)
4497 if not Player[pl].admin then
4498 return 1
4499 end
4500
4501 options.chatoptions.actionmessage = not options.chatoptions.actionmessage
4502
4503 optionsChat()
4504end
4505
4506function toggleActionBroadcast(ob, pl)
4507 if not Player[pl].admin then
4508 return 1
4509 end
4510
4511 options.chatoptions.actionbroadcast = not options.chatoptions.actionbroadcast
4512
4513 optionsChat()
4514end
4515
4516function toggleStageBroadcast(ob, pl)
4517 if not Player[pl].admin then
4518 return 1
4519 end
4520
4521 options.chatoptions.stage = not options.chatoptions.stage
4522
4523 optionsChat()
4524end
4525
4526function toggleCurrentBetMessage(ob, pl)
4527 if not Player[pl].admin then
4528 return 1
4529 end
4530
4531 options.chatoptions.currentbetmessage = not options.chatoptions.currentbetmessage
4532
4533 optionsChat()
4534end
4535
4536function toggleBetter(ob, pl)
4537 if not Player[pl].admin then
4538 return 1
4539 end
4540
4541 options.chatoptions.better = not options.chatoptions.better
4542
4543 optionsChat()
4544end
4545
4546function toggleAllinBroadcast(ob, pl)
4547 if not Player[pl].admin then
4548 return 1
4549 end
4550
4551 options.chatoptions.allinbroadcast = not options.chatoptions.allinbroadcast
4552
4553 optionsChat()
4554end
4555
4556function togglePotMessage(ob, pl)
4557 if not Player[pl].admin then
4558 return 1
4559 end
4560
4561 if options.chatoptions.potmessage >= 2 then
4562 options.chatoptions.potmessage = 0
4563 else
4564 options.chatoptions.potmessage = options.chatoptions.potmessage + 1
4565 end
4566
4567 optionsChat()
4568end
4569
4570function printMessages()
4571
4572 local p = ''
4573
4574 for i, v in ipairs(colors) do
4575 if string.find(printstring, v) then
4576 p = v
4577 break
4578 end
4579 end
4580
4581 if string.find(printstring, 'bet') or string.find(printstring, 'raise') then
4582 if options.chatoptions.currentbetmessage then
4583 local s = 'Current bet: $'..currentbet
4584 if options.chatoptions.better then
4585 if string.find(printstring, 'bet') then
4586 if Player[p].steam_name then
4587 s = s..', made by '..fontcolors[p].bbcode..Player[p].steam_name..'[ffffff].'
4588 else
4589 s = s..', made by '..fontcolors[p].bbcode..p..'[ffffff].'
4590 end
4591 else
4592 if Player[p].steam_name then
4593 s = s..', raised by '..fontcolors[p].bbcode..Player[p].steam_name..'[ffffff].'
4594 else
4595 s = s..', raised by '..fontcolors[p].bbcode..p..'[ffffff].'
4596 end
4597 end
4598 else
4599 s = s..'.'
4600 end
4601
4602 printToAll(s, {1, 1, 1})
4603 end
4604 end
4605
4606
4607 if options.chatoptions.allinbroadcast and string.find(printstring, 'allin') then
4608 if string.find(printstring, p) then
4609 if Player[p].steam_name then
4610 broadcastToAll (fontcolors[p].bbcode..Player[p].steam_name..'[ffffff] is all in!', {1, 1, 1})
4611 else
4612 broadcastToAll (fontcolors[p].bbcode..p..'[ffffff] is all in!.', {1, 1, 1})
4613 end
4614 end
4615 end
4616
4617 if string.find(printstring, 'action') and actionon then
4618
4619 if options.chatoptions.actionmessage then
4620 if Player[actionon].steam_name then
4621 printToAll ("Action on "..fontcolors[actionon].bbcode..Player[actionon].steam_name..'[ffffff].', {1, 1, 1})
4622 else
4623 printToAll ("Action on "..fontcolors[actionon].bbcode..actionon..'[ffffff].', {1, 1, 1})
4624 end
4625 end
4626
4627 if options.chatoptions.actionbroadcast and Player[actionon].seated then
4628 broadcastToColor("Action on you!", actionon, {1, 0, 0})
4629 end
4630 end
4631
4632 if options.chatoptions.potmessage > 0 then
4633 if (options.chatoptions.potmessage >= 1 and string.find(printstring, 'collect')) or (options.chatoptions.potmessage > 1 and string.find(printstring, 'pot')) then
4634 printToAll('Pot: $'..pot..'.', {1, 1, 1})
4635 end
4636 end
4637
4638 printstring = ''
4639end
4640
4641function onObjectDropped(player, object)
4642 if handinprogress and object.tag == 'Card' then
4643
4644 if handsshown[player] then return 0 end -- if the player already revealed their hand, then abort function. this is to prevent players from spamming chat by repeatedly picking up and dropping their cards
4645 for i, v in ipairs (colors) do
4646 for j, w in ipairs (Player[v].getHandObjects()) do
4647 if w == object then return 0 end -- they dropped it into their hand, so abort function
4648 end
4649 end
4650 local r = object.getRotation()
4651 if (r.x < 80 or r.x > 280) and (r.z < 80 or r.z > 280) then -- it's face-up
4652 for i, v in ipairs (holecards[player]) do
4653 if v == object.getGUID() then
4654 table.insert(revealedcards[player], table.remove(holecards[player], i))
4655 break
4656 end
4657 end
4658 if #holecards[player] == 0 then
4659 handsshown[player] = true
4660 --evaluateHand(player)
4661 end
4662 end
4663 end
4664
4665 if isCurrency(object) then
4666 for i, v in ipairs (colors) do
4667 local chips = {}
4668 local value = "$" .. getChipValues(tablezones[v],chips)
4669
4670
4671 if options.displayplayermoney then
4672 --tablezonetext[v].setValue(value)
4673 end
4674 for j, w in ipairs (chips) do
4675 if w == object then
4676 object.setColorTint(chiptints[v])
4677 return 1
4678 end
4679 end
4680 for j, w in ipairs (backtablezones[v].getObjects()) do
4681 if w == object then
4682 object.setColorTint(chiptints[v])
4683 return 1
4684 end
4685 end
4686 for j, w in ipairs (betzones[v].getObjects()) do
4687 if w == object then
4688 object.setColorTint(chiptints[v])
4689 return 1
4690 end
4691 end
4692 end
4693 object.setColorTint({1, 1, 1})
4694 end
4695end
4696
4697function onObjectSpawn(object)
4698 if isCurrency(object) then
4699 for i, v in ipairs (colors) do
4700 for j, w in ipairs (tablezones[v].getObjects()) do
4701 if w == object then
4702 object.setColorTint(chiptints[v])
4703 return 1
4704 end
4705 end
4706 for j, w in ipairs (backtablezones[v].getObjects()) do
4707 if w == object then
4708 object.setColorTint(chiptints[v])
4709 return 1
4710 end
4711 end
4712 for j, w in ipairs (betzones[v].getObjects()) do
4713 if w == object then
4714 object.setColorTint(chiptints[v])
4715 return 1
4716 end
4717 end
4718 end
4719 object.setColorTint({1, 1, 1})
4720 end
4721end
4722
4723function isCurrency(object)
4724 if object.tag == 'Chip' then
4725 if object.getValue() then
4726 return true
4727 elseif tonumber(object.getName()) ~= nil then
4728 if tonumber(object.getName()) > 0 then
4729 return true
4730 end
4731 else
4732 return false
4733 end
4734 end
4735end
4736function getPlayersHoleCards()
4737 for i, v in ipairs (players) do
4738 for j, w in ipairs (Player[v].getHandObjects()) do
4739 table.insert(holecards[v], w.getGUID())
4740 end
4741 end
4742end
4743
4744function evaluateHand(player)
4745
4746 if options.gamemode == 'omaha' then return 0 end -- doesn't work for omaha since it doesn't consider which cards are in the player's hand and which are on the board.
4747
4748 local sevencards = getSevenCards(player)
4749
4750 if not sevencards then return 0 end
4751
4752 local cards = {['Spades'] = {}, ['Hearts'] = {}, ['Clubs'] = {}, ['Diamonds'] = {}}
4753 local suits = {'Spades', 'Hearts', 'Clubs', 'Diamonds'}
4754 local ranks = {'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Jack', 'Queen', 'King','Ace'}
4755 local handranks = {'Royal Flush', 'Straight Flush', 'Four of a Kind', 'Full House', 'Flush', 'Straight', 'Three of a Kind', 'Two Pairs', 'One Pair', 'High Card'}
4756
4757 -- Populate cards table
4758 for i, v in ipairs (sevencards) do
4759 for j, w in ipairs (ranks) do
4760 if getConvertedName(v.getName()) == w then
4761 table.insert(cards[v.getDescription()], nameToValue(w))
4762 break
4763 end
4764 end
4765 end
4766
4767 -- Sort tables
4768 for i, v in ipairs (suits) do
4769 table.sort(cards[v])
4770 end
4771
4772 -- Check for each type of hand until a hand is found
4773
4774 -- Royal flush
4775
4776 local flushexists = false
4777 local flushsuit = ''
4778
4779 for i, v in ipairs (suits) do
4780 if #cards[v] >= 5 then -- a flush exists at least
4781 flushexists = true
4782 flushsuit = v
4783 local value = 0
4784 for j = 1, 5 do
4785 value = value + cards[v][#cards[v] - (j-1)]
4786 end
4787 if value == 60 then -- it's a royal flush!
4788 broadcastToAll(player..' shows a '..flushsuit..' Royal Flush!', {0, 1, 0})
4789 return 0
4790 end
4791 end
4792 end
4793
4794 -- Straight Flush
4795
4796 if flushexists then
4797 local consecutives = 0
4798 local highcard = 0
4799 local lowconsecutives = false
4800 local ace = false
4801 for i, v in ipairs (cards[flushsuit]) do
4802 if i == 1 then
4803 consecutives = 1
4804 else
4805 if v == (cards[flushsuit][i - 1] + 1) then
4806 consecutives = consecutives + 1
4807 if consecutives >= 5 then
4808 highcard = v
4809 elseif consecutives == 4 and v == 5 then
4810 lowconsecutives = true
4811 end
4812 else
4813 consecutives = 1
4814 end
4815 if v == 14 then
4816 ace = true
4817 end
4818 end
4819 end
4820
4821 -- check for straight flush to the 5
4822 if highcard == 0 and ace and lowconsecutives then highcard = 5 end
4823
4824 if highcard > 0 then
4825 broadcastToAll (fontcolors[player].bbcode..player..' shows a '..flushsuit..' Straight Flush to the '..valueToName(highcard), {1, 1, 1})
4826 return 0
4827 end
4828 end
4829
4830 -- Create list of all cards based on rank to use in finding pairs, etc.
4831
4832 local cards2 = {}
4833
4834 for i, v in ipairs (suits) do
4835 for j, w in ipairs (cards[v]) do
4836 table.insert(cards2, w)
4837 end
4838 end
4839
4840 table.sort(cards2)
4841
4842 local quantities = {}
4843
4844 for i, v in ipairs (cards2) do
4845 if not quantities[valueToName(v)] then
4846 quantities[valueToName(v)] = 1
4847 else
4848 quantities[valueToName(v)] = quantities[valueToName(v)] + 1
4849 end
4850 end
4851
4852 local quads = {}
4853 local trips = {}
4854 local pairs = {}
4855 local singles = {}
4856 for i, v in ipairs (ranks) do
4857 if quantities[v] == 4 then table.insert(quads, v) end
4858 if quantities[v] == 3 then table.insert(trips, v) end
4859 if quantities[v] == 2 then table.insert(pairs, v) end
4860 if quantities[v] == 1 then table.insert(singles, v) end
4861 end
4862
4863 -- Check for quads
4864 if #quads > 0 then
4865 broadcastToAll(fontcolors[player].bbcode..player..' shows Four of a Kind: '..quads[#quads]..'s!', {1, 1, 1})
4866 return 0
4867 end
4868
4869 -- Check for full house
4870 if #trips > 0 and #trips + #pairs >= 2 then
4871 if #pairs > 0 then
4872 printToAll (fontcolors[player].bbcode..player..' shows a Full House: '..trips[#trips]..'s full of '..pairs[#pairs]..'s!', {1, 1, 1})
4873 else
4874 printToAll (fontcolors[player].bbcode..player..' shows a Full House: '..trips[#trips]..'s full of '..trips[#trips-1]..'s!', {1, 1, 1})
4875 end
4876 return 0
4877 end
4878
4879 -- Flush
4880 if flushexists then
4881 printToAll (fontcolors[player].bbcode..player..' shows a '..flushsuit..' Flush, '..valueToName(cards[flushsuit][#cards[flushsuit]])..' high!', {1, 1, 1})
4882 return 0
4883 end
4884
4885 -- Check for Straight
4886 local consecutives = 0
4887 local highcard = 0
4888 local lowconsecutives = false
4889 local ace = false
4890 for i, v in ipairs (cards2) do
4891 if i == 1 then
4892 consecutives = 1
4893 else
4894 if v == (cards2[i-1] + 1) then
4895 consecutives = consecutives + 1
4896 if consecutives >= 5 then
4897 highcard = v
4898 elseif consecutives == 4 and v == 5 then
4899 lowconsecutives = true
4900 end
4901 elseif v ~= cards2[i-1] then
4902 consecutives = 1
4903 end
4904 if v == 14 then
4905 ace = true
4906 end
4907 end
4908 end
4909
4910 -- check for straight flush to the 5
4911 if highcard == 0 and ace and lowconsecutives then highcard = 5 end
4912
4913 if highcard > 0 then
4914 printToAll (fontcolors[player].bbcode..player..' shows a Straight to the '..valueToName(highcard)..'!', {1, 1, 1})
4915 return 0
4916 end
4917
4918 -- Check for trips
4919 if #trips > 0 then
4920 printToAll (fontcolors[player].bbcode..player..' shows Three of a Kind: '..trips[#trips]..'s.', {1, 1, 1})
4921 return 0
4922 end
4923
4924 -- Check for two pair
4925 if #pairs >= 2 then
4926 printToAll (fontcolors[player].bbcode..player..' shows Two Pair: '..pairs[#pairs]..'s and '..pairs[#pairs-1]..'s.', {1, 1, 1})
4927 return 0
4928 end
4929
4930 -- Check for one pair
4931 if #pairs == 1 then
4932 printToAll (fontcolors[player].bbcode..player..' shows One Pair: '..pairs[#pairs]..'s.', {1, 1, 1})
4933 return 0
4934 end
4935
4936 -- High card
4937 printToAll (fontcolors[player].bbcode..player..' shows '..singles[#singles]..' High.', {1, 1, 1})
4938
4939end
4940
4941function getSevenCards(player)
4942 local sevencards = {}
4943
4944 for i, v in ipairs (boardzone.getObjects()) do
4945 if v.tag == 'Card' then
4946 if v.getName() == '' or v.getDescription() == '' then return nil end
4947 sevencards[#sevencards + 1] = v
4948 end
4949 end
4950 for i, v in ipairs (revealedcards[player]) do
4951 local card = getObjectFromGUID(v)
4952 if card.tag == 'Card' then
4953 if card.getName() == '' or card.getDescription() == '' then return nil end
4954 sevencards[#sevencards + 1] = card
4955 end
4956 end
4957
4958 return sevencards
4959end
4960
4961function getConvertedName(name)
4962 if name == '2' then return 'Two' end
4963 if name == '3' then return 'Three' end
4964 if name == '4' then return 'Four' end
4965 if name == '5' then return 'Five' end
4966 if name == '6' then return 'Six' end
4967 if name == '7' then return 'Seven' end
4968 if name == '8' then return 'Eight' end
4969 if name == '9' then return 'Nine' end
4970 if name == '10' then return 'Ten' end
4971 return name
4972end
4973
4974function nameToValue(name)
4975 if name == 'Two' then return 2 end
4976 if name == 'Three' then return 3 end
4977 if name == 'Four' then return 4 end
4978 if name == 'Five' then return 5 end
4979 if name == 'Six' then return 6 end
4980 if name == 'Seven' then return 7 end
4981 if name == 'Eight' then return 8 end
4982 if name == 'Nine' then return 9 end
4983 if name == 'Ten' then return 10 end
4984 if name == 'Jack' then return 11 end
4985 if name == 'Queen' then return 12 end
4986 if name == 'King' then return 13 end
4987 if name == 'Ace' then return 14 end
4988end
4989
4990function valueToName(value)
4991 if value == 2 then return 'Two' end
4992 if value == 3 then return 'Three' end
4993 if value == 4 then return 'Four' end
4994 if value == 5 then return 'Five' end
4995 if value == 6 then return 'Six' end
4996 if value == 7 then return 'Seven' end
4997 if value == 8 then return 'Eight' end
4998 if value == 9 then return 'Nine' end
4999 if value == 10 then return 'Ten' end
5000 if value == 11 then return 'Jack' end
5001 if value == 12 then return 'Queen' end
5002 if value == 13 then return 'King' end
5003 if value == 14 then return 'Ace' end
5004end
5005
5006function onObjectPickedUp(player, object)
5007
5008 if Player[player].admin then return 0 end
5009
5010 local r = object.getPosition()
5011 local description = ''
5012
5013 if object.getName() ~= '' then
5014 description = object.getName()
5015 elseif object.getValue() then
5016 description = object.getValue()
5017 else
5018 description = object.tag
5019 end
5020
5021 --[[ Check if the object is inside the dealer's area --]]
5022 if r.x < 8.5 and r.x > -8.5 and r.z < -16.5 and r.z > -52 then
5023 object.translate({0, 1, 0})
5024 print (player..' has attempted to pick up an object ('..description..') in the dealer\'s area.')
5025 return 0
5026 end
5027
5028 --[[ Check if the object is on another player's table or bet zone, and not in player's own table or betzone --]]
5029
5030 --[[if not objectExistsInList(tablezones[player].getObjects(), object) and not objectExistsInList(betzones[player].getObjects(), object) then
5031 for i, v in ipairs (colors) do
5032 if v ~= player then
5033 if objectExistsInList(tablezones[v].getObjects(), object) or objectExistsInList(betzones[v].getObjects(), object) or objectExistsInList(backtablezones[v].getObjects(), object) then
5034 object.translate({0, 1, 0})
5035 print (player..' has attempted to pick up an object ('..description..') on player '..v..'\'s table or bet square.')
5036 return 0
5037 end
5038 end
5039 end
5040 end--]]
5041
5042 --[[ If the object is a card and not in the player's own hand, then drop it. Only works with named cards. --]]
5043
5044 local ranks = {['Ace'] = true, ['Two'] = true, ['Three'] = true, ['Four'] = true, ['Five'] = true, ['Six'] = true, ['Seven'] = true, ['Eight'] = true, ['Nine'] = true, ['Ten'] = true, ['Jack'] = true, ['Queen'] = true, ['King'] = true}
5045 --[[if object.tag == 'Card' and ranks[getConvertedName(object.getName())] then
5046 for i, v in ipairs (Player[player].getHandObjects()) do
5047 if object == v then return 0 end
5048 end
5049 for i, v in ipairs (holecards[player]) do
5050 if object.getGUID() == v then return 0 end
5051 end
5052 for i, v in ipairs (revealedcards[player]) do
5053 if object.getGUID() == v then return 0 end
5054 end
5055 object.translate({0, 1, 0})
5056 print (player..' has attempted to pick up a card that does not belong to them.')
5057 end--]]
5058end
5059
5060function initializePot()
5061 local p = {}
5062 p = stacklayout[options.stacklayout]
5063
5064 -- reset height
5065 for i, v in pairs (p) do
5066 v.height = 0
5067 v.x = 0
5068 v.y = 0
5069 v.z = 0
5070 end
5071 return p
5072end
5073
5074function createSidepot(ob, pl)
5075 createSidepotPl = pl
5076 createSidepotOb = ob
5077 startLuaCoroutine(nil, "coCreateSidepot")
5078end
5079
5080function coCreateSidepot()
5081
5082 pl = createSidepotPl
5083 ob = createSidepotOb
5084
5085 if sidepotfailcount > sidepotfailcountlimit then
5086 convertfailcount = 0
5087 print("Error in Sidepotcreations, chips were moved");
5088 return 1
5089 end
5090
5091 if pl then
5092 if not Player[pl].admin then
5093 return 1
5094 end
5095 end
5096 -- cant build sidepots twice
5097 if sidepotcalculated then
5098 return 1
5099 end
5100
5101 local chips1 = {}
5102 local positions1 = {}
5103 local rotations1 = {}
5104 for i, v in pairs (betzones) do
5105 objects = {}
5106 objects = v.getObjects()
5107 for j, w in ipairs (objects) do
5108 if w.tag == 'Chip' then
5109 if w.getValue() or tonumber(w.getName()) != nil then
5110 chips1[#chips1 + 1] = w
5111 end
5112 end
5113 end
5114 end
5115 for i, v in ipairs (chips1) do
5116 positions1[#positions1 + 1] = v.getPosition()
5117 rotations1[#rotations1 + 1] = v.getRotation()
5118 end
5119 for i = 1, 2 do
5120 coroutine.yield(0)
5121 end
5122 local chips2 = {}
5123 local playerbets = {}
5124 local positions2 = {}
5125 local rotations2 = {}
5126 for i, v in ipairs (colors) do
5127 playerbets[i] = { getChipValues(betzones[v], chips2), betzones[v], v, 0}
5128 end
5129 for i, v in ipairs (chips2) do
5130 positions2[#positions2 + 1] = v.getPosition()
5131 rotations2[#rotations2 + 1] = v.getRotation()
5132 end
5133 --[[ Check chip positions --]]
5134 for i, v in ipairs(positions1) do
5135 if v.x ~= positions2[i].x or v.y ~= positions2[i].y or v.z ~= positions2[i].z then
5136 sidepotfailcount = sidepotfailcount + 1
5137 --startLuaCoroutine(nil, 'convertBetsToPot')
5138 print("error in convert")
5139
5140 return 1
5141 end
5142 end
5143 table.sort(playerbets,compare)
5144 for i, v in ipairs (playerbets) do
5145 if i == #playerbets then
5146 v[4] = v[1] * i
5147 else
5148 v[4] = ( v[1]-playerbets[i+1][1]) * i
5149 end
5150 end
5151 for i, v in ipairs (chips2) do
5152 v.destruct()
5153 end
5154
5155 if clock ~= nil then
5156 clock.destruct()
5157 end
5158
5159 local spawnedcolors = {}
5160 local params = {}
5161 params.type = "backgammon_piece_white"
5162 params.position = {5, 2, 1}
5163 params.rotation = {0, 180, 0}
5164 params.scale = {0.4, 0.2, 0.4}
5165
5166 for i, v in ipairs (playerbets) do
5167 if v[1] > 0 then
5168 bettext[v[3]].setValue("Bet: $" .. tostring(v[1]))
5169 sidepottext[v[3]].setValue("Sidepot: $" .. tostring(v[4]))
5170 local p = {}
5171 local r = {}
5172 p = v[2].getPosition()
5173 r = v[2].getRotation()
5174 r.y = (r.y + 180) % 360
5175 spawnChips(v[4], p, r)
5176 local zoffset = -3
5177 local xoffset = -3
5178 p.x = p.x + (math.cos(math.rad(r.y)) * xoffset) + (math.sin(math.rad(r.y)) * zoffset)
5179 p.z = p.z - (math.sin(math.rad(r.y)) * xoffset) + (math.cos(math.rad(r.y)) * zoffset)
5180 local zoffset = 0
5181 local xoffset = 0.5
5182 spawnedcolors[#spawnedcolors + 1] = v[3]
5183 for k, w in ipairs(spawnedcolors) do
5184
5185 p.x = p.x + (math.cos(math.rad(r.y)) * xoffset) + (math.sin(math.rad(r.y)) * zoffset)
5186 p.z = p.z - (math.sin(math.rad(r.y)) * xoffset) + (math.cos(math.rad(r.y)) * zoffset)
5187 params.position = p
5188 ob = spawnObject(params)
5189 ob.setColorTint(fontcolors[w])
5190 ob.setName("Sidepotmarker")
5191 end
5192
5193 end
5194 end
5195
5196
5197
5198
5199
5200
5201 for j, v in ipairs (playerbets) do
5202
5203
5204 end
5205 sidepotcalculated = true
5206 return 1
5207end
5208
5209
5210-- chips should correspond to the chipstable, position, rotation is where the chips should move to
5211function moveChips(chips, p, r)
5212 local chipstack = initializePot()
5213 local h = {}
5214 local chips2 = {}
5215 for i, v in pairs (chipstack) do
5216 chips2[i] = {}
5217 h[i] = {}
5218 end
5219 for i, v in pairs(chipstack) do
5220 v.x = p.x + (math.cos(math.rad(r.y)) * v.xoffset) + (math.sin(math.rad(r.y)) * v.zoffset)
5221 v.z = p.z - (math.sin(math.rad(r.y)) * v.xoffset) + (math.cos(math.rad(r.y)) * v.zoffset)
5222 v.y = p.y + v.yoffset + v.height
5223 end
5224
5225 -- move also chips within the potzone
5226 for j, w in ipairs (chips) do
5227 if w.tag == "Chip" and not w.held_by_color then
5228 local hit = false
5229 for k, x in pairs (currencies) do
5230 local stack
5231 if h[x.stack] == nil then
5232 stack = "misc"
5233 else
5234 stack = x.stack
5235 end
5236 if w.getValue() == x.value or w.getName() == x.name then
5237 hit = true
5238 chips2[stack][#chips2[stack] + 1] = w
5239 if w.getQuantity() > 0 then
5240 h[stack][#h[stack] + 1] = w.getQuantity() * x.height
5241 else
5242 h[stack][#h[stack] + 1] = x.height
5243 end
5244 break -- next object
5245 end
5246 end
5247 -- unknown chips
5248 if not hit then
5249
5250 local x = currencies[#currencies] -- should be dummy value
5251 local stack = "misc"
5252 chips2[stack][#chips2[stack] + 1] = w
5253 if w.getQuantity() > 0 then
5254 h[stack][#h[stack] + 1] = w.getQuantity() * x.height
5255 else
5256 h[stack][#h[stack] + 1] = x.height
5257 end
5258 end
5259 end
5260 end
5261
5262 for i, v in pairs (chips2) do
5263 for j, w in ipairs (v) do
5264
5265 local rot = {0,0,0}
5266 for k, x in pairs (currencies) do
5267 if (w.getValue() == x.value) or (w.getName() == x.name) then
5268 rot.x = (r.x + x.params.rotation[1]) % 360
5269 rot.y = (r.y + x.params.rotation[2]) % 360
5270 rot.z = (r.z + x.params.rotation[3]) % 360
5271 rot[1] = rot.x
5272 rot[2] = rot.y
5273 rot[3] = rot.z
5274 end
5275 end
5276 w.setRotation(rot)
5277 w.setPosition(chipstack[i])
5278 w.translate({0, 0.1, 0})
5279 chipstack[i].y = chipstack[i].y + h[i][j]
5280 chipstack[i].height = chipstack[i].height + h[i][j]
5281 end
5282 end
5283
5284
5285 return 1
5286end
5287
5288-- spawnChips(money, position, rotation)
5289function spawnChips(money, p, r, minheight)
5290 if minheight == nil or minheight==null then
5291 minheight = 0
5292 end
5293 money = money + 0.001 -- prevents rounding error
5294 money = comma_value(money) + 0
5295
5296 local chipstack = {}
5297
5298 local params = {}
5299 local custom = {}
5300
5301 -- prevent spawning to much Chips
5302 if money > currencies[1].value * 50 then
5303
5304
5305 money = math.floor(money)
5306 params.position = p
5307 params.rotation = r
5308 params.scale = {1.12,1.12,1.12}
5309 params.params = {"$" .. string.format("%.0f", money) }
5310 params.type = 'Custom_Model'
5311 params.callback = 'apllyName'
5312 custom.mesh = "http://cloud-3.steamusercontent.com/ugc/841461304086373873/9925B4E8ECFC5BBB13AB9FD1BB93E768C2DD3151/"
5313 custom.diffuse = "http://cloud-3.steamusercontent.com/ugc/841461304094020976/22277301EF8ACDDD4649BD6F382CF950967A8D50/"
5314
5315 custom.type = 5
5316 custom.material = 1
5317
5318 local obj = spawnObject(params)
5319 obj.setCustomObject(custom)
5320 obj.setName("$" .. comma_value(money) )
5321 printToAll('Conversion Limit reached, alternate Bar with the money value spawned', {1, 1, 0})
5322 return
5323 end
5324
5325
5326
5327 chipstack = initializePot()
5328
5329 for i, v in pairs(chipstack) do
5330 v.x = p.x + (math.cos(math.rad(r.y)) * v.xoffset) + (math.sin(math.rad(r.y)) * v.zoffset)
5331 v.z = p.z - (math.sin(math.rad(r.y)) * v.xoffset) + (math.cos(math.rad(r.y)) * v.zoffset)
5332 v.y = p.y + v.yoffset + v.height
5333 end
5334
5335 params.rotation = r
5336 params.callback_owner = Global
5337
5338 local i = #currencies
5339 while i>0 do
5340
5341
5342 v = currencies[i]
5343 if not (v.value == -1) then
5344 params.rotation = v.params.rotation
5345 params.scale = v.params.scale
5346 params.params = {v.name}
5347 local rot = {}
5348 rot.x = (r.x + v.params.rotation[1]) % 360
5349 rot.y = (r.y + v.params.rotation[2]) % 360
5350 rot.z = (r.z + v.params.rotation[3]) % 360
5351 rot[1] = rot.x
5352 rot[2] = rot.y
5353 rot[3] = rot.z
5354 params.rotation = rot
5355 local stack
5356 if chipstack[v.stack] == nil then
5357 stack = "misc"
5358 else
5359 stack = v.stack
5360 end
5361 if not v.standard then
5362
5363 params.type = 'Custom_Model'
5364 params.callback_owner = Global
5365 custom.mesh = v.custom.mesh
5366 custom.diffuse = v.custom.diffuse
5367 custom.type = 5
5368 custom.material = 1
5369
5370
5371 local j=0
5372 while (j<minheight) and (money >= v.value) do
5373 params.position = {}
5374 params.position.x = chipstack[stack].x
5375 params.position.y = chipstack[stack].y + chipstack[stack].height
5376 params.position.z = chipstack[stack].z
5377 local obj = spawnObject(params)
5378 obj.setCustomObject(custom)
5379 obj.setName('test')
5380 money = money - v.value
5381 chipstack[stack].height = chipstack[stack].height + v.height
5382 j=j+1
5383 end
5384 else
5385 params.type = 'Chip_'.. v.value
5386 params.callback = nil
5387 params.callback_owner = Global
5388 params.params = nil
5389 local j=0
5390 while (j<minheight) and (money >= v.value) do
5391 params.position = {}
5392 params.position.x = chipstack[stack].x
5393 params.position.y = chipstack[stack].y + chipstack[stack].height
5394 params.position.z = chipstack[stack].z
5395 local obj = spawnObject(params)
5396 obj.setname('test2')
5397 money = money - v.value
5398 chipstack[stack].height = chipstack[stack].height + v.height
5399 j=j+1
5400 end
5401 end
5402 end
5403 i = i - 1
5404 end
5405
5406
5407 for i, v in ipairs (currencies) do
5408
5409 if v.value == -1 then
5410 break -- no dummy chips spawn
5411 end
5412 params.rotation = v.params.rotation
5413 params.scale = v.params.scale
5414 params.params = {v.name}
5415 if chipstack[v.stack] == nil then
5416 stack = "misc"
5417 else
5418 stack = v.stack
5419 end
5420
5421 if not v.standard then
5422 params.type = 'Custom_Model'
5423 params.callback_owner = Global
5424 custom.mesh = v.custom.mesh
5425 custom.diffuse = v.custom.diffuse
5426 custom.type = 5
5427 custom.material = 1
5428 local rot = {}
5429 rot.x = (r.x + v.params.rotation[1]) % 360
5430 rot.y = (r.y + v.params.rotation[2]) % 360
5431 rot.z = (r.z + v.params.rotation[3]) % 360
5432 rot[1] = rot.x
5433 rot[2] = rot.y
5434 rot[3] = rot.z
5435 params.rotation = rot
5436 while money >= tonumber(v.value) do
5437 params.position = {}
5438 params.position.x = chipstack[stack].x
5439 params.position.y = chipstack[stack].y + chipstack[stack].height
5440 params.position.z = chipstack[stack].z
5441 local obj = spawnObject(params)
5442 obj.setCustomObject(custom)
5443 obj.setName(v.value)
5444 money = money - v.value
5445 chipstack[stack].height = chipstack[stack].height + v.height
5446 end
5447 else
5448 params.type = 'Chip_'.. v.value
5449 params.callback = nil
5450 params.callback_owner = Global
5451 params.params = nil
5452 while money >= v.value do
5453 params.position = {}
5454 params.position.x = chipstack[stack].x
5455 params.position.y = chipstack[stack].y + chipstack[stack].height
5456 params.position.z = chipstack[stack].z
5457 local obj = spawnObject(params)
5458 if v.value == 10 then
5459 obj.setName('Ten')
5460 elseif v.value == 50 then
5461 obj.setName('Fifty')
5462 elseif v.value == 100 then
5463 obj.setName('One Hundred')
5464 elseif v.value == 500 then
5465 obj.setName('Five Hundred')
5466 elseif v.value == 1000 then
5467 obj.setName('One Thousand')
5468 end
5469 money = money - v.value
5470 chipstack[stack].height = chipstack[stack].height + v.height
5471 end
5472 end
5473 end
5474 return money -- returns the leftover money
5475end
5476
5477function sortPlayerChips(ob, pl)
5478 if Player[pl].admin then
5479 pl = ob.getDescription()
5480 elseif ob.getDescription() ~= pl then
5481 return 1
5482 end
5483
5484 local chips = {}
5485 local value
5486 value = "$" .. getChipValues(tablezones[pl],chips)
5487 if options.displayplayermoney then
5488 --tablezonetext[pl].setValue(value)
5489 end
5490
5491 p = tablezones[pl].getPosition()
5492 r = tablezones[pl].getRotation()
5493
5494 xoffset = -1.15
5495 zoffset = 1
5496 x = p.x + (math.cos(math.rad(r.y)) * xoffset) + (math.sin(math.rad(r.y)) * zoffset)
5497 z = p.z - (math.sin(math.rad(r.y)) * xoffset) + (math.cos(math.rad(r.y)) * zoffset)
5498 y = p.y - 10
5499
5500 pos = {x, y, z}
5501 pos.x = x
5502 pos.y = y
5503 pos.z = z
5504
5505 r.y = (r.y + 180) % 360
5506 moveChips(chips,pos,r)
5507
5508
5509end
5510
5511function quickConvertPlayerChips10(ob, pl)
5512 if Player[pl].admin then
5513 pl = ob.getDescription()
5514 elseif ob.getDescription() ~= pl then
5515 return 1
5516 end
5517
5518
5519 if quickConvertPlayerChips == true then
5520 -- if 15 seconds are over after the last convertion then start another one (function broke before)
5521 if (os.time() - quickConvertPlayerTime) < 15 then
5522 return
5523 else
5524 quickConvertPlayerTime = os.time()
5525 end
5526 else
5527 quickConvertPlayerChips = true
5528 quickConvertPlayerTime = os.time()
5529 end
5530
5531
5532
5533
5534 quickConvertPlayersPlayer = pl
5535 quickConvertPlayersObject = ob
5536
5537 startLuaCoroutine(nil, 'quickConvertPlayerChips10Co')
5538
5539end
5540
5541function quickConvertPlayerChips10Co()
5542
5543
5544 local pl = quickConvertPlayersPlayer
5545 local ob = quickConvertPlayersObject
5546
5547
5548
5549
5550 local objects = {}
5551 local chips1 = {}
5552 local positions1 = {}
5553 local rotations1 = {}
5554
5555 v = tablezones[pl]
5556 objects = {}
5557 objects = v.getObjects()
5558 for j, w in ipairs (objects) do
5559 if w.tag == 'Chip' then
5560 if w.getValue() or tonumber(w.getName()) != nil then
5561 chips1[#chips1 + 1] = w
5562 end
5563 end
5564 end
5565
5566
5567 for i, v in ipairs (chips1) do
5568 positions1[#positions1 + 1] = v.getPosition()
5569 rotations1[#rotations1 + 1] = v.getRotation()
5570 end
5571
5572 for i=0,2 do
5573 coroutine.yield(0)
5574 end
5575
5576
5577 objects = {}
5578 local chips2 = {}
5579 local positions2 = {}
5580 local rotations2 = {}
5581
5582 v = tablezones[pl]
5583 objects = {}
5584 objects = v.getObjects()
5585 for j, w in ipairs (objects) do
5586 if w.tag == 'Chip' then
5587 if w.getValue() or tonumber(w.getName()) != nil then
5588 chips2[#chips2 + 1] = w
5589 end
5590 end
5591 end
5592
5593
5594 if #chips2 ~= #chips1 then
5595 quickConvertPlayerChips = false
5596 return 1
5597 end
5598
5599 for i=0,2 do
5600 coroutine.yield(0)
5601 end
5602
5603
5604 for i, v in ipairs (chips2) do
5605 positions2[#positions2 + 1] = v.getPosition()
5606 rotations2[#rotations2 + 1] = v.getRotation()
5607 end
5608
5609 --[[ Check chip positions --]]
5610 for i, v in ipairs(positions1) do
5611 if v.x ~= positions2[i].x or v.y ~= positions2[i].y or v.z ~= positions2[i].z then
5612 quickConvertPlayerChips = false
5613 return 1
5614 end
5615 end
5616
5617 --[[ Check chip rotations --]]
5618 for i, v in pairs(rotations1) do
5619 if v.x ~= rotations2[i].x or v.y ~= rotations2[i].y or v.z ~= rotations2[i].z then
5620 quickConvertPlayerChips = false
5621 return 1
5622 end
5623 end
5624
5625 local chips = {}
5626 local money = 0
5627
5628
5629 money = getChipValues(tablezones[pl], chips)
5630 --[[ Destroy old chips --]]
5631 for i, v in ipairs (chips) do
5632 v.destruct()
5633 end
5634
5635 for i=0,10 do
5636 coroutine.yield(0)
5637 end
5638
5639 local p = tablezones[pl].getPosition()
5640 local r = tablezones[pl].getRotation()
5641
5642 xoffset = -1.15
5643 zoffset = 1
5644 x = p.x + (math.cos(math.rad(r.y)) * xoffset) + (math.sin(math.rad(r.y)) * zoffset)
5645 z = p.z - (math.sin(math.rad(r.y)) * xoffset) + (math.cos(math.rad(r.y)) * zoffset)
5646 y = p.y - 10
5647
5648 pos = {x, y, z}
5649 pos.x = x
5650 pos.y = y
5651 pos.z = z
5652
5653 r.y = (r.y + 180) % 360
5654
5655 spawnChips(money, pos,r, 10)
5656
5657
5658 --[[ Wait five frames to allow chips to spawn before updating pot values --]]
5659
5660 quickConvertPlayerChips = false
5661 return 1
5662end
5663
5664function quickConvertPlayerChips10_5(ob, pl)
5665 if Player[pl].admin then
5666 pl = ob.getDescription()
5667 elseif ob.getDescription() ~= pl then
5668 return 1
5669 end
5670
5671 if quickConvertPlayerChips == true then
5672 -- if 30 seconds are over after the last convertion then start another one (function broke before)
5673 if (os.time() - quickConvertPlayerTime) < 30 then
5674 return
5675 else
5676 quickConvertPlayerTime = os.time()
5677 end
5678 else
5679 quickConvertPlayerChips = true
5680 quickConvertPlayerTime = os.time()
5681 end
5682
5683 quickConvertPlayersPlayer = pl
5684 quickConvertPlayersObject = ob
5685
5686 startLuaCoroutine(nil, 'quickConvertPlayerChips10_5Co')
5687
5688end
5689
5690
5691
5692
5693function quickConvertPlayerChips10_5Co()
5694 local pl = quickConvertPlayersPlayer
5695 local ob = quickConvertPlayersObject
5696
5697
5698
5699
5700 local objects = {}
5701 local chips1 = {}
5702 local positions1 = {}
5703 local rotations1 = {}
5704
5705 v = tablezones[pl]
5706 objects = {}
5707 objects = v.getObjects()
5708 for j, w in ipairs (objects) do
5709 if w.tag == 'Chip' then
5710 if w.getValue() or tonumber(w.getName()) != nil then
5711 chips1[#chips1 + 1] = w
5712 end
5713 end
5714 end
5715
5716
5717 for i, v in ipairs (chips1) do
5718 positions1[#positions1 + 1] = v.getPosition()
5719 rotations1[#rotations1 + 1] = v.getRotation()
5720 end
5721
5722 for i=0,2 do
5723 coroutine.yield(0)
5724 end
5725
5726
5727 objects = {}
5728 local chips2 = {}
5729 local positions2 = {}
5730 local rotations2 = {}
5731
5732 v = tablezones[pl]
5733 objects = {}
5734 objects = v.getObjects()
5735 for j, w in ipairs (objects) do
5736 if w.tag == 'Chip' then
5737 if w.getValue() or tonumber(w.getName()) != nil then
5738 chips2[#chips2 + 1] = w
5739 end
5740 end
5741 end
5742
5743
5744 if #chips2 ~= #chips1 then
5745 quickConvertPlayerChips = false
5746 return 1
5747 end
5748
5749 for i=0,2 do
5750 coroutine.yield(0)
5751 end
5752
5753
5754 for i, v in ipairs (chips2) do
5755 positions2[#positions2 + 1] = v.getPosition()
5756 rotations2[#rotations2 + 1] = v.getRotation()
5757 end
5758
5759 --[[ Check chip positions --]]
5760 for i, v in ipairs(positions1) do
5761 if v.x ~= positions2[i].x or v.y ~= positions2[i].y or v.z ~= positions2[i].z then
5762 quickConvertPlayerChips = false
5763 return 1
5764 end
5765 end
5766
5767 --[[ Check chip rotations --]]
5768 for i, v in pairs(rotations1) do
5769 if v.x ~= rotations2[i].x or v.y ~= rotations2[i].y or v.z ~= rotations2[i].z then
5770 quickConvertPlayerChips = false
5771 return 1
5772 end
5773 end
5774
5775 local chips = {}
5776 local money = 0
5777
5778
5779 money = getChipValues(tablezones[pl], chips)
5780 --[[ Destroy old chips --]]
5781 for i, v in ipairs (chips) do
5782 v.destruct()
5783 end
5784
5785 for i=0,10 do
5786 coroutine.yield(0)
5787 end
5788
5789 local p = tablezones[pl].getPosition()
5790 local r = tablezones[pl].getRotation()
5791
5792 xoffset = -1.15
5793 zoffset = 1
5794 x = p.x + (math.cos(math.rad(r.y)) * xoffset) + (math.sin(math.rad(r.y)) * zoffset)
5795 z = p.z - (math.sin(math.rad(r.y)) * xoffset) + (math.cos(math.rad(r.y)) * zoffset)
5796 y = p.y - 10
5797
5798 pos = {x, y, z}
5799 pos.x = x
5800 pos.y = y
5801 pos.z = z
5802
5803 r.y = (r.y + 180) % 360
5804
5805 local lowStackValue = 0
5806 lowStackValue = currencies[#currencies-1].value * 10 + currencies[#currencies-2].value * 10
5807 + currencies[#currencies-3].value * 10
5808 if money <= lowStackValue then
5809 spawnChips(money, pos,r, 15)
5810 else
5811
5812 money = money-lowStackValue
5813 spawnChips(money,pos,r,5)
5814 pos["y"] = pos["y"] + 5
5815 spawnChips(lowStackValue,pos,r,10)
5816
5817
5818 end
5819
5820
5821 for i=0,10 do
5822 coroutine.yield(0)
5823 end
5824 -- update money display
5825 if options.displayplayermoney then
5826 local chips = {}
5827 --tablezonetext[pl].setValue("$" .. getChipValues(tablezones[pl],chips))
5828 --[[ Wait five frames to allow chips to spawn before updating pot values --]]
5829 quickConvertPlayerChips = false
5830 end
5831 return 1
5832end
5833
5834
5835
5836function splitPot2(ob, pl)
5837 if pl then
5838 if not Player[pl].admin then
5839 return 1
5840 end
5841 end
5842
5843 splitPotObject = ob;
5844 splitPotPlayers = 2;
5845
5846 local p = ob.getPosition()
5847 local r = ob.getRotation()
5848 local s = ob.getScale()
5849 params = {}
5850 params.type = 'ScriptingTrigger'
5851 params.callback = 'splitPot'
5852 params.scale = {s.x, 20, s.z*1.9}
5853 params.position = {p.x, p.y + 10, p.z}
5854 params.rotation = r
5855
5856 splitPotZone = spawnObject(params)
5857end
5858
5859function splitPot3(ob, pl)
5860 if pl then
5861 if not Player[pl].admin then
5862 return 1
5863 end
5864 end
5865
5866 splitPotObject = ob;
5867 splitPotPlayers = 3;
5868
5869 local p = ob.getPosition()
5870 local r = ob.getRotation()
5871 local s = ob.getScale()
5872 params = {}
5873 params.type = 'ScriptingTrigger'
5874 params.callback = 'splitPot'
5875 params.scale = {s.x, 20, s.z*1.9}
5876 params.position = {p.x, p.y + 10, p.z}
5877 params.rotation = r
5878
5879 splitPotZone = spawnObject(params)
5880end
5881
5882function splitPot4(ob, pl)
5883 if pl then
5884 if not Player[pl].admin then
5885 return 1
5886 end
5887 end
5888
5889 splitPotObject = ob;
5890 splitPotPlayers =4 ;
5891
5892 local p = ob.getPosition()
5893 local r = ob.getRotation()
5894 local s = ob.getScale()
5895 params = {}
5896 params.type = 'ScriptingTrigger'
5897 params.callback = 'splitPot'
5898 params.scale = {s.x, 20, s.z*1.9}
5899 params.position = {p.x, p.y + 10, p.z}
5900 params.rotation = r
5901
5902 splitPotZone = spawnObject(params)
5903end
5904
5905function splitPot5(ob, pl)
5906 if pl then
5907 if not Player[pl].admin then
5908 return 1
5909 end
5910 end
5911
5912 splitPotObject = ob;
5913 splitPotPlayers = 5;
5914
5915 local p = ob.getPosition()
5916 local r = ob.getRotation()
5917 local s = ob.getScale()
5918 params = {}
5919 params.type = 'ScriptingTrigger'
5920 params.callback = 'splitPot'
5921 params.scale = {s.x, 20, s.z*1.9}
5922 params.position = {p.x, p.y + 10, p.z}
5923 params.rotation = r
5924
5925 splitPotZone = spawnObject(params)
5926end
5927
5928function splitPot6(ob, pl)
5929 if pl then
5930 if not Player[pl].admin then
5931 return 1
5932 end
5933 end
5934
5935 splitPotObject = ob;
5936 splitPotPlayers = 6;
5937
5938 local p = ob.getPosition()
5939 local r = ob.getRotation()
5940 local s = ob.getScale()
5941 params = {}
5942 params.type = 'ScriptingTrigger'
5943 params.callback = 'splitPot'
5944 params.scale = {s.x, 20, s.z*1.9}
5945 params.position = {p.x, p.y + 10, p.z}
5946 params.rotation = r
5947
5948 splitPotZone = spawnObject(params)
5949end
5950
5951function splitPot7(ob, pl)
5952 if pl then
5953 if not Player[pl].admin then
5954 return 1
5955 end
5956 end
5957
5958 splitPotObject = ob;
5959 splitPotPlayers = 7;
5960
5961 local p = ob.getPosition()
5962 local r = ob.getRotation()
5963 local s = ob.getScale()
5964 params = {}
5965 params.type = 'ScriptingTrigger'
5966 params.callback = 'splitPot'
5967 params.scale = {s.x, 20, s.z*1.9}
5968 params.position = {p.x, p.y + 10, p.z}
5969 params.rotation = r
5970
5971 splitPotZone = spawnObject(params)
5972end
5973
5974function splitPot8(ob, pl)
5975 if pl then
5976 if not Player[pl].admin then
5977 return 1
5978 end
5979 end
5980
5981 splitPotObject = ob;
5982 splitPotPlayers = 8;
5983
5984 local p = ob.getPosition()
5985 local r = ob.getRotation()
5986 local s = ob.getScale()
5987 params = {}
5988 params.type = 'ScriptingTrigger'
5989 params.callback = 'splitPot'
5990 params.scale = {s.x, 20, s.z*1.9}
5991 params.position = {p.x, p.y + 10, p.z}
5992 params.rotation = r
5993
5994 splitPotZone = spawnObject(params)
5995end
5996
5997function splitPot9(ob, pl)
5998 if pl then
5999 if not Player[pl].admin then
6000 return 1
6001 end
6002 end
6003
6004 splitPotObject = ob;
6005 splitPotPlayers = 9;
6006
6007 local p = ob.getPosition()
6008 local r = ob.getRotation()
6009 local s = ob.getScale()
6010 params = {}
6011 params.type = 'ScriptingTrigger'
6012 params.callback = 'splitPot'
6013 params.scale = {s.x, 20, s.z*1.9}
6014 params.position = {p.x, p.y + 10, p.z}
6015 params.rotation = r
6016
6017 splitPotZone = spawnObject(params)
6018end
6019
6020
6021function splitPot10(ob, pl)
6022 if pl then
6023 if not Player[pl].admin then
6024 return 1
6025 end
6026 end
6027
6028 splitPotObject = ob;
6029 splitPotPlayers = 10;
6030
6031 local p = ob.getPosition()
6032 local r = ob.getRotation()
6033 local s = ob.getScale()
6034 params = {}
6035 params.type = 'ScriptingTrigger'
6036 params.callback = 'splitPot'
6037 params.scale = {s.x, 20, s.z*1.9}
6038 params.position = {p.x, p.y + 10, p.z}
6039 params.rotation = r
6040
6041 splitPotZone = spawnObject(params)
6042end
6043
6044
6045function splitPot()
6046 local chips = {}
6047 local value = 0;
6048
6049 value = getChipValues(splitPotZone,chips)
6050 leftover = 0;
6051 local spawnvalue = value / splitPotPlayers
6052
6053 for i, v in ipairs (chips) do
6054 v.destruct()
6055 end
6056
6057 local p = splitPotObject.getPosition()
6058 local r = splitPotObject.getRotation()
6059
6060
6061
6062
6063
6064
6065 local xoffset = 5.5
6066 local zoffset = -9.8
6067 local pos = {}
6068 pos.x = p.x + (math.cos(math.rad(r.y)) * xoffset) + (math.sin(math.rad(r.y)) * zoffset)
6069 pos.z = p.z - (math.sin(math.rad(r.y)) * xoffset) + (math.cos(math.rad(r.y)) * zoffset)
6070 pos.y = p.y + 0.2
6071 r[2] = r.y
6072
6073 local i = 0
6074
6075 xoffset = 12
6076 zoffset = 6.5
6077 while i < splitPotPlayers do
6078 leftover = leftover + spawnChips(spawnvalue, pos, r)
6079 pos.x = pos.x + (math.sin(math.rad(r.y)) * zoffset)
6080 pos.z = pos.z + (math.cos(math.rad(r.y)) * zoffset)
6081
6082 if i == 4 then
6083 pos.x = pos.x - (math.cos(math.rad(r.y)) * xoffset + (math.sin(math.rad(r.y)) * zoffset) * 5)
6084 pos.z = pos.z + (math.sin(math.rad(r.y)) * xoffset - (math.cos(math.rad(r.y)) * zoffset) * 5 )
6085 end
6086
6087
6088 i = i + 1
6089 end
6090
6091
6092 r = splitPotObject.getRotation()
6093 leftover = leftover + 0.1 -- avoid rounding errors for double number
6094 xoffset = -6.5
6095 zoffset = -14.8
6096 pos = {}
6097 pos.x = p.x + (math.cos(math.rad(r.y)) * xoffset) + (math.sin(math.rad(r.y)) * zoffset)
6098 pos.z = p.z - (math.sin(math.rad(r.y)) * xoffset) + (math.cos(math.rad(r.y)) * zoffset)
6099 pos.y = p.y + 0.2
6100 spawnChips(leftover, pos, r)
6101
6102
6103 splitPotZone.destruct()
6104end
6105
6106function goAllIn(ob, pl)
6107 if ob.getDescription() ~= pl then
6108 return 1
6109 end
6110
6111 if pl ~= actionon then
6112 return 0
6113 end
6114
6115 local chips = {}
6116 getChipValues(betzones[pl],chips)
6117 getChipValues(tablezones[pl],chips)
6118 p = betzones[pl].getPosition()
6119 r = betzones[pl].getRotation()
6120 p.y = p.y - 10
6121
6122 moveChips(chips,p,r)
6123 printstring = printstring..'allin'..actionon
6124
6125
6126end
6127
6128function compare(a,b)
6129 return a[1] > b[1]
6130end
6131
6132function goAFK(ob, pl)
6133 if Player[pl].admin then
6134 pl = ob.getDescription()
6135 elseif ob.getDescription() ~= pl then
6136 return 1
6137 end
6138
6139 local objects = betzones[pl].getObjects()
6140 local x = 0
6141 local found = false
6142
6143 for i, v in ipairs(objects) do
6144 if v.getName() == "AFK" then
6145 found = true
6146 v.destruct()
6147 end
6148 end
6149 if afkClock[pl] ~= nil then
6150 found = true
6151 afkClock[pl].destruct()
6152 afkClock[pl] = nil
6153 end
6154
6155 if not found then
6156 local params = {}
6157 params.type = 'Custom_Model'
6158 params.position = betzones[pl].getPosition()
6159 params.scale = {1.35, 1.05, 1.35}
6160 params.rotation = betzones[pl].getPosition()
6161
6162 local playerhand = getPlayerHandPositionAndRotation(pl)
6163 params.position = {playerhand['pos_x'] + playerhand['trigger_forward_x'] * 6.63, 1.4, playerhand['pos_z'] + playerhand['trigger_forward_z'] * 6.63}
6164 params.rotation = {360, playerhand['rot_y'], 180}
6165 params.callback = 'setAfkButton'
6166 afkButton = spawnObject(params)
6167
6168 local custom = {}
6169 custom.mesh = 'pastebin.com/raw.php?i=qv6mnq65'
6170 custom.diffuse = 'http://cloud-3.steamusercontent.com/ugc/787414409029900646/86887868A02758FE509E25BB6D81EDB601BA8002/'
6171 custom.type = 0
6172
6173 afkButton.setCustomObject(custom)
6174 afkButton.setName('AFK')
6175
6176 params = {}
6177 params.type = 'Digital_Clock'
6178
6179 params.position = {playerhand['pos_x'] + playerhand['trigger_forward_x'] * 0.6, 1.8, playerhand['pos_z'] + playerhand['trigger_forward_z'] * 0.6}
6180 params.rotation = {-215, playerhand['rot_y'], 180}
6181
6182 params.callback = 'setAfkClockTimer'
6183 afkClock[pl] = spawnObject(params)
6184
6185 end
6186
6187end
6188
6189function setAfkButton(ob, pl)
6190 ob.lock()
6191end
6192
6193function setPlayerAfk(ob, pl)
6194 if pl then
6195 if not Player[pl].admin then
6196 return 1
6197 end
6198 end
6199 if actionon ~= nil then
6200 goAFK(ob,actionon)
6201 end
6202end
6203
6204
6205function setAfkClockTimer(ob, pl)
6206 ob.lock()
6207 ob.Clock.startStopwatch()
6208 ob.setColorTint({0.1, 0.1, 0.1})
6209 ob.setName("AFK")
6210 --afkClock[pl].lock()
6211 --afkClock[pl].Clock.startStopwatch()
6212end
6213
6214function changeMachineButton1(ob, pl)
6215 if not converting then
6216 clicker = player
6217 convertingPlayer = true
6218 conversionPlayerValue = 1
6219 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6220 end
6221end
6222
6223function changeMachineButton2(ob, pl)
6224 if not converting then
6225 clicker = player
6226 convertingPlayer = true
6227 conversionPlayerValue = 2
6228 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6229 end
6230end
6231
6232function changeMachineButton3(ob, pl)
6233 if not converting then
6234 clicker = player
6235 convertingPlayer = true
6236 conversionPlayerValue = 3
6237 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6238 end
6239end
6240
6241function changeMachineButton4(ob, pl)
6242 if not converting then
6243 clicker = player
6244 convertingPlayer = true
6245 conversionPlayerValue = 4
6246 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6247 end
6248end
6249
6250function changeMachineButton5(ob, pl)
6251 if not converting then
6252 clicker = player
6253 convertingPlayer = true
6254 conversionPlayerValue = 5
6255 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6256 end
6257end
6258
6259
6260function changeMachineButton6(ob, pl)
6261 if not converting then
6262 clicker = player
6263 convertingPlayer = true
6264 conversionPlayerValue = 6
6265 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6266 end
6267end
6268
6269function changeMachineButton7(ob, pl)
6270 if not convertingPlayer then
6271 convertingPlayerColor = pl
6272 convertingPlayer = true
6273 conversionPlayerValue = 7
6274 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6275
6276 end
6277end
6278
6279function changeMachineButton8(ob, pl)
6280 if not convertingPlayer then
6281 convertingPlayerColor = pl
6282 convertingPlayer = true
6283 conversionPlayerValue = 8
6284 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6285
6286 end
6287end
6288
6289function changeMachineButton9(ob, pl)
6290 if not convertingPlayer then
6291 convertingPlayerColor = pl
6292 convertingPlayer = true
6293 conversionPlayerValue = 9
6294 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6295
6296 end
6297end
6298
6299function changeMachineButton10(ob, pl)
6300 if not convertingPlayer then
6301 convertingPlayerColor = pl
6302 convertingPlayer = true
6303 conversionPlayerValue = 10
6304 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6305 end
6306end
6307
6308
6309function changeMachineButton11(ob, pl)
6310 if not converting then
6311 clicker = player
6312 convertingPlayer = true
6313 conversionPlayerValue = 11
6314 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6315 end
6316end
6317
6318function changeMachineButton12(ob, pl)
6319 if not converting then
6320 clicker = player
6321 convertingPlayer = true
6322 conversionPlayerValue = 12
6323 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6324 end
6325end
6326
6327function changeMachineButton13(ob, pl)
6328 if not converting then
6329 clicker = player
6330 convertingPlayer = true
6331 conversionPlayerValue = 13
6332 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6333 end
6334end
6335
6336function changeMachineButton14(ob, pl)
6337 if not converting then
6338 clicker = player
6339 convertingPlayer = true
6340 conversionPlayerValue = 14
6341 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6342 end
6343end
6344
6345function changeMachineButton15(ob, pl)
6346 if not converting then
6347 clicker = player
6348 convertingPlayer = true
6349 conversionPlayerValue = 15
6350 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6351 end
6352end
6353
6354
6355function changeMachineButton16(ob, pl)
6356 if not converting then
6357 clicker = player
6358 convertingPlayer = true
6359 conversionPlayerValue = 16
6360 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6361 end
6362end
6363
6364function changeMachineButton17(ob, pl)
6365 if not convertingPlayer then
6366 convertingPlayerColor = pl
6367 convertingPlayer = true
6368 conversionPlayerValue = 17
6369 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6370
6371 end
6372end
6373
6374function changeMachineButton18(ob, pl)
6375 if not convertingPlayer then
6376 convertingPlayerColor = pl
6377 convertingPlayer = true
6378 conversionPlayerValue = 18
6379 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6380
6381 end
6382end
6383
6384function changeMachineButton19(ob, pl)
6385 if not convertingPlayer then
6386 convertingPlayerColor = pl
6387 convertingPlayer = true
6388 conversionPlayerValue = 19
6389 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6390
6391 end
6392end
6393
6394function changeMachineButton20(ob, pl)
6395 if not convertingPlayer then
6396 convertingPlayerColor = pl
6397 convertingPlayer = true
6398 conversionPlayerValue = 20
6399 ChangeMachineZone = spawnChangeMachineZone(ob, pl)
6400 end
6401end
6402
6403
6404
6405
6406
6407
6408function spawnChangeMachineZone(ob, pl)
6409 --[[spawn scripting zone on in surface--]]
6410 local p = ob.getPosition()
6411 local r = ob.getRotation()
6412 local s = ob.getScale()
6413
6414 params = {}
6415
6416 params.type = 'ScriptingTrigger'
6417 params.callback = 'checkChangeMachineZone'
6418 params.scale = {s.x * 2, 20, s.z}
6419 params.position = {p.x - ((s.z/2) * math.sin(math.rad(r.y))), p.y + 9, p.z - ((s.z/2) * math.cos(math.rad(r.y)))}
6420 params.rotation = ob.getRotation()
6421
6422 changeMachineZone = spawnObject(params)
6423end
6424
6425function checkChangeMachineZone()
6426 startLuaCoroutine(nil,'checkChangeMachineZoneCoroutine')
6427end
6428
6429function checkChangeMachineZoneCoroutine()
6430 local objects1 = changeMachineZone.getObjects()
6431 local positions1 = {}
6432 local rotations1 = {}
6433
6434 for i, v in ipairs(objects1) do
6435 positions1[#positions1 + 1] = v.getPosition()
6436 rotations1[#rotations1 + 1] = v.getRotation()
6437 end
6438
6439 for i=1, 2 do
6440 coroutine.yield(0)
6441 end
6442
6443 local objects2 = changeMachineZone.getObjects()
6444 local positions2 = {}
6445 local rotations2 = {}
6446
6447 --[[ Abort if the amount of chips/stacks changed --]]
6448 if #objects1 ~= #objects2 then
6449 broadcastToColor('Conversion aborted. Please wait for chips to be at rest on the platform and try again.', convertingPlayerColor, {1, 0, 0})
6450 changeMachineZone.destruct()
6451 converting = false
6452 return 1
6453 end
6454
6455 for i, v in ipairs(objects1) do
6456 positions2[#positions2 + 1] = v.getPosition()
6457 rotations2[#rotations2 + 1] = v.getRotation()
6458 end
6459
6460 --[[ Abort if any chips/stacks are moving --]]
6461 for i, v in ipairs (positions1) do
6462 if v.x ~= positions2[i].x or v.y ~= positions2[i].y or v.z ~= positions2[i].z then
6463 broadcastToColor ('Conversion aborted. Please wait for chips to be at rest on the platform and try again.', convertingPlayerColor, {1, 0, 0})
6464 changeMachineZone.destruct()
6465 convertingPlayer = false
6466 return 1
6467 end
6468
6469 if rotations1[i].x ~= rotations2[i].x or rotations1[i].y ~= rotations2[i].y or rotations1[i].z ~= rotations2[i].z then
6470 broadcastToColor ('Conversion aborted. Please wait for chips to be at rest on the platform and try again.', convertingPlayerColor, {1, 0, 0})
6471 changeMachineZone.destruct()
6472 convertingPlayer = false
6473 return 1
6474 end
6475 end
6476
6477 local pos = changeMachineZone.getPosition()
6478 pos["y"] = 2
6479 local rot = changeMachineZone.getRotation()
6480 rot["y"] = (rot["y"] + 180) % 360
6481 local chips = {}
6482 money = getChipValues(changeMachineZone, chips)
6483
6484 for i, v in ipairs(chips) do
6485 v.destruct()
6486 end
6487 convertchangeMachine(money, pos, rot , 25)
6488
6489 changeMachineZone.destruct()
6490 convertingPlayer = false
6491 --calculateAndConvert()
6492 return 1
6493end
6494
6495
6496
6497function convertchangeMachine(money, p, r, height)
6498
6499
6500 local chipstack = {}
6501 chipstack = initializePot()
6502 for i, v in pairs(chipstack) do
6503 v.x = p.x + (math.cos(math.rad(r.y)) * v.xoffset) + (math.sin(math.rad(r.y)) * v.zoffset)
6504 v.z = p.z - (math.sin(math.rad(r.y)) * v.xoffset) + (math.cos(math.rad(r.y)) * v.zoffset)
6505 v.y = p.y + v.yoffset + v.height
6506 end
6507 local v = {}
6508 v = currencies[conversionPlayerValue]
6509 local custom = {}
6510 if v.value > 0 then
6511 params.rotation = v.params.rotation
6512 params.scale = v.params.scale
6513 params.params = {v.name}
6514 local rot = {}
6515 rot.x = (r.x + v.params.rotation[1]) % 360
6516 rot.y = (r.y + v.params.rotation[2]) % 360
6517 rot.z = (r.z + v.params.rotation[3]) % 360
6518 rot[1] = rot.x
6519 rot[2] = rot.y
6520 rot[3] = rot.z
6521 params.rotation = rot
6522 if chipstack[v.stack] == nil then
6523 stack = "misc"
6524 else
6525 stack = v.stack
6526 end
6527 if not v.standard then
6528 params.type = 'Custom_Model'
6529 params.callback_owner = Global
6530 custom.mesh = v.custom.mesh
6531 custom.diffuse = v.custom.diffuse
6532 custom.type = 5
6533 custom.material = 1
6534 local i=0
6535 while money >= tonumber(v.value) and i<height do
6536 params.position = {}
6537 params.position.x = chipstack[stack].x
6538 params.position.y = chipstack[stack].y + chipstack[stack].height
6539 params.position.z = chipstack[stack].z
6540 local obj = spawnObject(params)
6541 obj.setCustomObject(custom)
6542 obj.setName(v.name)
6543 money = money - v.value
6544 chipstack[stack].height = chipstack[stack].height + v.height
6545 i=i+1
6546 if i >= height then
6547 broadcastToColor("Conversion limit reached. The difference is spawned with the least amount of chips as possible", convertingPlayerColor, {1,1,0})
6548 end
6549 end
6550 else
6551 params.type = 'Chip_'.. v.value
6552 params.callback = nil
6553 params.callback_owner = Global
6554 params.params = nil
6555 local i=0
6556 while money >= v.value and i<height do
6557 params.position = {}
6558 params.position.x = chipstack[stack].x
6559 params.position.y = chipstack[stack].y + chipstack[stack].height
6560 params.position.z = chipstack[stack].z
6561 spawnObject(params)
6562 money = money - v.value
6563 chipstack[stack].height = chipstack[stack].height + v.height
6564 i = i + 1
6565 if i >= height then
6566 broadcastToColor("Conversion limit reached. The difference is spawned with the least amount of chips as possible", convertingPlayerColor, {1,1,0})
6567 end
6568 end
6569 end
6570 end
6571
6572
6573 p["y"] = 10
6574 spawnChips(money, p, r)
6575 convertingPlayer = false
6576end
6577
6578
6579function loadSaveBag(ob, pl)
6580 for i, v in ipairs(savebag.getObjects()) do
6581
6582 if v.name == Player[pl].steam_name then
6583 local params = {}
6584 --params.position = Vector –Optional. Defaults to the container’s position + 2 in the x direction.
6585 --params.rotation = Vector –Optional. Defaults to the container’s rotation.
6586 params.position = tablezones[pl].getPosition()
6587 params.position.y = params.position.y - 8
6588 params.rotation = tablezones[pl].getRotation()
6589 params.callback_owner = Global
6590 --params.guid = v.guid
6591 params.index = v.index
6592 saves[pl] = savebag.takeObject(params)
6593 if saves[pl].getDescription() == "" then
6594 for i, v in ipairs (getSeatedPlayers()) do
6595 if Player[v].admin then
6596 broadcastToColor('Warning: Steamid not found on savebag for player ' .. Player[pl].steam_name, v, {1, 1, 0})
6597 end
6598 end
6599 elseif saves[pl].getDescription() != Player[pl].steam_id then
6600 for i, v in ipairs (getSeatedPlayers()) do
6601 if Player[v].admin then
6602 broadcastToColor('Warning: Steamid on savebag dont match the current player ' .. Player[pl].steam_name, v, {1, 1, 0})
6603 end
6604 end
6605 end
6606 return 1
6607 end
6608 end
6609 for i, v in ipairs (getSeatedPlayers()) do
6610 if Player[v].admin or v == pl then
6611 broadcastToColor('Warning: no save found for player ' .. Player[pl].steam_name .. '.' , v, {1, 1, 0})
6612 end
6613 end
6614end
6615
6616
6617
6618--[[ rPrint(struct, [limit], [indent]) Recursively print arbitrary data.
6619 Set limit (default 100) to stanch infinite loops.
6620 Indents tables as [KEY] VALUE, nested tables as [KEY] [KEY]...[KEY] VALUE
6621 Set indent ("") to prefix each line: Mytable [KEY] [KEY]...[KEY] VALUE
6622--]]
6623function rPrint(s, l, i) -- recursive Print (structure, limit, indent)
6624 l = (l) or 100; i = i or ""; -- default item limit, indent string
6625 if (l<1) then print "ERROR: Item limit reached."; return l-1 end;
6626 local ts = type(s);
6627 if (ts ~= "table") then print (i,ts,s); return l-1 end
6628 print (i,ts); -- print "table"
6629 for k,v in pairs(s) do -- print "[ KEY ] VALUE"
6630 l = rPrint(v, l, i.."\t[ "..tostring(k).." ] ");
6631 if (l < 0) then break end
6632 end
6633 return l
6634end
6635
6636function comma_value(n) -- credit http://richard.warburton.it
6637 local left,num,right = string.match(n,'^([^%d]*%d)(%d*)(.-)$')
6638 return left..(num:reverse():gsub('(%d%d%d)','%1,'):reverse())..right
6639end
6640
6641function quickCall(ob, pl)
6642 calculatePots()
6643 if Player[pl].admin then
6644 pl = ob.getDescription()
6645 elseif ob.getDescription() ~= pl then
6646 return 1
6647 end
6648
6649 quickConvertPlayersPlayer = pl
6650 quickConvertPlayersObject = ob
6651
6652 --[[local objects = {}
6653 local chips1 = {}
6654 local positions1 = {}
6655 local rotations1 = {}--]]
6656
6657 local chips = {}
6658 local chipsout = getChipValues(betzones[pl],chips)
6659 local playerchips = getChipValues(tablezones[pl],chips)
6660 local chipdiff = currentbet - chipsout
6661 --[[if chipdiff >= playerchips then
6662 goAllIn(ob, pl)
6663 action(ob, pl)
6664 return 1
6665 end--]]
6666
6667 startLuaCoroutine(nil, 'quickCallCo')
6668 startLuaCoroutine(nil, 'quickCallCo2')
6669end
6670
6671function quickCallCo()
6672 local pl = quickConvertPlayersPlayer
6673 local ob = quickConvertPlayersObject
6674
6675 local objects = {}
6676 local chips1 = {}
6677 local positions1 = {}
6678 local rotations1 = {}
6679
6680 if ob.getDescription() ~= pl then
6681 return 1
6682 end
6683
6684 if pl ~= actionon then
6685 coroutine.yield(1)
6686 return 0
6687 end
6688
6689 local chips = {}
6690 local chipsout = getChipValues(betzones[pl],chips)
6691 local playerchips = getChipValues(tablezones[pl],chips)
6692 p = betzones[pl].getPosition()
6693 r = betzones[pl].getRotation()
6694 p.y = p.y - 10
6695 local chipdiff = currentbet - chipsout
6696 if chipdiff == 0 then
6697 return 1
6698 end
6699
6700 v = tablezones[pl]
6701 objects = {}
6702 objects = v.getObjects()
6703 for j, w in ipairs (objects) do
6704 if w.tag == 'Chip' then
6705 if w.getValue() or tonumber(w.getName()) != nil then
6706 chips1[#chips1 + 1] = w
6707 end
6708 end
6709 end
6710
6711 for i, v in ipairs (chips1) do
6712 positions1[#positions1 + 1] = v.getPosition()
6713 rotations1[#rotations1 + 1] = v.getRotation()
6714 end
6715
6716 for i=0,2 do
6717 coroutine.yield(0)
6718 end
6719
6720 objects = {}
6721 local chips2 = {}
6722 local positions2 = {}
6723 local rotations2 = {}
6724
6725 v = tablezones[pl]
6726 objects = {}
6727 objects = v.getObjects()
6728 for j, w in ipairs (objects) do
6729 if w.tag == 'Chip' then
6730 if w.getValue() or tonumber(w.getName()) != nil then
6731 chips2[#chips2 + 1] = w
6732 end
6733 end
6734 end
6735
6736 if #chips2 ~= #chips1 then
6737 quickConvertPlayerChips = false
6738 return 1
6739 end
6740
6741 for i=0,2 do
6742 coroutine.yield(0)
6743 end
6744
6745 for i, v in ipairs (chips2) do
6746 positions2[#positions2 + 1] = v.getPosition()
6747 rotations2[#rotations2 + 1] = v.getRotation()
6748 end
6749
6750 --[[ Check chip positions --]]
6751 for i, v in ipairs(positions1) do
6752 if v.x ~= positions2[i].x or v.y ~= positions2[i].y or v.z ~= positions2[i].z then
6753 quickConvertPlayerChips = false
6754 return 1
6755 end
6756 end
6757
6758 --[[ Check chip rotations --]]
6759 for i, v in pairs(rotations1) do
6760 if v.x ~= rotations2[i].x or v.y ~= rotations2[i].y or v.z ~= rotations2[i].z then
6761 quickConvertPlayerChips = false
6762 return 1
6763 end
6764 end
6765
6766 local chips = {}
6767 local money = 0
6768
6769 money = (getChipValues(tablezones[pl], chips)) - chipdiff
6770 --[[ Destroy old chips --]]
6771 for i, v in ipairs (chips) do
6772 v.destruct()
6773 end
6774
6775 for i=0,10 do
6776 coroutine.yield(0)
6777 end
6778
6779 local p = tablezones[pl].getPosition()
6780 local r = tablezones[pl].getRotation()
6781
6782 xoffset = -1.15
6783 zoffset = 1
6784 x = p.x + (math.cos(math.rad(r.y)) * xoffset) + (math.sin(math.rad(r.y)) * zoffset)
6785 z = p.z - (math.sin(math.rad(r.y)) * xoffset) + (math.cos(math.rad(r.y)) * zoffset)
6786 y = p.y - 10
6787
6788 pos = {x, y, z}
6789 pos.x = x
6790 pos.y = y
6791 pos.z = z
6792
6793 r.y = (r.y + 180) % 360
6794
6795 local lowStackValue = 0
6796 lowStackValue = currencies[#currencies-1].value * 10 + currencies[#currencies-2].value * 10
6797 + currencies[#currencies-3].value * 10
6798 if money <= lowStackValue then
6799 spawnChips(money, pos,r, 15)
6800 else
6801 money = money-lowStackValue
6802 spawnChips(money,pos,r,5)
6803 pos["y"] = pos["y"] + 5
6804 spawnChips(lowStackValue,pos,r,10)
6805 end
6806
6807 for i=0,10 do
6808 coroutine.yield(0)
6809 end
6810
6811 calculatePots()
6812 -- update money display
6813 if options.displayplayermoney then
6814 local chips = {}
6815 --tablezonetext[pl].setValue("$" .. getChipValues(tablezones[pl],chips))
6816 --[[ Wait five frames to allow chips to spawn before updating pot values --]]
6817 quickConvertPlayerChips = false
6818 end
6819 return 1
6820end
6821
6822function quickCallCo2()
6823 local pl = quickConvertPlayersPlayer
6824 local ob = quickConvertPlayersObject
6825
6826 local objects = {}
6827 local chips1 = {}
6828 local positions1 = {}
6829 local rotations1 = {}
6830
6831 if ob.getDescription() ~= pl then
6832 return 1
6833 end
6834
6835 if pl ~= actionon then
6836 coroutine.yield(1)
6837 return 0
6838 end
6839
6840 local chips = {}
6841 local chipsout = getChipValues(betzones[pl],chips)
6842 local playerchips = getChipValues(tablezones[pl],chips)
6843 p = betzones[pl].getPosition()
6844 r = betzones[pl].getRotation()
6845 p.y = p.y - 10
6846 local chipdiff = currentbet - chipsout
6847 if chipdiff == 0 then
6848 return 1
6849 end
6850
6851 v = betzones[pl]
6852 objects = {}
6853 objects = v.getObjects()
6854 for j, w in ipairs (objects) do
6855 if w.tag == 'Chip' then
6856 if w.getValue() or tonumber(w.getName()) != nil then
6857 chips1[#chips1 + 1] = w
6858 end
6859 end
6860 end
6861
6862 for i, v in ipairs (chips1) do
6863 positions1[#positions1 + 1] = v.getPosition()
6864 rotations1[#rotations1 + 1] = v.getRotation()
6865 end
6866
6867 for i=0,2 do
6868 coroutine.yield(0)
6869 end
6870
6871 objects = {}
6872 local chips2 = {}
6873 local positions2 = {}
6874 local rotations2 = {}
6875
6876 v = betzones[pl]
6877 objects = {}
6878 objects = v.getObjects()
6879 for j, w in ipairs (objects) do
6880 if w.tag == 'Chip' then
6881 if w.getValue() or tonumber(w.getName()) != nil then
6882 chips2[#chips2 + 1] = w
6883 end
6884 end
6885 end
6886
6887 if #chips2 ~= #chips1 then
6888 quickConvertPlayerChips = false
6889 return 1
6890 end
6891
6892 for i=0,2 do
6893 coroutine.yield(0)
6894 end
6895
6896 for i, v in ipairs (chips2) do
6897 positions2[#positions2 + 1] = v.getPosition()
6898 rotations2[#rotations2 + 1] = v.getRotation()
6899 end
6900
6901 --[[ Check chip positions --]]
6902 for i, v in ipairs(positions1) do
6903 if v.x ~= positions2[i].x or v.y ~= positions2[i].y or v.z ~= positions2[i].z then
6904 quickConvertPlayerChips = false
6905 return 1
6906 end
6907 end
6908
6909 --[[ Check chip rotations --]]
6910 for i, v in pairs(rotations1) do
6911 if v.x ~= rotations2[i].x or v.y ~= rotations2[i].y or v.z ~= rotations2[i].z then
6912 quickConvertPlayerChips = false
6913 return 1
6914 end
6915 end
6916
6917 local chips = {}
6918 local money = 0
6919 money = chipdiff + chipsout
6920 --[[ Destroy old chips --]]
6921 for i, v in ipairs (chips2) do
6922 v.destruct()
6923 end
6924
6925 for i=0,10 do
6926 coroutine.yield(0)
6927 end
6928
6929 local p = betzones[pl].getPosition()
6930 local r = betzones[pl].getRotation()
6931
6932 xoffset = -1.15
6933 zoffset = 1
6934 --x = p.x + (math.cos(math.rad(r.y)) * xoffset) + (math.sin(math.rad(r.y)) * zoffset)
6935 --z = p.z - (math.sin(math.rad(r.y)) * xoffset) + (math.cos(math.rad(r.y)) * zoffset)
6936 --y = p.y - 10
6937 x = p.x
6938 z = p.z
6939 y = p.y
6940
6941 pos = {x, y, z}
6942 pos.x = x
6943 pos.y = y
6944 pos.z = z
6945
6946 r.y = (r.y + 180) % 360
6947
6948 local lowStackValue = 0
6949 lowStackValue = currencies[#currencies-1].value * 10 + currencies[#currencies-2].value * 10
6950 + currencies[#currencies-3].value * 10
6951 if money <= lowStackValue then
6952 spawnChips(money, pos,r, 1)
6953 else
6954 money = money-lowStackValue
6955 spawnChips(money,pos,r,5)
6956 pos["y"] = pos["y"] + 5
6957 spawnChips(lowStackValue,pos,r,10)
6958 end
6959
6960 for i=0,10 do
6961 coroutine.yield(0)
6962 end
6963
6964 calculatePots()
6965 action(ob, pl)
6966 -- update money display
6967 if options.displayplayermoney then
6968 local chips = {}
6969 --tablezonetext[pl].setValue("$" .. getChipValues(tablezones[pl],chips))
6970 --[[ Wait five frames to allow chips to spawn before updating pot values --]]
6971 quickConvertPlayerChips = false
6972 end
6973 return 1
6974end
6975
6976--Pretty sure this is unnecessary
6977function convertCallToBet()
6978 bets = bets + getChipValues(potzones[1], chips)
6979 --[[ Spawn new chips in pot --]]
6980 --[[ Destroy old chips --]]
6981 for i, v in ipairs (chips) do
6982 v.destruct()
6983 end
6984 --[[ Wait five frames to allow chips to spawn destruct themself --]]
6985 for i = 1, 10 do
6986 coroutine.yield(0)
6987 end
6988
6989 spawnChips(bets, potobject.getPosition(), potobject.getRotation(), options.convertstackheight)
6990
6991 --[[ Wait five frames to allow chips to spawn before updating pot values --]]
6992 for i = 1, 5 do
6993 coroutine.yield(0)
6994 end
6995
6996 calculatePots()
6997
6998 convertfailcount = 0
6999
7000 return 1
7001end
7002
7003function quickBet(ob, pl)
7004 calculatePots()
7005 if Player[pl].admin then
7006 pl = ob.getDescription()
7007 elseif ob.getDescription() ~= pl then
7008 return 1
7009 end
7010
7011 quickConvertPlayersPlayer = pl
7012 quickConvertPlayersObject = ob
7013
7014 --[[local objects = {}
7015 local chips1 = {}
7016 local positions1 = {}
7017 local rotations1 = {}--]]
7018
7019 local temptable = getObjectFromGUID('413411')
7020 local inputslist = temptable.getInputs()
7021 local inputbet = tonumber(inputslist[1].value)
7022 --local divis = inputbet % 10
7023 if inputbet == nil then
7024 return 1
7025 elseif (inputbet % 10 ) ~= 0 then
7026 return 1
7027 end
7028 --print(inputslist[1].value)
7029
7030 local chips = {}
7031 local chipsout = getChipValues(betzones[pl],chips)
7032 local playerchips = getChipValues(tablezones[pl],chips)
7033 local chipdiff = inputbet - chipsout
7034 print(chipdiff)
7035 --[[if chipdiff >= playerchips then
7036 goAllIn(ob, pl)
7037 action(ob, pl)
7038 return 1
7039 end--]]
7040
7041 startLuaCoroutine(nil, 'quickBetCo')
7042 startLuaCoroutine(nil, 'quickBetCo2')
7043end
7044
7045function quickBetCo()
7046
7047 local pl = quickConvertPlayersPlayer
7048 local ob = quickConvertPlayersObject
7049
7050 local objects = {}
7051 local chips1 = {}
7052 local positions1 = {}
7053 local rotations1 = {}
7054
7055 local temptable = getObjectFromGUID('413411')
7056 local inputslist = temptable.getInputs()
7057
7058 if ob.getDescription() ~= pl then
7059 --coroutine.yield(0)
7060 return 0
7061 end
7062
7063 if pl ~= actionon then
7064 coroutine.yield(1)
7065 return 1
7066 end
7067
7068 local chips = {}
7069 local chipsout = getChipValues(betzones[pl],chips)
7070 local playerchips = getChipValues(tablezones[pl],chips)
7071 p = betzones[pl].getPosition()
7072 r = betzones[pl].getRotation()
7073 p.y = p.y - 10
7074 local chipdiff = inputslist[1].value - chipsout
7075 if chipdiff == 0 then
7076 return 1
7077 end
7078
7079 v = tablezones[pl]
7080 objects = {}
7081 objects = v.getObjects()
7082 for j, w in ipairs (objects) do
7083 if w.tag == 'Chip' then
7084 if w.getValue() or tonumber(w.getName()) != nil then
7085 chips1[#chips1 + 1] = w
7086 end
7087 end
7088 end
7089
7090 for i, v in ipairs (chips1) do
7091 positions1[#positions1 + 1] = v.getPosition()
7092 rotations1[#rotations1 + 1] = v.getRotation()
7093 end
7094
7095 for i=0,2 do
7096 coroutine.yield(0)
7097 end
7098
7099 objects = {}
7100 local chips2 = {}
7101 local positions2 = {}
7102 local rotations2 = {}
7103
7104 v = tablezones[pl]
7105 objects = {}
7106 objects = v.getObjects()
7107 for j, w in ipairs (objects) do
7108 if w.tag == 'Chip' then
7109 if w.getValue() or tonumber(w.getName()) != nil then
7110 chips2[#chips2 + 1] = w
7111 end
7112 end
7113 end
7114
7115 if #chips2 ~= #chips1 then
7116 quickConvertPlayerChips = false
7117 return 1
7118 end
7119
7120 for i=0,2 do
7121 coroutine.yield(0)
7122 end
7123
7124 for i, v in ipairs (chips2) do
7125 positions2[#positions2 + 1] = v.getPosition()
7126 rotations2[#rotations2 + 1] = v.getRotation()
7127 end
7128
7129 --[[ Check chip positions --]]
7130 for i, v in ipairs(positions1) do
7131 if v.x ~= positions2[i].x or v.y ~= positions2[i].y or v.z ~= positions2[i].z then
7132 quickConvertPlayerChips = false
7133 return 1
7134 end
7135 end
7136
7137 --[[ Check chip rotations --]]
7138 for i, v in pairs(rotations1) do
7139 if v.x ~= rotations2[i].x or v.y ~= rotations2[i].y or v.z ~= rotations2[i].z then
7140 quickConvertPlayerChips = false
7141 return 1
7142 end
7143 end
7144
7145 local chips = {}
7146 local money = 0
7147
7148 money = (getChipValues(tablezones[pl], chips)) - chipdiff
7149 --[[ Destroy old chips --]]
7150 for i, v in ipairs (chips) do
7151 v.destruct()
7152 end
7153
7154 for i=0,10 do
7155 coroutine.yield(0)
7156 end
7157
7158 local p = tablezones[pl].getPosition()
7159 local r = tablezones[pl].getRotation()
7160
7161 xoffset = -1.15
7162 zoffset = 1
7163 x = p.x + (math.cos(math.rad(r.y)) * xoffset) + (math.sin(math.rad(r.y)) * zoffset)
7164 z = p.z - (math.sin(math.rad(r.y)) * xoffset) + (math.cos(math.rad(r.y)) * zoffset)
7165 y = p.y - 10
7166
7167 pos = {x, y, z}
7168 pos.x = x
7169 pos.y = y
7170 pos.z = z
7171
7172 r.y = (r.y + 180) % 360
7173
7174 local lowStackValue = 0
7175 lowStackValue = currencies[#currencies-1].value * 10 + currencies[#currencies-2].value * 10
7176 + currencies[#currencies-3].value * 10
7177 if money <= lowStackValue then
7178 spawnChips(money, pos,r, 15)
7179 else
7180 money = money-lowStackValue
7181 spawnChips(money,pos,r,5)
7182 pos["y"] = pos["y"] + 5
7183 spawnChips(lowStackValue,pos,r,10)
7184 end
7185
7186 for i=0,10 do
7187 coroutine.yield(0)
7188 end
7189
7190 calculatePots()
7191 -- update money display
7192 if options.displayplayermoney then
7193 local chips = {}
7194 --tablezonetext[pl].setValue("$" .. getChipValues(tablezones[pl],chips))
7195 --[[ Wait five frames to allow chips to spawn before updating pot values --]]
7196 quickConvertPlayerChips = false
7197 end
7198 return 1
7199end
7200
7201function quickBetCo2()
7202 local pl = quickConvertPlayersPlayer
7203 local ob = quickConvertPlayersObject
7204
7205 local objects = {}
7206 local chips1 = {}
7207 local positions1 = {}
7208 local rotations1 = {}
7209
7210 local temptable = getObjectFromGUID('413411')
7211 local inputslist = temptable.getInputs()
7212
7213 if ob.getDescription() ~= pl then
7214 return 1
7215 end
7216
7217 if pl ~= actionon then
7218 coroutine.yield(1)
7219 return 0
7220 end
7221
7222 local chips = {}
7223 local chipsout = getChipValues(betzones[pl],chips)
7224 local playerchips = getChipValues(tablezones[pl],chips)
7225 p = betzones[pl].getPosition()
7226 r = betzones[pl].getRotation()
7227 p.y = p.y - 10
7228 local chipdiff = inputslist[1].value - chipsout
7229 if chipdiff == 0 then
7230 return 1
7231 end
7232
7233 v = betzones[pl]
7234 objects = {}
7235 objects = v.getObjects()
7236 for j, w in ipairs (objects) do
7237 if w.tag == 'Chip' then
7238 if w.getValue() or tonumber(w.getName()) != nil then
7239 chips1[#chips1 + 1] = w
7240 end
7241 end
7242 end
7243
7244 for i, v in ipairs (chips1) do
7245 positions1[#positions1 + 1] = v.getPosition()
7246 rotations1[#rotations1 + 1] = v.getRotation()
7247 end
7248
7249 for i=0,2 do
7250 coroutine.yield(0)
7251 end
7252
7253 objects = {}
7254 local chips2 = {}
7255 local positions2 = {}
7256 local rotations2 = {}
7257
7258 v = betzones[pl]
7259 objects = {}
7260 objects = v.getObjects()
7261 for j, w in ipairs (objects) do
7262 if w.tag == 'Chip' then
7263 if w.getValue() or tonumber(w.getName()) != nil then
7264 chips2[#chips2 + 1] = w
7265 end
7266 end
7267 end
7268
7269 if #chips2 ~= #chips1 then
7270 quickConvertPlayerChips = false
7271 return 1
7272 end
7273
7274 for i=0,2 do
7275 coroutine.yield(0)
7276 end
7277
7278 for i, v in ipairs (chips2) do
7279 positions2[#positions2 + 1] = v.getPosition()
7280 rotations2[#rotations2 + 1] = v.getRotation()
7281 end
7282
7283 --[[ Check chip positions --]]
7284 for i, v in ipairs(positions1) do
7285 if v.x ~= positions2[i].x or v.y ~= positions2[i].y or v.z ~= positions2[i].z then
7286 quickConvertPlayerChips = false
7287 return 1
7288 end
7289 end
7290
7291 --[[ Check chip rotations --]]
7292 for i, v in pairs(rotations1) do
7293 if v.x ~= rotations2[i].x or v.y ~= rotations2[i].y or v.z ~= rotations2[i].z then
7294 quickConvertPlayerChips = false
7295 return 1
7296 end
7297 end
7298
7299 local chips = {}
7300 local money = 0
7301 money = chipdiff + chipsout
7302 --[[ Destroy old chips --]]
7303 for i, v in ipairs (chips2) do
7304 v.destruct()
7305 end
7306
7307 for i=0,10 do
7308 coroutine.yield(0)
7309 end
7310
7311 local p = betzones[pl].getPosition()
7312 local r = betzones[pl].getRotation()
7313
7314 xoffset = -1.15
7315 zoffset = 1
7316 x = p.x + (math.cos(math.rad(r.y)) * xoffset) + (math.sin(math.rad(r.y)) * zoffset)
7317 z = p.z - (math.sin(math.rad(r.y)) * xoffset) + (math.cos(math.rad(r.y)) * zoffset)
7318 y = p.y - 10
7319
7320 pos = {x, y, z}
7321 pos.x = x
7322 pos.y = y
7323 pos.z = z
7324
7325 r.y = (r.y + 180) % 360
7326
7327 local lowStackValue = 0
7328 lowStackValue = currencies[#currencies-1].value * 10 + currencies[#currencies-2].value * 10
7329 + currencies[#currencies-3].value * 10
7330 if money <= lowStackValue then
7331 spawnChips(money, pos,r, 1)
7332 else
7333 money = money-lowStackValue
7334 spawnChips(money,pos,r,5)
7335 pos["y"] = pos["y"] + 5
7336 spawnChips(lowStackValue,pos,r,10)
7337 end
7338
7339 for i=0,10 do
7340 coroutine.yield(0)
7341 end
7342
7343 calculatePots()
7344 action(ob, pl)
7345 -- update money display
7346 if options.displayplayermoney then
7347 local chips = {}
7348 --tablezonetext[pl].setValue("$" .. getChipValues(tablezones[pl],chips))
7349 --[[ Wait five frames to allow chips to spawn before updating pot values --]]
7350 quickConvertPlayerChips = false
7351 end
7352 return 1
7353end
7354
7355--[[function onObjectEnterScriptingZone(zone, enter_object)
7356 if zone.getGUID() == '420cfb' then
7357 print('blah')
7358 end
7359end--]]
7360
7361function dealSave()
7362 --local dealbag = getObjectFromGUID('9f91d5')
7363 --dealbag.dealToColorWithOffset({0,1,9.5}, false, 'White')
7364 --dealbag.deal(1, 'Green')
7365end
7366
7367function cleanMuck()
7368 --[[if muck == nil or muck == null then
7369 muck = Global.getVar('muck')
7370 end --]]
7371 objects1 = potzones[2].getObjects()
7372 objects2 = potzones[3].getObjects()
7373 objects3 = potzones[4].getObjects()
7374 objects4 = potzones[5].getObjects()
7375 objects5 = potzones[6].getObjects()
7376 allobjects = {}
7377 local count = 0
7378
7379 for i, v in ipairs (objects1) do
7380 if v.tag == "Card" then
7381 local r = v.getRotation()
7382 --print(r.z)
7383 if r.z > 90 then
7384 count = count + 1
7385 allobjects[count] = v
7386 end
7387 elseif v.tag == "Deck" and #v.getObjects() <= 20 then
7388 count = count + 1
7389 allobjects[count] = v
7390 end
7391 end
7392 for i, v in ipairs (objects2) do
7393 if v.tag == "Card" then
7394 local r = v.getRotation()
7395 if r.z > 90 then
7396 count = count + 1
7397 allobjects[count] = v
7398 end
7399 elseif v.tag == "Deck" and #v.getObjects() <= 20 then
7400 count = count + 1
7401 allobjects[count] = v
7402 end
7403 end
7404 for i, v in ipairs (objects3) do
7405 if v.tag == "Card" then
7406 local r = v.getRotation()
7407 --print(r.z)
7408 if r.z > 90 then
7409 count = count + 1
7410 allobjects[count] = v
7411 end
7412 elseif v.tag == "Deck" and #v.getObjects() <= 20 then
7413 count = count + 1
7414 allobjects[count] = v
7415 end
7416 end
7417 for i, v in ipairs (objects4) do
7418 if v.tag == "Card" then
7419 local r = v.getRotation()
7420 if r.z > 90 then
7421 count = count + 1
7422 allobjects[count] = v
7423 end
7424 elseif v.tag == "Deck" and #v.getObjects() <= 20 then
7425 count = count + 1
7426 allobjects[count] = v
7427 end
7428 end
7429 for i, v in ipairs (objects5) do
7430 if v.tag == "Card" then
7431 local r = v.getRotation()
7432 if r.z > 90 then
7433 count = count + 1
7434 allobjects[count] = v
7435 end
7436 elseif v.tag == "Deck" and #v.getObjects() <= 20 then
7437 count = count + 1
7438 allobjects[count] = v
7439 end
7440 end
7441
7442 --local cards = Player[player].getHandObjects()
7443 local p = muck.getPosition()
7444 local r = muck.getRotation()
7445 p.y = p.y + 0.25
7446 r.x = 180
7447 r.z = 0
7448
7449 for i, v in ipairs (allobjects) do
7450 v.setRotation(r)
7451 v.setPosition(p)
7452 v.translate({0, 0.1, 0})
7453 p.y = p.y + 0.01
7454 end
7455
7456 --[[ move action to next player if action on clicker --]]
7457 --local a = Global.getVar('actionon')
7458
7459 --[[if player == a then
7460 startLuaCoroutine(self, 'delayedAction')
7461 end--]]
7462end