Tabletop Simulator

Tabletop Simulator

Not enough ratings
[Script] Area Manager
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
333.341 KB
29 Jan @ 2:25pm
18 Jul @ 12:14pm
13 Change Notes ( view )

Subscribe to download
[Script] Area Manager

In 1 collection by Ediforce44
Basic Script Components
7 items
Description
Area Manager
This mod contains the scripts and demonstrations for managing multiple areas in which objects can easily be placed.

What is an area?
An area is a 2D rectangle in the x-z-plane.
Your area is defined by the upper left corner A and the lower right corner B. Aswell as an offsetH in the horizontal direction and offsetV in the vertical direction.
A and B will mark the outlines of the area. All objects placed in this area will be placed inside of the outlines. Also the objects will be placed centered.
WARNING: Make sure A is always the upper left corner and B always the lower left corner of your area according to its rotation. The Y coordinate should be the same as the surface on which the area is located.

IMPORTANT: Please use the Area Manager function area_placeObjectOnTable(...) instead of the setPositionSmooth(...) function. It will make sure that no objects will be captured by unwanted hand zones or blocking spaces in areas, which they are crossing.
To make it even simpler you can create a Global function calling area_placeObjectOnTable(...). So you can access it more easily.

If you place an object in an already full area, an configurable Area-Full-Function is called. Normally a STM (Simply Too Much) Container/Bag will be created and every further obejct will be placed inside of it.

Standard hand zones
Standard hand zones (The first for every color) will be automatically added to the Area Manager. Their area ID followes the pattern: HAND_ZONE_....
For example the hand zone for player red has the ID: HAND_ZONE_RED



Contents
You can find two checkers (black and red), which contain the Area Manager script.
  • BLACK: This script contains the main logic for the Area Manager script. In this script you can configure and add your own areas. You will find 3 example areas. 1 normal area, 1 1D-Area and 1 snap point area.
  • RED: This script contains the code for an example use of the Area Manager and also 2 example Area-Full-Functions.



How to import the Area Manager script into your project!
  1. Save the black checker and import it into your project.



Types and Ranges of areas
Every area needs to have a area type. This type decides, how the area and its zone behave.
The NO_ZONE options for certain area types is a variant of this area type which doesn't create a zone.

Area Type
Description
NORMAL / NORMAL_NO_ZONE
This area uses offsets to calculate the spaces on which something will be placed in this area.
SNAPPOINT / SNAPPOINT_NO_ZONE
If you want to use specific positions for the spaces in your area, you can snappoints to these positions and use this area type.
HAND
These areas will create hand zones instead of scripting zones. They behave like a normal hand zone.
VIRTUAL_NO_ZONE
This area is a simple container (bag/deck/stack). This allowes the container to be used with a lot of functions from this script.
OBJECT / OBJECT_NO_ZONE
Object Areas are Snappoint Areas with snappoints attached to an object.

Area Ranges will define how the spaces in the area will be calculated.
Not every area type can be combined with every area range.

Area Range
Description
Compatible Area Types
NORMAL
If the Area Type features spaces, they will be calculated in multiple rows with multiple columns.
Every Area Type
ONE_DIMENSIONAL
The area has only one row of spaces. They are sorted horizontally.
Every Area Type except: HAND / VIRTUAL_NO_ZONE
INFINITE
Every snappoint on the table/object will be considered while determine the snappoints for this area.
SNAPPOINT_NO_ZONE / OBJECT / OBJECT_NO_ZONE

Configure your areas
There are two types how you can configure your areas:
  • You can add your areas directly to the AREA_INFO table.
  • You can call 'area_attachArea()' for every of your areas.
You don't have to do anything else to use the Area Manager.

For more details how to configure your area read the description comment in the Area Manager script and take a look at the example AREA_INFO table.

You can add an TAG to your area. If you do this, every object that will be placed inside this area will also get this tag assigned. If you call an Area Manager function to place an object inside of an area and you don't give an Area-ID to this function, the Area Manager will select an area, which has at least 1 matching tag with the object you want to place. The main purposes for area tags are the following scenarios:
  • You want to place an object inside an area but you don't always want to provide an Area-ID.
  • There are multiple areas for one specific type of object and you want to place these objects in anyone of these areas. (Everyone of these areas should have the same tag)

Rotation priority for object placing
Rotation parameter given to the placing function > Snap Point rotation > Object rotation in this area > Rotation of this area



Area Manager API
  • area_attachArea(...)
  • area_modifyArea(...)
  • area_deleteArea(...)
  • area_getAreaInfo(...)
  • area_getAreaTag(...)
  • area_getMatchingAreaId(...)
  • area_getAreaZone(...)
  • area_getAreaSpaceTable(...)
  • area_getSpacePosition(...)
  • area_getSpaceRotation(...)
  • area_getSpaceTags(...)
  • area_isAreaFull(...)
  • area_getAreaId(...)
  • area_getRCFromPosition(...)
  • area_getRCFromObject(...)
  • area_isPositionInArea(...)
  • area_getAllObjectsFromPosition(...)
  • area_getAllObjectsFromRC(...)
  • area_getAllObjectsFromArea(...)
  • area_getStmContainerFromArea(...)
  • area_blockSpace(...)
  • area_unblockSpace(...)
  • area_resetAreaSpaceTable(...)
  • area_placeObjectInArea(...)
  • area_placeMultipleObjectsInArea(...)
  • area_placeObjectInStmContainer(...)
  • area_placeObjectInContainer(...)
  • area_placeObjectOnTable(...)
  • area_restockArea(...)
  • area_eliminateGapsInArea(...)
  • area_shuffleArea(...)




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