Changing settings based on other settings (and their values)

Things that we aren't going to implement
User avatar
BraveCaperCat
Filter Inserter
Filter Inserter
Posts: 430
Joined: Mon Jan 15, 2024 10:10 pm
Contact:

Changing settings based on other settings (and their values)

Post by BraveCaperCat »

I want to be able to change a setting based on the value of another setting, or at least disable+hide different settings based on the value of a setting, like a dropdown menu selected by another dropdown menu. This would be very useful, as it allows other mods to add other things to my mod which i am making, which enables different recipes based on a setting. I then use another setting to chose which of the new recipes to unlock in control.lua, which is all implemented in the library the mod creates (it also adds some examples)
Creator of multiple mods, including Quality Assurance - My most popular one.
Go check them out with the first and second links!
I'll probably be wanting or giving help with modding most of the time I spend here on the forum.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15578
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Changing settings based on other settings (and their values)

Post by Rseding91 »

This is technically not possible. Settings defined based off the value of settings is the definition of an infinite loop. Every time it would run it could get a different result.

So sorry, but this can never be done.
If you want to get ahold of me I'm almost always on Discord.
A.Freeman
Manual Inserter
Manual Inserter
Posts: 1
Joined: Thu Nov 28, 2024 4:00 pm
Contact:

Re: Changing settings based on other settings (and their values)

Post by A.Freeman »

When I found this post I thought "okay..." and then "wait a moment, that's not true" :D So I've been thinking of writing this post for a while.
Basically, I wanted to do 2 things: a) hide settings that weren't relevant while some others were disabled (also, using this mechanism you can show/hide sets of settings like expand/collapse sections); b) use settings presets (like easy/hard, or different progressions for some parameters).
The problem with possible loops isn't really a problem. Just forbid them D For example by using order field - a setting can affect another if its order is less than the order of an affected. In that case, if you processed all settings with order less than the current, it won't be changed/affected later.
How such mechanism can work or be implemented:
  1. There will be a new field in settings "depends", that can contain one or more settings names. Their order must be striclty less than order of the current record.
  2. There will be a mechanism to register a callback function (maybe another field "update" with function for a value). When called, callback can read all settings, but will be able to update only the record it was called for. Besides, it cannot change name, settings-type, order and depends fields (and callback). And it can be registered or replaced any time during settings stages, see *.
  3. After settings-final-fixes, we iterate over all settings taking into account settings order. If setting has a registered callback, call it once. This paragraph might not be necessary as you can call callbacks directly during settings stages, see *.
  4. When player changes an option, if there are dependent options with callbacks, add them to some sort of a collection (heap, ordered map), and process them in lexicographically increasing order. If a callback changes the option, and it has dependent option(s), add them to the collection to be processed.
  • Because it's possible to change settings of other mods during settings stages, it should be possible for a mod to integrate options from several mods in one (or more) directed acyclic graph(s), so that mechanism can work on all mods at the same time and not be limited to one mod at a time. Basically, ui will use existing ordering for displaying purposes, but for settings dependencies the order field will be used globally.
So... Any thoughts?
curiosity
Filter Inserter
Filter Inserter
Posts: 637
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Changing settings based on other settings (and their values)

Post by curiosity »

A.Freeman wrote: Sat Feb 15, 2025 9:29 pm So... Any thoughts?
viewtopic.php?f=28&t=105003
Post Reply

Return to “Won't implement”