Tabletop Simulator

Tabletop Simulator

Not enough ratings
[Script] Ultimate Counters
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
134.239 KB
6 Jan @ 11:03am
26 Jan @ 6:53am
9 Change Notes ( view )

Subscribe to download
[Script] Ultimate Counters

In 1 collection by Ediforce44
Basic Script Components
7 items
Description
Ultimate Counters
This mod contains the scripts and demonstrations for a whole counter eco system.

There are 3 main features in this mod you can integrate into your own project.
  1. API and support for Custom Counters and their bags.
  2. Counter Zones to create Custom Counter bags on demand.
  3. API and support for Auto Counters.

1. Custom Counter
Custom Counters are unique tokens which are used to count stuff. Everytime you increase or decrease the count you add or remove one of the tokens.
You can subscribe your Custom Counter bag to the Ultimate Counter script. Then your Custom Counter bag will get a Claim button, which allows players to claim this bag. If a player has claimed a bag, he can now just ping on objects and the Custom Counters will be placed on the objects. If the player pings a card, the script recognizes Custom Counters from the same type on top of the card and will group the counters together.

The Ultimate Counter API also features functions, which will count such Custom Counters or place multiple of them at once.

2. Counter Zones
You can add scripting zones to your project and add their GUID to the Ultimate Counter script. Whenever a bag or infinite bag is droped into these zones, it will be transformed into a Custom Counter bag. So player can bring their own counter bags to the table (e.g. from community mods).

3. Auto Counters / ACs
Auto Counters are numerical counters, which have the possibility to count what ever you want without user interaction. Everything will be increased or decreased automatically if you add simple API calls to the stuff you want to count.

This mod contains an example Auto Counter bag which features two buttons. If you press one, an UI window will show up in which you can configure the Auto Counter you want to create. If you want to learn more about the UI window read the section 'Auto Counter UI Interface'.

A Auto Counter consists of 3 parts:
  1. Type: The thing the AC should count. This mod features the example 'Handcards'. But you can add what ever you want and fits for your game. For a little inspiration you can take a look at one of my projects Isaac: Four Souls XL.
  2. Range: Range of the AC. The predefined Ranges are 5 player colors. Most of the time you only need player colors as Ranges. But feel free to add custom Ranges.
    A AC only considers values counted for his configured Ranges (e.g. for the players).
  3. Mode: How the AC should count stuff. There are 3 predefined modes 'Most', 'Least' and 'Sum'. If you need it, you can add more, but it is a little bit more coding then everything else. (see Configure Auto Counters)
    Most of the Modes have a slightly different effect depending on the 'Range' of a AC.
    ACs with only one type of 'Range':
    • Most: The AC shows the highest value, which was counted since it exists.
    • Least: The AC shows the lowest value, which was counted since it exists.
    • Sum: The AC shows the current value for its 'Range'.
    ACs with more than one type of 'Range':
    • Most: The AC shows the highest value, out of all current values of its 'Ranges'.
    • Least: The AC shows the lowest value, out of all current values of its 'Ranges'.
    • Sum: The AC shows the sum of all current values of its 'Ranges'.



Auto Counter UI Interface
In the first column (Type) you can select, what the Auto Counter should count.
In the second column (Mode) you can select, how the Auto Counter should count.
In the theird column (Range) you can select, how far the range of counting from the Auto Counter reaches. If you select every Range, it is considered a 'Global Auto Counter'.

On the lower left you can see the 'Place' button. After pressing it one or more times, you can ping anywhere and the Auto Counter matching your configuration at the time you pressed the 'Place' button will be placed at the pinged position.

Next to the 'Place' button is the 'Reset' button. If you press the 'Reset' button, the counted values and Auto Counters for the currently selected Type will be reseted.
If you select the check box 'Reset all types' next to the 'Reset' button and press the 'Reset' button. Everything counted sofar and every Auto Counter will be reseted.



Contents
You can find three checkers (black, grey and white), which contain the Ultimate Counter script.
  • BLACK: This script contains the main logic for the Ultimate Counter script. In this script you can configure and add Custom Counter bags and also Auto Counters. You will find one example Custom Counter bag and one example Auto Counter bag.
  • GREY: This script contains the code to create a dynamic Counter Creation UI
  • WHITE: This script is just a demonstration of how to use the Auto Counter counting mechanism.



How to import the Ultimate Counter script into your project!
  1. Save the black checker and import it into your project.
  2. [Optional] Save the Auto Counter bag and import it into your project.
  3. If you haven't imported my Ping Event Tool from another project, go to the Global script and copy its content into your own Global script.
  4. Import the grey checker (UI Generator) to your project or copy the code marked with 'conf' into your UI Generator script, if you already imported one from my other scripts.
  5. Copy the contents of the Global XML file into the Global XML file of your own script, if you don't have Defaults with the name "modTheme" in your Global XML file.

Configure Custom Counters and bags
Every Custom Counter should has its own counter type (not the same as the AC Types).
  1. [Optional] Add all your Custom Counter TypeIDs to the 'COUNTER_TYPE' table (you can remove the 'CUSTOM_1')
  2. Every Custom Counter bag should contain a variable 'COUNTER_TYPE' with the corresponding TypeID of this Custom Counter. (Take a look at the example Custom Counter bag)
  3. Make sure your Custom Counter bag calls the 'uc_attachCounterBag()' function. (Take a look at the example Custom Counter bag)

Configure Counter Zones
All you have to do is add the GUID of the Counter Zone to the 'COUNTER_ZONES' table. The table follows the pattern: (key: PlayerColor, value: Table of Counter Zone GUIDs).

Configure Auto Counters
You can configure a lot of stuff for ACs.

Add a new Auto Counter bag:
  1. Add the variable ' COUNTER_TYPE = "NUMBER" ' to your Auto Counter bag. (Take a look at the example Auto Counter bag)
  2. Call the 'uc_attachCounterBag()' function. (Take a look at the example Auto Counter bag)

Add a new AC Type:
  1. Add the AC Type to the 'AC_COUNTER_SUBTYPE' and 'SUBTYPE_TO_NAME' table.
  2. Add the AC Type to the XML file.
  3. Call 'notify()' whenever a value of this AC type changes. (Take a look at the white checker)

Add a new AC Range:
  1. Change the 'COUNTER_RANGE' table.
  2. Add the 'Range' to the 'COUNTER_CREATION_UI_INFO' table.
  3. Add the 'Range' to the XML file.



So that's it. I hope you like it. Feel free to do what every you want with these scripts.
Please, give me some credits if you use them :D

Other Projects