Page 1 of 1

How do you use the TableElement?

Posted: Mon Jul 18, 2016 4:48 pm
by credomane
So I create a TableElement.

Code: Select all

game.player.gui.top.add{name="foo", type="table", colspan=3}
Now what? I can't find anything in lua-docs.factorio.com on how to manipulate the table.

How do I put stuff in specific columns/rows?
How do I even add rows?


Then a generic question about all elements. Is there an alignment option? Say to align a flow/button/whatever to the center (or to the right side) of parent element rather than the default of always on left side?

Re: How do you use the TableElement?

Posted: Mon Jul 18, 2016 6:06 pm
by Adil
You just add elements to the table, as in

Code: Select all

t= game.player.gui.top.add{name="foo", type="table", colspan=3}
t.add{name='bar',type='button',caption='foo'}
--or
--game.player.gui.top.foo.add{name='bar',type='button',caption='foo'}
It will keep adding elements to a single row up to a cospan, so the fourth addition to the table will go to the second row first column.

I believe you can have a look at `style` definition its not that detailed, bit probably `padding` attribute is relevant here.

Re: How do you use the TableElement?

Posted: Mon Jul 18, 2016 7:10 pm
by credomane
Ah. I was starting to wonder if that was how it worked. Thanks.

Can the colspan be changed dynamically? I have no need for it but want to know out of curiosity.

Re: How do you use the TableElement?

Posted: Tue Jul 19, 2016 8:34 pm
by Adil
No it cannot. Actually, you can't even determine the number of columns of already existing table.

Re: How do you use the TableElement?

Posted: Tue Jul 19, 2016 9:29 pm
by credomane
So I have noticed.

Some of the Factorio API is really confusing. This being one of them. Having a single "LuaEntity" for all entities and a single "LuaGuiElement" for all elements plus what you can do with each is different depending on what specific "LuaEntity" or "LuaGuiElement" type is is maddening. :/

I'd make a feature request but my request is already in the frequently requested feature forum. lol