Page 1 of 1

How to extend another mods setting

Posted: Sat Sep 12, 2020 1:01 pm
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?

Re: How to extend another mods setting

Posted: Sat Sep 12, 2020 8:59 pm
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")