New setting field types in settings.lua for improved modding

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
Vas
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Tue Apr 12, 2016 11:02 pm
Contact:

New setting field types in settings.lua for improved modding

Post by Vas »

Too long don't read:
I want to see some new settings types added to the core to allow us to hide options and add new option types. Sliders for example.

Longer version:
I've been mucking about with settings.lua, and finding some limitations with it that I'd like to overcome. One issue is too many options, some mods take up 5 pages with their settings and 70% of those settings, you don't even need! I'd like that to change.

We could add something like "hiddenunless = other-option-enabled" to these settings, that allows us to enable hiding of options from the mod settings menu if they aren't needed.

Lets take an example of some code from my own mod that I'm working on but change it up to add this new setting;

Code: Select all

{
	type = "bool-setting",
	name = "basic-kit-car",
	localised_name = "Would you like a vehicle?",
	localised_description = "Would you like a vehicle?",
	setting_type = "runtime-global",
	default_value = False,
	order = 3
},
{
	type = "string-setting",
	name = "basic-kit-car2",
	hiddenunless = basic-kit-car
	localised_name = "Choose a starting vehicle.",
	localised_description = "Each vehicle also comes with a little bit of solid fuel.",
	setting_type = "runtime-global",
	default_value = "None",
	allowed_values = {"None","Car","Tank","Pending"},
	order = 5
},
{
	type = "bool-setting",
	name = "basic-kit-car3",
	hiddenunless = basic-kit-car
	localised_name = "Generic Name",
	localised_description = "Generic Description",
	setting_type = "runtime-global",
	default_value = False,
	order = 6
},
Now, when I enable basic-kit-car, it displays these two new options below it, so you can choose your vehicle, and enable yet another hidden group of options, should I want to add more (I mearly did the generic name option as an example of cascading options).

In the example of the Ore Chaos mod, this would enable us to hide useless elements we don't need. In my case I only use one set of options on it, and it adds 4 major chunks of options that take up way too much space. It could cascade each one under the previous option. All defaulting to their values, till the user checkboxes "Do you need more settings?". Imagine how convenient that would be? How much cleaner, it would make the mod settings screens?

I don't know if this will be done though, because I'm not sure if the mod settings screen would be able to run something like this. However there is one more setting I'd like to see for some improved easier altering of integers, doubles, floats, and such.

Code: Select all

	{
		-- Start with landfill
		type = "int-slider-setting",
		name = "basic-kit-perfectionist",
		localised_name = "Perfectionist",
		localised_description = "Are you a man who dislikes water where you don't want it? Did you decide to bring some landfill with you to handle messy water ways?",
		setting_type = "runtime-global",
		default_value = 0,
		maximum_value = 1000,
		minimum_value = 0,
		order = 6
	},
Simple right? Instead of an input box, it would show a slider between the minimum and maximum values. Allowing the player to drag the slider between the two points to choose an amount, fine tuning by clicking on the slider and using arrow keys to move one at a time, shift arrow to move 5 at a time.
Basically all the types that could use a slider would allow a slider should "slider" be added to the type. Even Boolean could technically support a slider, though wildly un-nessicary because its only two options.

While I was here though, I came to a final thought about possible settings. A multiple choice type. type = "multiplechoice-setting", which would look something like;

Code: Select all

{
	type = "multiplechoice-setting",
	name = "basic-kit-car",
	localised_name = "Pick your vehicle options",
	localised_description = "Each vehicle also comes with a little bit of solid fuel.",
	setting_type = "runtime-global",
	default_values = {1,0,1,0,0},
	options_values = {"Car","Tank","5 Fuel","Ammunition","Tank Weapons & Ammo"},
	order = 5
},
In this case, you have 5 checkboxes in a row, with the first and 3rd default checked giving you a car, and 5 fuel. I'd say multiple choice should probably max at 5 values, due to the space limitations of the UI, but thats just my thoughts on it.

