Tabletop Simulator

Tabletop Simulator

Not enough ratings
Automated Button Width Calculator script
   
Award
Favorite
Favorited
Unfavorite
Assets: Scripting
Tags: Misc
File Size
Posted
8.506 KB
2 Apr, 2018 @ 4:22am
1 Change Note ( view )

Subscribe to download
Automated Button Width Calculator script

Description
Script for generating a width for a button that dynamically matches the width of the text of the button.

To use, copy the functions "calculateButtonWidth" and "Contains" into your script.

Then, to determine the with a button should be, call:

calculateButtonWidth(font_size, text)

Example:

local width = calculateButtonWidth(400, "This is a test")

Then set your button width to the value returned.

The calculation is by no means perfect, but it produces results that are close enough for most cases.