[0.17.59] auto_center not available in LuaGuiElement::add()

Bugs that are actually features.
Post Reply
asdff45
Long Handed Inserter
Long Handed Inserter
Posts: 62
Joined: Sun Aug 07, 2016 1:23 pm
Contact:

[0.17.59] auto_center not available in LuaGuiElement::add()

Post by asdff45 »

auto_center does not work, when defined in LuaGuiElement::add().
When defining auto_center=true in add(), and then reading it, it is still false.

Reproduction
All executed ingame with /c

Code: Select all

local test_frame = game.player.gui.screen.add{name='test',type='frame',auto_center=true} -- new frame in the center
game.player.print(game.player.gui.screen.test.auto_center) -- prints false
game.player.gui.screen.test.add{type="label",caption="test-element"} -- set element
-- element is displayed in the top-left corner

Code: Select all

local test_frame = game.player.gui.screen.add{name='test',type='frame'}  -- new frame in the center
game.player.gui.screen.test.auto_center = true -- set auto_center external
game.player.print(game.player.gui.screen.test.auto_center) -- prints true
game.player.gui.screen.test.add{type="label",caption="test-element"} -- set element
-- element is displayed in the center
Edit:
I think i musunderstood, how the add-function works, sorry. I thought, i can define everything there, but that is not the case.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17.59] auto_center not available in LuaGuiElement::add()

Post by Rseding91 »

auto_center is only available on elements stored directly in .screen and writing to it checks that. It doesn't know if it's in screen until after it's created so I wasn't able to make it support setting it in .add().
If you want to get ahold of me I'm almost always on Discord.

Post Reply

Return to “Not a bug”