Mods could associate metadata directly with a GUI element instance. This would make event handling much simpler.
For example, I could have a table like:
Code: Select all
{ mod = 'my_mod', do = 'method_name' }
In the example above, my mod would be able to instantly identify that a GUI event is related to my mod, and also what to do with it.
For better performance, maybe it would be nice to have a .mod property on gui elements - so mods can check that specific property quickly prior to accessing the .meta property (which would often contain quite a bit more data to typecast from C to Lua).
The first line in any GUI-related event handler would be:
Code: Select all
if event.element.mod ~= 'my_mod' then return end
Code: Select all
if event.mod ~= 'my_mod' then return end