Tabletop Simulator

Tabletop Simulator

Not enough ratings
Sort Hand Tool
2
   
Award
Favorite
Favorited
Unfavorite
Type: Utility
Assets: Scripting
Tags: Tool, Sort, Sorting
File Size
Posted
Updated
80.044 KB
13 Sep, 2020 @ 8:49am
29 Apr, 2021 @ 1:46pm
13 Change Notes ( view )

Subscribe to download
Sort Hand Tool

Description

Sort Hand Tool

This tool allows any player to sort their hand easily and instantly.


Features

  • Trigger via scripting hotkey (Default: NumPad 1) or by manually clicking tile
  • Customizable sort order
  • Customizable group methods (e.g. all suits together, all numbers together, ignore suit)
  • Customizable for any type of deck (i.e. not limited to normal playing cards)
  • One tool for the entire table, or individual tools so each player can use their own preferred sort order
  • You can set up multiple sort configurations in a single tool (including for multiple deck/game types)!
  • Pre-labeled deck included



Defaults:

  • Expects a standard deck by default (don't worry, you can use this with any deck, not just normal playing cards) with the card value in the Name field (e.g. "Ace", "Two", "Three", etc...) and the suit in the Description (e.g. "Diamond", "Heart", etc...). A pre-labeled deck is included.

  • Scripting hotkey to trigger is Numpad 1

  • Sorts deck in new-deck order - all suits together, face-up order: Jokers, followed by A-K (spades, diamonds, clubs, hearts)

  • One tool works for the entire table


Customizing:

The top of the object script has all the customization settings.


There are two reference card order tables - one for values and one for suits. These represent the left-to-right order when looking at your hand of how you want the cards to be sorted.

refCardOrder:
Order of card values (as you want them to appear from left to right). These are values that would be in the card Name.

refSuitOrder:
Order of card suits (as you want them to appear left to right). These are values that would be in the card Description.


Grouping is keyed on the reference suit table, and the grouping mode is set via groupSuitMode.

0: Ignore suits (this can also be used when you're using cards that don't need a second piece of information, so the Description fields are blank)
1: All suits are together
2: All card numbers are together


Note: The suits "BW" and "Color" are used to distinguish between the two Jokers (color vs black/white).


Customization Examples:

New-Deck Order:

groupSuitMode = 1
refCardOrder = {"King", "Queen", "Jack", "Ten", "Nine", "Eight", "Seven", "Six", "Five", "Four", "Three", "Two", "Ace", "Joker", }
refSuitOrder = {"Heart", "Club", "Diamond", "Spade", "BW", "Color", }


The above settings will result in a sort that looks like this[i.imgur.com].


Ding Pai Order (i.e. Fours are high and suit order from low to high is diamonds, clubs, hearts, spades):

groupSuitMode = 2
refCardOrder = {"Joker", "Four", "Three", "Two", "Ace", "King", "Queen", "Jack", "Ten", "Nine", "Eight", "Seven", "Six", "Five", }
refSuitOrder = {"Spade", "Heart", "Club", "Diamond", "BW", "Color", }


The above settings will result in a sort that looks like this[i.imgur.com].


Non-Standard Decks:

You can customize this tool to work with any type of deck, not just normal playing cards.

Essentially, this does a two-level sort using the card Name as the main key and card Description as the grouping key.


An example is provided for Uno (covering some of the specialized editions).

groupSuitMode = 1
refCardOrder = {"Oogie Boogie", "Invisibility", "Howler", "Draw 4", "Draw 3", "Draw 2", "Wild", "Reverse", "Skip", "Nine", "Eight", "Seven", "Six", "Five", "Four", "Three", "Two", "One", "Zero", }
refSuitOrder = {"Wild", "Blue", "Green", "Red", "Yellow", }


The above settings might result in a sort that looks like this[i.imgur.com]. (Note that this only shows a partial hand, not the entire deck, due to the deck size.)


Customizing Per Player

By default, a single tool will work for the entire table.

However, you can spawn additional tools and customize them with different sort settings.


There are two ways to configure the triggering for multiple tools with different sorting options:
  1. One tool for most people to use (supports the scripting hotkey), and the exceptions trigger the minority tool(s) by clicking the tool's button.

  2. Each player gets a sorting tool. In this case, set the description of each tool with their player's color. This way, everyone can use the scripting hotkey but will only trigger their own sorting tool.


Multiple Sort Configurations

You can set up multiple sort configurations within a single tool, which can even span different deck/game types!

  1. Start by creating a different Sort Hand tool for every configuration you want.
  2. Select them all. The order of the states will be based off of the order in which they are highlighted.
  3. Right click the one you want to be the primary state and choose "Create States" from the menu.
  4. Done! Now they are all combined into a single tool with multiple states. You can switch between them either through the right-click menu or just by hovering your cursor over it and pressing the number of the state you want (e.g. "1", "2", "3", etc...)!

See the mod's screenshots for an example of what this will look like. The sample image shows a single tool made up of 4 states which I referenced earlier as sorting examples - New Deck Order, Ding Pai, Ding Pai Reversed, and Uno.


This tool has a lot of flexibility - how you use it is up to you!


p.s. If you like this mod, please give it a thumbs up!
15 Comments
TheWindMage 26 May, 2024 @ 4:44pm 
I need to group cards based on value and not suit. How can I do this?
Il-Roberto 19 Dec, 2023 @ 2:07am 
Awesome tool!
1 thumb up for you!
Xtal Lattice  [author] 27 Aug, 2023 @ 12:55pm 
@grandpixel:

This shouldn't be a problem. It should import like any object and the code should be available just like you would expect it to.

If it's not showing up properly, that sounds like a TTS bug rather than anything with this particular object.
Xtal Lattice  [author] 27 Aug, 2023 @ 12:54pm 
@Leandro_Pires:

Thank you! And no, it wasn't designed to sort all players' hands because it was intended to give individual control to each player. This way, you could have different sorting methods based in individual preferences.

But in addition to that, people will occasionally stage sets within their hands (like putting together a full house, flush, etc...) and someone else triggering a sort would ruin their work.
G R Λ N D 16 Mar, 2023 @ 12:23am 
Can you tell me, how do I import this into my own game? I load this and I see the deck and the button and it works (except for modifying the refCardOrder - doesn't work), but when I copy the deck with labels you provide, and paste into my own game, and go to the modding/scripting button, it doesn't show your script, and I can't see where to add or import one. Thanks.
Leandro_Pires 31 Dec, 2022 @ 5:04am 
Awesome tool!
Is there any way of sorting all players' hand without each player click on it? (e.g., If the host clicks, all hands are sorted).
Mindspur 19 Oct, 2022 @ 8:39pm 
@Xtal - thank you for the response - I will look to set this up and give it a try!
Xtal Lattice  [author] 10 Jul, 2022 @ 2:33pm 
@ZeekMaster, @calpoop:

You're very welcome! I'm glad you guys found this useful!
Xtal Lattice  [author] 10 Jul, 2022 @ 2:32pm 
@Tim: Yes, you can. Just use whatever is in the name field to determine your sort order in the tool's configuration.

Example:

refCardOrder = {"1", "2", "3", }
ZeekMaster 23 Jun, 2022 @ 12:49pm 
Thank you @Xtal Lattice! I've reused your code to automatically sort the train cards on entry to a player's hand in the Ticket to Ride mod I put together.