PDA

View Full Version : Control type



Xarxus
November 4th, 2022, 10:17
Using getControls () I get a table whose elements look something like this:
{#1 = subwindow = { name = s'header', x,y,w,h = 15,23,520,0 }, #2 = genericcontrol = { name = s'contentframe', x,y,w,h = 0,0,0,0}, ... } Is there a way to know the type of each control?
I need to know if it's a subwindow, a genericcontrol or whatever. Not the name, but the type.

Trenloe
November 4th, 2022, 15:51
Use the LUA type function - this has been "Extended to cover FG Lua object types" as mentioned here: https://fantasygroundsunity.atlassian.net/wiki/spaces/FGCP/pages/996644496/Ruleset+-+Scripting#Fantasy-Grounds-Specific-Lua-Changes

Xarxus
November 4th, 2022, 22:23
I think I'm doing something wrong
for _, c in pairs(self.getControls()) do
Debug.console("TYPE ===",c, c.type, _);
end;

This is what I get
s'TYPE ===' | subwindow = { name = s'header', x,y,w,h = 15,23,460,0 } | fn | #1

Moon Wizard
November 4th, 2022, 22:28
The information displayed for custom FG data types are not actual Lua tables that you can query (even if the output mimics the output of tables).



for k, c in pairs(self.getControls()) do
Debug.console("TYPE ===", c, type(c), k);
end;


Regards,
JPG

Xarxus
November 4th, 2022, 22:31
Great!

Ty