[Rseding91] Missing doc: return value of LuaGuiElement::add

This subforum contains all the issues which we already resolved.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1197
Joined: Wed May 18, 2016 4:55 pm
Contact:

[Rseding91] Missing doc: return value of LuaGuiElement::add

Post by Mooncat »

After a long struggle and then a sudden curiosity, I realized that
LuaGuiElement::add actually returns the added GUI element!

So, instead of doing something like

Code: Select all

frame.add{type = "table", name = "my_table", colspan = 10}
local my_table = frame["my_table"]
my_table.add{.......}
you can do it like this:

Code: Select all

local my_table = frame.add{type = "table", name = "my_table", colspan = 10}
my_table.add{.......}
It is a huge difference if you are adding many GUI elements.
Some of you may have already known this, but this deserves to be on the document. :P
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Missing doc: return value of LuaGuiElement::add

Post by Nexela »

When you sent me over the message GUI I wondered why you didn't do that :)
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1197
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: Missing doc: return value of LuaGuiElement::add

Post by Mooncat »

Because the doc didn't say it has a return value.

Image

edit: and I just realized the name property is optional. :| Nah, I still name every single element anyway.
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Missing doc: return value of LuaGuiElement::add

Post by Nexela »

Well....
Attachments
maxresdefault.jpg
maxresdefault.jpg (9.14 KiB) Viewed 1571 times
Rseding91
Factorio Staff
Factorio Staff
Posts: 14913
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [Rseding91] Missing doc: return value of LuaGuiElement::add

Post by Rseding91 »

Fixed the docs for 0.14.4.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1197
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [Rseding91] Missing doc: return value of LuaGuiElement::add

Post by Mooncat »

Thanks :lol:
Post Reply

Return to “Resolved Problems and Bugs”