LuaGuiElement.path, the full path of a gui element
Posted: Wed Nov 15, 2017 6:37 pm
What?
The ability to get the full (absolute) path of a LuaGuiElement.Whaat?
I would like to be able to access a full list of parent element names from any given LuaGuiElement. For examble if i have a button in a table in a submenu the full path might look something like this:Code: Select all
local path = {"center","mymodname_gui_frame","submenu1_frame",1,"submenu1_table","button1"}.
Why?
On a (not so recent anymore) thread i was discussion the performance cost of checking for a LuaGuiElement's parent vs checking for a name prefix with string.sub(). For my guis so far i've often felt the need to check an elements parent or root names, but rarely (never?) needed to retrive the actual parent object.As far as i understand the internals of the C->Lua transfer of objects it would be much faster to fetch a table of strings from the api than to recurse (on the lua side) upwards through all parent objects just to fetch the name of each object. If that assumption is wrong feel free to point fingers at me and laugh :p.