Tabletop Simulator

Tabletop Simulator

Not enough ratings
[Script] Script Collection
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
76.770 KB
8 Jan, 2024 @ 4:34am
9 Oct @ 3:36pm
7 Change Notes ( view )

Subscribe to download
[Script] Script Collection

In 1 collection by Ediforce44
Basic Script Components
7 items
Description
Script Collection
This mod contains various little scripts and demonstrations of them.

There are 2 main scripts in this mod you can integrate into your own project. All of them are located in the Global script
  1. The Color Picker script, which allows you to instruct a player to pick a color and further process his pick.
  2. The Ping Event system, which allows you to track the ping of players and furtheer process it.

This mod also contains some very helpful functions (e.g. Color API).

1. Color Picker
You can add Color Picker events to the Color Picker system and a UI window will open up. You can specifiy a 'pickerColor' in the Color Picker event. The UI window will only be visible to the player with the color 'pickerColor'. This player can then select a color, let it choose by random or chancel the pick.

The Color Picker only allows you to pick colors that are featured on your table (have Hand Zones) and also
occupied by a player. If you want the possibility to select featured colors on your table that aren't occupied by
a player, you can add zones for every player.
Therefor add a Scripting Zone for every player or use their Hand Zones (like i did here). Copy the GUID of the
zone to the 'ZONE_GUID_PLAYER' table in the Global script and add a variable to the zone of every player: active = true


Color Picker API

colorPicker_attach(params)
Adds a new Color Picker event to the queue.
You have to provide the following parameters in the params table:
  • afterPickFunction, the name of the function that is called after the matching player has picked a color.
  • pickerColor, the color of the player, who should pick the color.
  • reason, the reason why a color should be picked. It is only needed for the printed text.
  • [Optional] functionOwner, the object that holds the afterPickFunction. If you leave this parameter empty, the script things your afterPickFunction is located in the Global script.
  • [Optional] functionParams, a table of parameters that are passed to the afterPingFunction.
If everything works fine, it returns true.

colorPicker_pick(params)
You can pick a color via code.
You have to provide the following parameters in the params table:
  • pickerColor, the color of the player, who is considered as the picker.
  • [Optional] pickedValue, the color, that the player "had picked". If you leave this parameter empty, the pick is considered as canceled.

2. Ping Event system
You can add Ping Events to the Ping Event system. They consists out of several things, like a 'playerColor' of the player, whose ping should be tracked. Whenever this player will ping a 'afterPingFunction' will be called and the Ping Event will be removed.


Ping Event API

pingEvent_attach(params)
Adds a new Ping Event to the queue.
You have to provide the following parameters in the params table:
  • afterPingFunction, the name of the function that is called after the matching player has pinged.
  • playerColor, the color of the player, whose ping should be tracked for this event.
  • [Optional] functionOwner, the object that holds the afterPingFunction. If you leave this parameter empty, the script things your afterPingFunction is located in the Global script.
  • [Optional] functionParams, a table of parameters that are passed to the afterPingFunction.
The return value is a eventID, which is only importend if you want to delete this ping event before it will be executed.

pingEvent_detach(params)
Deletes a Ping Event from the queue before it can be executed.
You have to provide the following parameters in the params table:
  • eventID, the eventID that the pingEvent_attach() function returned to you.

Color API
color_getPlayerString(...)
color_getColorText(...)
color_getRandomPlayerColor(...)
color_getActivePlayerColors(...)
color_getPlayerColors(...)
color_isPlayerColorActive(...)



Contents
You can find two checkers (red and white), which contain example uses of the Color Picker and Ping Event system.
  • BLACK: This script contains the code to create a dynamic Color Picker UI
  • RED: This script contains an example use of the Color Picker.
  • WHITE: This script contains an example use of the Ping Event system. You can find a more detailed example here: [Script] Ultimate Counters.



How to import the Script Collection into your project!
  1. Copy the contents of the Global script into the Global script of your own project.
  2. Import the black 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.
  3. 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.

If you only want to import parts of this Script Collection to your project, you can do this aswell. Every part is marked in the Global script. But watch out. Some of the scripts use one or more of the provided APIs. So the easiest way is copying the part of the script you want and all APIs of the script.
For example the Ping Event system uses the Color API.



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

Other Projects