A Steam Workshop mod that scripts The Mind (Wolfgang Warsch, 2018 Spiel des Jahres nominee) in Tabletop Simulator. Players work as a team to play cards from their hands in ascending order without communicating; a card out of order costs a life. The mod does the bookkeeping that is easy to get wrong when nobody is allowed to talk: dealing, level changes, life and shuriken tracking, and checking the discard pile.
Level changes
"Next" and "Previous" buttons advance or rewind the level deck. The top card of the deck is the current level, and the cards to its right are the level discard. When a level moves to the discard, any life or shuriken reward printed on it is flipped face up for the players; going back flips it face down again.
Dealing and resetting
"Deal" hands every seated player as many cards as the current level number and starts watching the number discard pile. "Reset" sweeps the discard pile and any loose cards back into the number deck and shuffles it, which is all you need between levels.
Catching incorrect cards
Every 30 frames the script checks whether the number discard pile is still in ascending order. If someone has played a card too early, a life card flips face down, every loose card lower than the wrongly played one is moved into the discard, and the pile is rebuilt in sorted order so the game can carry on. A play/pause button turns the checking off while you fix something by hand. When the last life goes, everyone gets told the game is lost.
-- Checks whether the numbers discard deck is in numerical order.
-- The deck will be checked every 30 frames. If it is not in order then the
-- players will lose a life automatically.
function onUpdate()
-- Check if we have waited for enough frames to do a proper check.
numberCheckCount = numberCheckCount + 1
if numberCheckCount < numberCheckTriggerCount or not playingRound then
return
end
numberCheckCount = 0
verifyNumberDiscard()
end
Shuriken votes
With a shuriken in reserve, any player can start a vote; everyone then has five seconds to press the button. If the vote passes, the lowest card in each player's hand is moved to the discard pile automatically and the pile is re-sorted. If no shuriken are left, only the player who tried is told.
How it's built
One global.lua (around 1,000 lines) plus a small global.xml for the UI. Cards are found by scripting zones and by radius searches around known positions; decks are rebuilt by taking cards out and re-creating them in order, since TTS has no sort primitive. Most of the fiddliness is in the callbacks: TTS object moves are asynchronous, so each step waits for the previous one to settle before it looks for the deck again.