Module Setting

Methods for Mod Settings.

Module Status: Work in progress.

Usage:

    local Setting = require('__eradicators-library__/erlib/factorio/Setting')()
    

Concepts

setting_type Factorio uses several different names for the setting_type of a setting.

Setting

get_value(setting_type, name) Retrieve the current value of a ModSetting.
set_value(setting_type, name) Set a new value for a ModSetting.
make(prototype) Syntactic sugar for making settings.


Concepts

setting_type

Factorio uses several different names for the setting_type of a setting.

In-Game Menu | Erlib     | settings.lua      | data.lua  | LuaSettings
---------------------------------------------------------------------
Startup      | 'startup' | 'startup'         | 'startup' | 'startup'
Map          | 'map'     | 'runtime-global'  |  -        | 'global'
Per Player   | 'player'  | 'runtime-per-user'|  -       '| 'player'

Setting

get_value(setting_type, name)
Retrieve the current value of a ModSetting.

Works in: data stage, control stage.

Parameters:

  • setting_type string, player_index or LuaPlayer The string can be either 'startup' or 'map'. Only 'startup' is valid in data stage.
  • name string Name of the setting.

Returns:

    NotNil Value of the setting.
set_value(setting_type, name)
Set a new value for a ModSetting. Works only when called from the same mod that created the setting.

Works in: control stage.

See also LuaSetting

Parameters:

  • setting_type string, player_index or LuaPlayer The string can be either 'startup' or 'map'. Only 'startup' is valid in data stage.
  • name string Name of the setting.
make(prototype)
Syntactic sugar for making settings.

Parameters:

Returns:

    table A reference to the new prototype at data.raw[type][name].

Usage:

    Setting.make {
      'mymod-my-setting-name',
      'player', 'string', 'default_value',
      'order-string-[foo]-[bar]',
      allow_blank    = false,
      allowed_values = {'default_value', 'other_value'},
      }
    
generated by LDoc 1.4.6 Last updated 2021-09-10 19:51:19