masterl / MaintenanceMadnessReloaded

Reupload/update of Maintenance Madness Factorio mod
MIT License
2 stars 0 forks source link

Remove cost_factor from lib/runtime-settings.lua #12

Open masterl opened 3 years ago

masterl commented 3 years ago

Currently we have:

mod_settings.maintenance_level = get_setting_value( 'maintenance-cost' )

-- Cost multipliers for repair material demand
mod_settings.cost_factor = {
    ['level-0'] = 0.5,
    ['level-1'] = 1.0,
    ['level-2'] = 1.5,
    ['level-3'] = 2.5
}

This table should be moved to another file (constants/defaults.lua or something else) and cost_factor should actually contain the selected cost (which is read above on the mod_settings.maintenance_level), so it would look something like this:

mod_settings.maintenance_level = get_setting_value( 'maintenance-cost' )

mod_settings.cost_factor = defaults.cost_factors[mod_settings.maintenance_level]

Note: It seems that this table is iterated over on control.lua. Not yet sure why though.

Since I'm trying to fully refactor this mod, I started from the first files that are loaded and so only now I got to touch on the old config-runtime.lua which I renamed and moved into a lib folder as lib/runtime-settings.lua. There's still control.lua and control-gui.lua to refactor, so I'll keep it as it is right now, but I think we'll need to change this.