Page 1 of 1

[0.17.60] LuaGuiElement of type 'slider' property 'value' can be set on add

Posted: Sun Aug 18, 2019 10:22 am
by Ugge
When adding a gui element of type slider the property value must be set in order to have a starting value for the slider, slider_value doesnt work. But later value cannot be accessed at all. You have to use slider_value which actually has the value previously set using the property value. This is inconsistent. And the documentation is clear on the difference between value and slider_value.

I expect to always use slider_value for gui elements of type slider.

Examples:
This works:

Code: Select all

local my_slider = element.add {
    type = "slider",
    name = "output-count-slider",
    minimum_value = 1,
    maximum_value = 8,
    value_step = 1,
    discrete_slider = true,
    discrete_values = true,
    value = 4 -- I expect to use slider_value instead here.
}
But this produces an error:

Code: Select all

player.print(my_slider.value)
You have to (correctly) use:

Code: Select all

player.print(my_slider.slider_value)
Which will print 4.

Re: [0.17.60] LuaGuiElement of type 'slider' property 'value' can be set on add

Posted: Sun Aug 18, 2019 10:50 am
by Bilka
It works the way the docs say. What is the bug here?

Re: [0.17.60] LuaGuiElement of type 'slider' property 'value' can be set on add

Posted: Sun Aug 18, 2019 12:02 pm
by Ugge
The docs i was referring to was:
How much this progress bar is filled. It is a value in range [0, 1].
Can only be used if this is progressbar
https://lua-api.factorio.com/latest/Lua ... ment.value

And:
The value of this slider element.

Can only be used if this is slider
https://lua-api.factorio.com/latest/Lua ... ider_value

However I can now see that the 'add' function accepts a different data structure. I was somehow under the impression 'add' accepted a LuaGuiElement.
https://lua-api.factorio.com/latest/Lua ... lement.add

So I guess that would downgrade this from a bug to a minor cosmetic issue. I would still expect 'add' to accept 'slider_value' as the initial value. However that's not as important as the issue I initially thought existed.

Feel free to discard this issue.