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

Bugs that are actually features.
Ugge
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Aug 05, 2019 8:02 pm
Contact:

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

Post 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.
Bilka
Factorio Staff
Factorio Staff
Posts: 3617
Joined: Sat Aug 13, 2016 9:20 am
Contact:

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

Post by Bilka »

It works the way the docs say. What is the bug here?
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Ugge
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Aug 05, 2019 8:02 pm
Contact:

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

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

Return to “Not a bug”