Page 1 of 1

Make LuaGuiElement::name writable

Posted: Thu Oct 01, 2020 5:48 am
by raiguard
Currently, you can only read a LuaGuiElement's name. I would love to be able to modify the name as well.

The reason is that while I don't use names to match against to fire specific GUI handlers, I do use them to encode information about which button was clicked for generic handlers. For example, I could have nine similar buttons that are all displaying different LTN depots, and I want to know which one was clicked.

Storing that information in the name is a lot easier than making a thing to store it in `global` and managing it myself. But, unless I destroy and re-create the element, there's no way for me to update which depot the button is referencing, leaving storing it in global as the only option.

Thanks!

Re: Make LuaGuiElement::name writable

Posted: Tue Oct 06, 2020 9:57 pm
by eradicator
-1/+2

+2 I would also like a way to store extra data in LuaGuiElements that doesn't somehow influence how the element itself looks. Something like LuaEntity.tags. (My personal hack is to store data in invisible childrens labels.)

-1 Because you say yourself that you don't actually care about element names. You just want a more powerful hack to solve the actual problem - but you request a hack.

Re: Make LuaGuiElement::name writable

Posted: Wed Oct 07, 2020 2:04 am
by raiguard
I would be ecstatic if we could store "tags" on a GUI element. That would solve all sorts of problems that I've been using the name for.