How to extend another mods setting

Place to get help with not working mods / modding interface.
Post Reply
razahin
Inserter
Inserter
Posts: 40
Joined: Sat Feb 29, 2020 1:39 pm
Contact:

How to extend another mods setting

Post by razahin »

I'd like to hide another mods setting. I want to access the existing prototype, check for its existence, and set the hidden flag to true.

Code: Select all

if mods['pycoalprocessing'] then 
  local oreGen = table.deepcopy(data.raw['settings']['ore-gen'])
  
  oreGen.hidden = true
  
  data:extend{oreGen}
end
Variations on the above don't work because I can't find where the setting prototype lives in `data`. The following does work

Code: Select all

if mods['pycoalprocessing'] then 
  data:extend({
    {
      type = "bool-setting",
      name = "ore-gen",
      setting_type = "startup",
      default_value = false,
      order = "e",
      hidden = true,
    },
  })
end
But in this case I am completely overwriting the setting, and if it is ever removed I am actually adding the setting back in. I am doing this process in settings-updates.lua, and have been following https://wiki.factorio.com/Tutorial:Mod_settings and https://wiki.factorio.com/Tutorial:Modd ... e_creation but its not clear where the settings prototypes live.

How can I access the existing setting prototype and extend it?

User avatar
kirazy
Filter Inserter
Filter Inserter
Posts: 416
Joined: Tue Mar 06, 2018 12:18 am
Contact:

Re: How to extend another mods setting

Post by kirazy »

They live in the data table according to their type, so boolean settings are under data.raw["bool-setting"].

See below for an example.

Code: Select all

local function hide_setting(setting_type, setting_name, setting_default)
    if data.raw[setting_type] and data.raw[setting_type][setting_name] then
        data.raw[setting_type][setting_name].hidden = true
        if setting_default ~= nil then
            data.raw[setting_type][setting_name].default_value = setting_default
        end
    end
end

-- Core mods
hide_setting("bool-setting", "reskins-angels-do-angelsbioprocessing")

Post Reply

Return to “Modding help”