Reputation: 21
I'm making a somewhat obscure and out-of-print game, Creatures & Cultists, available on Tabletop Simulator. The player board has various text-boxes. For two of those text-boxes, I need the text to reduce in size, when there's not enough room to display what the player types in.
I've made programs in C# and there's a built-in auto-resize feature that can be toggled on for fields like text-boxes. Does the Tabletop Simulator LUA & API allow for such a feature?
I'm using the text-box template from Mr. Stump.
Parameters for one of the text-boxes:
--name Credo
{
pos = {0.35,0.12,0.93},
rows = 1,
width = 6000,
font_size = 450,
label = "",
value = "Enter in Cult Credo Here",
alignment = 2,
rotation = {0,0,0},
height = 500,
scale = {0.1,0.0075,0.1},
},
Those parameters are passed to the create_text-box function from Mr. Stump:
function create_textboxes()
for i, data in ipairs(ref_buttonData.house_inputs) do
--Sets up reference function
local funcName = "textboxes"..i
local func = function(_,_,val,sel) click_textboxes(i,val,sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = data.label,
alignment = data.alignment,
position = data.pos,
scale = buttonScale,
width = data.width,
height = (data.font_size*data.rows)+24,
font_size = data.font_size,
color = buttonColor,
font_color = buttonFontColor,
value = data.value,
rotation = data.rotation,
height = data.height,
scale = data.scale,
})
end
end
Thanks for any help.
Upvotes: 2
Views: 911
Reputation: 71
As far as I have found, this cannot be done using the inputs created in Lua. However, this effect can be accomplished by utilizing the UI API which allows you to create elements using XML. You'll want to create something like the following:
<InputField resizeTextForBestFit="true"/>
The resizeTextForBestFit attribute can be found in the Attributes Section of the UI API.
It takes a lot of code to get things running in Tabletop Simulator so for an in depth example of this code in action, you can reference this character sheet I made using the XML solution above.
Upvotes: 0