Settings.lua dropdown example

Place to get help with not working mods / modding interface.
UberWaffe
Fast Inserter
Fast Inserter
Posts: 203
Joined: Mon May 04, 2015 4:53 am
Contact:

Settings.lua dropdown example

Post 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.
User avatar
steinio
Smart Inserter
Smart Inserter
Posts: 2638
Joined: Sat Mar 12, 2016 4:19 pm
Contact:

Re: Settings.lua dropdown example

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

Transport Belt Repair Man

View unread Posts
UberWaffe
Fast Inserter
Fast Inserter
Posts: 203
Joined: Mon May 04, 2015 4:53 am
Contact:

Re: Settings.lua dropdown example

Post by UberWaffe »

Awesome, thanks! These help a lot.
UberWaffe
Fast Inserter
Fast Inserter
Posts: 203
Joined: Mon May 04, 2015 4:53 am
Contact:

Re: Settings.lua dropdown example

Post 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?
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: Settings.lua dropdown example

Post 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
UberWaffe
Fast Inserter
Fast Inserter
Posts: 203
Joined: Mon May 04, 2015 4:53 am
Contact:

Re: Settings.lua dropdown example

Post by UberWaffe »

@Nexela: Ah, thanks! That will be perfect.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Settings.lua dropdown example

Post 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
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14561
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Settings.lua dropdown example

Post 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
If you want to get ahold of me I'm almost always on Discord.
User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: Settings.lua dropdown example

Post 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.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.
Post Reply

Return to “Modding help”