Tabletop Simulator

Tabletop Simulator

View Stats:
Enzyphilon Feb 11, 2021 @ 6:35am
Shuffle two decks of cards together
I have two decks of cards on my table.
Deck 1 is shuffled and 4 cards are dealt to each player.
This works with the script below.

Now I want to put deck 2 on deck 1 and shuffeld it.
How does it work, and what exactly do I have to insert and where?
I just don't get it.
I know that I ".putObject ()" must use, but how and where exactly?


This is my Script:

LUA – Global:
DECK1_GUID = "96212f" DECK2_GUID = "521917"
Lua – Button Object:
DECK1_GUID = Global.getVar('DECK1_GUID') DECK2_GUID = Global.getVar('DECK2_GUID') function setUpCards() local deck = getObjectFromGUID(DECK1_GUID) deck.randomize() deck.deal(4) end
UI – Button Object:
<button onClick="setUpCards" position="0 0 -30" width="650" height="200" color="rgba(220,160,140,0)"> </button>
Originally posted by Arrakeen:
Not sure if this is the best way but if you move Deck2 on top of Deck2 then they will form a single deck.

Do something like:

DECK1_GUID = Global.getVar('DECK1_GUID')
DECK2_GUID = Global.getVar('DECK2_GUID')

function setUpCards()
local deck = getObjectFromGUID(DECK1_GUID)
local deckpos = deck.getPosition()
deckpos[2] = 4

local deck2 = getObjectFromGUID(DECK2_GUID)

deck2.setPositionSmooth(deckpos, false, false)

deck.randomize()
deck.deal(4)

end

Notes:
deckpos[2] is the height above the table and this just makes sure it drops on top

Also as deck2 will take time to drop so adding a delay before shuffling and dealing might be a good idea.

Wait.time(function() deck.randomize() end, 1)
Wait.time(function() deck.deal(4) end, 1)


Phil.
< >
Showing 1-3 of 3 comments
The author of this thread has indicated that this post answers the original topic.
Arrakeen Feb 11, 2021 @ 7:10am 
Not sure if this is the best way but if you move Deck2 on top of Deck2 then they will form a single deck.

Do something like:

DECK1_GUID = Global.getVar('DECK1_GUID')
DECK2_GUID = Global.getVar('DECK2_GUID')

function setUpCards()
local deck = getObjectFromGUID(DECK1_GUID)
local deckpos = deck.getPosition()
deckpos[2] = 4

local deck2 = getObjectFromGUID(DECK2_GUID)

deck2.setPositionSmooth(deckpos, false, false)

deck.randomize()
deck.deal(4)

end

Notes:
deckpos[2] is the height above the table and this just makes sure it drops on top

Also as deck2 will take time to drop so adding a delay before shuffling and dealing might be a good idea.

Wait.time(function() deck.randomize() end, 1)
Wait.time(function() deck.deal(4) end, 1)


Phil.
Arrakeen Feb 11, 2021 @ 7:12am 
You'll get much better answers from the #scripting channel in the official TTS Discord.

https://discord.gg/ACKUVDrBsF
Enzyphilon Feb 11, 2021 @ 5:53pm 
Thank you so much for your answer.
This script works very well now.

Thank you for TTS Discord recommendation.
< >
Showing 1-3 of 3 comments
Per page: 1530 50