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

Post your bugs and problems so we can fix them.
Honktown
Smart Inserter
Smart Inserter
Posts: 1046
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
Post Reply

Return to “Bug Reports”