How do you use the TableElement?

Place to get help with not working mods / modding interface.
credomane
Filter Inserter
Filter Inserter
Posts: 321
Joined: Tue Apr 12, 2016 6:21 pm
Contact:

How do you use the TableElement?

Post 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?
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: How do you use the TableElement?

Post 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.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
credomane
Filter Inserter
Filter Inserter
Posts: 321
Joined: Tue Apr 12, 2016 6:21 pm
Contact:

Re: How do you use the TableElement?

Post 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.
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: How do you use the TableElement?

Post by Adil »

No it cannot. Actually, you can't even determine the number of columns of already existing table.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.
credomane
Filter Inserter
Filter Inserter
Posts: 321
Joined: Tue Apr 12, 2016 6:21 pm
Contact:

Re: How do you use the TableElement?

Post 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
Post Reply

Return to “Modding help”