[hr]

I love settings, they are good to have because it lets players choose the way they wish to play. No one likes to be told how to play the game, they like to play the way they want. Everyone has their own style, and options give us the way to set it the way we like. The current settings screen is flooded though with all the mods I have and many people use lots of mods, some big mods have tons of settings in them. A way to compact those down to simplify it for us a bit, would be great. Giving modders better control over what users see, allowing us to hide advanced options from users who don't want to be confused with advanced settings. Sliders to give users that may not know what they should type in so they can simple pick a number between two points and visually see the min/max value. The last idea, was just a way to compact a few more things. Obviously, these are just suggestions on settings types. Its still up to the modder, to write the control.lua and other scripts around these options to make them all work.

There is, one more thought I have though before I conclude this post. If you want an alternate way to clean up the mod menu screen, I'd suggest adding sub categories that modders can control. So modders who choose to leave the category unspecified will ahve their options default to Main, while a mod like Ore Chaos can specify "Ore Chaos" as a category for all of his options would enable a new tab for his options under the primary tab its associated with. Enjoy this crappy image I made to show what I mean.
Image
You can get my mods by clicking here, and use discussions there or PMs here to suggest or report issues.
Want some blueprints made by me? Click here then!

User avatar
bobingabout
Smart Inserter
Smart Inserter
Posts: 7352
Joined: Fri May 09, 2014 1:01 pm
Contact:

Re: New setting field types in settings.lua for improved modding

Post by bobingabout »

I must admit, it would be nice to be able to have tabs inside those tabs for specific mods.
Some of my mods have enough options to fill the settings window by themselves.
If you have all of my mods installed, the list is pretty massive.

I personally would like to see that when you select the Startup tab for example, instead of just seeing a 5 page screen scrollbar of options, that each mod has a button, or tab to select it, and then you only see that one window's worth of settings for that particular mod.

And yes, a slider bar would be nice too.
Creator of Bob's mods. Expanding your gameplay since version 0.9.8.
I also have a Patreon.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: New setting field types in settings.lua for improved modding

Post by eradicator »

Imho the only way to make the mod settings menu work with mods that have lots of options is to completely restructure the menu. This also includes enlarging the window to get more screen space to show settings. There should be a list of mods that add settings (mods without settings are hidden) on the left like in the mod installation menu. Then on the right side you have a page with tabs. Every tab is custom defined by each mod (this requires adding a mandatory "category=" field to all settings [or adding everything without a category to a "default" tab]), and then only within those tabs should there be the old scrollable list of settings. Subdivided by global/map/player headings.

Here's a quick mockup:
mod_menu.png
mod_menu.png (74.94 KiB) Viewed 1425 times
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Vas
Long Handed Inserter
Long Handed Inserter
Posts: 91
Joined: Tue Apr 12, 2016 11:02 pm
Contact:

Re: New setting field types in settings.lua for improved modding

Post by Vas »

"Global Settings" is inaccurate its "Startup", which is why it requires a restart, that would make more sense. Just saying.

Adding the hide-this-setting method I gave should suffice for now if they don't want to go for a total re-write and redo all the UI. I was trying to give the most basic settings suggestion I could, just a few options to hide elements within the settings unless another setting = true.

With your example, it should have the Weapons Tab, named "Main" instead. For people who forget to add a category to their settings so that all categoryless settings default to that tab. Then you can add tabs after that.

Perhaps it also doesn't just have to be "Mod Name" either, in your list. For example Bob has his mods all split up to be modular. So he could in essence, create a Mod called "Bobs Mods" that will always load before his mods, simply a name mod that will create the entry in the list, then he can add something to his settings.lua in all of them to have all of his mods combined under that one mod's tab, with the sub tabs being for each of his mods.
You can get my mods by clicking here, and use discussions there or PMs here to suggest or report issues.
Want some blueprints made by me? Click here then!

Post Reply

Return to “Modding interface requests”