Page 1 of 1
Settings.lua dropdown example
Posted: Wed May 03, 2017 6:35 pm
by UberWaffe
Apologies if this is covered somewhere but I have not been able to find it.
Basically I just want an example of how to do a dropdown style setting. I.e. a setting where the user can only pick from a predefined list.
A list of key-value pairs would be best, but a list of strings would also suffice.
So far I have only found examples of boolean and double settings.
Re: Settings.lua dropdown example
Posted: Wed May 03, 2017 6:53 pm
by darkfrei
Re: Settings.lua dropdown example
Posted: Wed May 03, 2017 6:55 pm
by steinio
This example is from Logistic Train Network:
Code: Select all
{
type = "string-setting",
name = "ltn-interface-log-level",
order = "aa",
setting_type = "runtime-global",
default_value = "2: notifications",
allowed_values = {"0: off", "1: errors", "2: notifications", "3: expanded scheduler messages", "4: debug"}
}
Greetings, steinio.
Re: Settings.lua dropdown example
Posted: Thu May 04, 2017 1:50 pm
by UberWaffe
Awesome, thanks! These help a lot.
Re: Settings.lua dropdown example
Posted: Thu May 04, 2017 3:39 pm
by UberWaffe
http://lua-api.factorio.com/latest/LuaSettings.html does not indicate anything, but is it possible to add hover-over / help tooltips?
I.e. when the player hovers over the setting, can I display text that explains it better?
Also, even better, can I do similar help text per option in the setting dropdown?
Re: Settings.lua dropdown example
Posted: Thu May 04, 2017 5:10 pm
by Nexela
UberWaffe wrote:http://lua-api.factorio.com/latest/LuaSettings.html does not indicate anything, but is it possible to add hover-over / help tooltips?
I.e. when the player hovers over the setting, can I display text that explains it better?
Also, even better, can I do similar help text per option in the setting dropdown?
This is possible by adding it in the locale.cfg file
[mod-setting-description]
my-setting-name=What I want to say
Re: Settings.lua dropdown example
Posted: Thu May 04, 2017 8:32 pm
by UberWaffe
@Nexela: Ah, thanks! That will be perfect.
Re: Settings.lua dropdown example
Posted: Mon May 08, 2017 8:07 am
by bobingabout
I remember when I first started using it, I didn't have a clue what I was doing here.
I basically managed to piece everything I needed together from this post:
viewtopic.php?f=34&t=32890&start=40#p258222
Re: Settings.lua dropdown example
Posted: Mon May 08, 2017 3:10 pm
by Rseding91
bobingabout wrote:I remember when I first started using it, I didn't have a clue what I was doing here.
I basically managed to piece everything I needed together from this post:
viewtopic.php?f=34&t=32890&start=40#p258222
By the way, I updated the first post on that:
viewtopic.php?f=34&t=32890
Re: Settings.lua dropdown example
Posted: Tue May 09, 2017 7:56 am
by bobingabout
Rseding91 wrote:By the way, I updated the first post on that
I noticed after I posted.
It was a bit of a struggle back on day 1, I didn't even know you could use order tags, and all my settings have that un-needed per_user option because that's what all the examples I was looking at had.