[2.0.28] discrete steps on a modded slider don't re-gain control

This subforum contains all the issues which we already resolved.
Honktown
Smart Inserter
Smart Inserter
Posts: 1048
Joined: Thu Oct 03, 2019 7:10 am
Contact:

[2.0.28] discrete steps on a modded slider don't re-gain control

Post by Honktown »

Related thread: viewtopic.php?f=23&t=87600

A bug arises if a slider is set to be from discrete values, set to a min, min + 1 range, and then set again to a larger min/max.

The initial "Not a bug" behavior seems sensible, but the new bug is that setting it back to discrete stepping doesn't work, and save-load stability.

Example code:
Step 1:

Code: Select all

/c
local player = game.player
local gui = player.gui
local center = gui.center
if center.f then
  center.f.destroy()
  return
end
local frame = center.add{type = "frame", name = "f"}
local style = frame.style
style.height = 200
style.width = 200
local slider = frame.add{type = "slider", name = "slider", minimum_value = 1, maximum_value = 10}
Slider discretely slides as intended.
Step 2:

Code: Select all

/c
local slider = game.player.gui.center.f.children[1]
slider.set_slider_minimum_maximum(4, 5)
The slider becomes a "small step" slider. If more changes are mod without saving, there is a hidden state, visible below. If the game is saved and loaded here, the discrete value step is saved to the game probably assigned on load, as if it were set through code.

Step 3:

Code: Select all

/c
local slider = game.player.gui.center.f.children[1]
slider.set_slider_minimum_maximum(1, 10)
The slider is at small steps, which may be expected. However, this is not save-load stable, and the slider switches to discrete stepping after loading.

Optional 4:

Code: Select all

/c
local slider = game.player.gui.center.f.children[1]
slider.set_slider_discrete_values(true)
slider.set_slider_value_step(1)
When the slider is doing small-steps, it won't switch back to discrete stepping.

Documented for posterity, I am not personally affected by this.
I have mods! I guess!
Link
Rseding91
Factorio Staff
Factorio Staff
Posts: 15325
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.0.28] discrete steps on a modded slider don't re-gain control

Post by Rseding91 »

Thanks for the report. Looking into this, I believe I have it fixed however I'd like some feedback on it. With my fix it always works as if you did the "save and load" version - were the discrete steps are respected.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Resolved Problems and Bugs”