Page 1 of 1

[2.0.76] line gui element stretchability doesn't persist across save-load cycle

Posted: Tue Mar 17, 2026 12:35 pm
by Osmo
Creating a new line gui element for some reason sets horizontally_stretchable on its style to true. This is probably relevant, though technically not a bug, but i don't see a good reason why this isn't just a property on the default style instead of what seems like an in-engine exception, given it also cannot be read from the LuaStyle.
Line with no style properties changed
Line with no style properties changed
изображение.png (391.36 KiB) Viewed 229 times
If horizontally_stretchable is set to false by a mod, the element correctly becomes not stretchable. Writing nil later (importantly, needs to be at a different time) doesn't restore it back to stretchable since this is not what its LuaStyle nor style specification says it should do. The observed result is that the line has a width of 0 and cannot be seen.

Create a new world with the code below in control.lua to see this behaviour.
If the game is then saved, exited and loaded again, the line becomes stretchable and can be seen, which is incorrect.

Code: Select all

script.on_event(defines.events.on_player_created, function(event)
    storage.player_index = event.player_index
    local player = game.get_player(event.player_index)
    local frame = player.gui.screen.add{
        type = "frame", name = "frame",
        style = "inside_shallow_frame_with_padding",
    }
    frame.auto_center = true
    frame.style.width = 448
    frame.style.height = 200
    local flow = frame.add{type = "flow", name = "flow", direction = "vertical"}
    flow.style.vertical_spacing = 8
    flow.add{type = "button"}
    local line = flow.add{type = "line", name = "line"}
    game.print(line.style.horizontally_stretchable) -- prints nil
    line.style.horizontally_stretchable = false
end)

script.on_event(defines.events.on_tick, function(event)
    if event.tick == 2 then
        local player = game.get_player(storage.player_index)
        local line = player.gui.screen.frame.flow.line
        line.style.horizontally_stretchable = nil
    end
end)

Re: [2.0.76] line gui element stretchability doesn't persist across save-load cycle

Posted: Wed Mar 18, 2026 10:24 pm
by Rseding91
Thanks for the report. Looking into this: if I wanted to implement a fix it would require removing the current "line" type and style and adding "horizontal_line" and "vertical_line" types and styles. That doesn't seem worth it at the moment. I believe - you can simply write = true/false to get the effect you want (don't stretch) rather than relying on the default styles.

Re: [2.0.76] line gui element stretchability doesn't persist across save-load cycle

Posted: Thu Mar 19, 2026 5:37 am
by Osmo
That makes sense. For my usecase it matters to be able to read default value, but i'll hack my way around that