Page 1 of 1

Request a syntax

Posted: Fri Jan 28, 2022 12:23 pm
by sdgmlj
I just started to learn how to make modules. Please help me. Thank you.
I want to get the value of one of the items in "settings. Lua". My English level is not high and I may not express clearly. The following example explains:
if 。。。。。== true then hidden_1 = false
else hidden_1 = true
end

data:extend({
{
type = "bool-setting",
name = "setting1",
setting_type = "startup",
default_value = false,
},
{
type = "bool-setting",
name = "setting2",
setting_type = "startup",
default_value = false,
hidden = hidden_1
},
})
I mean, if setting 1 is true, then setting 2 is displayed
Otherwise, setting 2 will be hidden. I don't know how to get the value of setting 1
It is unrecognizable to use "settings. Startup [" setting1 "]. Value". How can I express this variable

Re: Request a syntax

Posted: Fri Jan 28, 2022 1:37 pm
by robot256
I don't think settings can be displayed conditionally based on user selections. The settings objects don't exist until the end of the Settings phase.

During settings.lua, settings-updates.lua, and settings-final-fixes.lia, you can read the setting prototypes of your own and other mods, including whether they are hidden and their default value. For example, to hide them if another mod is installed. But you won't know what values the user selected until the data stage.

In this case, your options are to label them so it is clear when the second option is ignored by the mod; or combine them into a single string-setting with three options.

Re: Request a syntax

Posted: Sat Jan 29, 2022 3:54 am
by sdgmlj
robot256 wrote: Fri Jan 28, 2022 1:37 pm I don't think settings can be displayed conditionally based on user selections. The settings objects don't exist until the end of the Settings phase.

During settings.lua, settings-updates.lua, and settings-final-fixes.lia, you can read the setting prototypes of your own and other mods, including whether they are hidden and their default value. For example, to hide them if another mod is installed. But you won't know what values the user selected until the data stage.

In this case, your options are to label them so it is clear when the second option is ignored by the mod; or combine them into a single string-setting with three options.
Thank you. It seems that I can only solve it in other ways