LuaGuiElement textfield: minimum_value and maximum_value

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 452
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

LuaGuiElement textfield: minimum_value and maximum_value

Post by raiguard »

Hello. With the new additions to the textfields (THANK YOU!!!), there are two more things missing that would complete my needs 100%, one of which is the ability to restrict a numeric textfield to a certain range.

Ideally, it would work similar to the vanilla settings GUI: inputting a number above or below the range is allowed, but when the textfield is confirmed, the value is set to whatever the last valid value was. Here is an example of what I mean, implemented through script:



(I added the red background by tinting the existing textfield active_background image)

Of course, being able to read the min and max would be nice, so I can add the red background and manipulate an adjacent slider correctly.

Thanks for your time!

Edit: In case anyone's interested, here's the style for the red background:

Code: Select all

styles['invalid_short_number_textfield'] = {
    type = 'textbox_style',
    parent = 'short_number_textfield',
    active_background = {
        base = {position={265,0}, corner_size=8, tint=warning_red_color},
        shadow = textbox_dirt
    }
}
Attachments
red background with slider.mp4
(12.21 KiB) Downloaded 53 times
Don't forget, you're here forever.

Post Reply

Return to “Modding interface requests”