Request a syntax

Place to get help with not working mods / modding interface.
sdgmlj
Fast Inserter
Fast Inserter
Posts: 174
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Request a syntax

Post 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
robot256
Smart Inserter
Smart Inserter
Posts: 1248
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Request a syntax

Post 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.
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
sdgmlj
Fast Inserter
Fast Inserter
Posts: 174
Joined: Sun Jul 04, 2021 11:12 pm
Contact:

Re: Request a syntax

Post 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
Post Reply

Return to “Modding help”