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

We are aware of them, but do not have solutions that don't cause other issues. They go here in order not to take space in the main bug thread list.
User avatar
Osmo
Filter Inserter
Filter Inserter
Posts: 257
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

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

Post 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 226 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)
Attachments
factorio-current.log
(10.32 KiB) Downloaded 14 times
Rseding91
Factorio Staff
Factorio Staff
Posts: 16662
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Osmo
Filter Inserter
Filter Inserter
Posts: 257
Joined: Wed Oct 23, 2024 12:08 pm
Contact:

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

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

Return to “Minor issues”