[Answered] How to access other mods' settings in settings.lua? (Not possible)
Posted: Mon Jul 01, 2019 4:02 pm
Hi all,
I want to read the settings values of other mods (mod A) in my new mod (mod B) settings.lua. In mod B, I want to create options based on a certain value in settings of mod A. Is there a possible way to do this?
In data.lua and control.lua, it is easy. I know the following code will work:
But when put in settings.lua, it will report error: "attempt to index global 'settings' (a nil value)", which suggests 'settings' is not created yet at settings stage.
Thanks for your attention,
Schall
Sample code to display what I want to access, if it helps explanation:
Mod A
Mod B
I want to read the settings values of other mods (mod A) in my new mod (mod B) settings.lua. In mod B, I want to create options based on a certain value in settings of mod A. Is there a possible way to do this?
In data.lua and control.lua, it is easy. I know the following code will work:
Code: Select all
settings.startup["mod-A-dummy-value-C"].value
Thanks for your attention,
Schall
Sample code to display what I want to access, if it helps explanation:
Mod A
Code: Select all
--in settings.lua:
data:extend({
{
type = "int-setting",
name = "mod-A-dummy-value-C",
setting_type = "startup",
minimum_value = 1,
default_value = 3
}
})
Code: Select all
--in settings.lua:
local valueC = settings.startup["mod-A-dummy-value-C"].value -- Does not work!
for i=1,valueC do
-- Do something fancy about options...
end