Module: Lich::Common::CharSettings

Defined in:
documented/common/settings/charsettings.rb

Class Method Summary collapse

Class Method Details

.[](name) ⇒ OpenStruct

Retrieves a scoped setting by name.

Parameters:

  • name (String)

    the name of the setting to retrieve

Returns:

  • (OpenStruct)

    the value of the setting



19
20
21
# File 'documented/common/settings/charsettings.rb', line 19

def self.[](name)
  Settings.get_scoped_setting(active_scope, name)
end

.[]=(name, value) ⇒ void

This method returns an undefined value.

Sets a scoped setting by name.

Parameters:

  • name (String)

    the name of the setting to set

  • value (OpenStruct)

    the value to assign to the setting



28
29
30
# File 'documented/common/settings/charsettings.rb', line 28

def self.[]=(name, value)
  Settings.set_script_settings(active_scope, name, value)
end

.active_scopeString

Returns the active scope for character settings.

This scope is a combination of the current game and character name.

Returns:

  • (String)

    the active scope in the format "game:name"



10
11
12
13
# File 'documented/common/settings/charsettings.rb', line 10

def self.active_scope
  # Ensure XMLData.game and XMLData.name are available and up-to-date when scope is needed
  "#{XMLData.game}:#{XMLData.name}"
end

.to_hashOpenStruct

Converts the character settings to a hash-like structure.

This method returns a root proxy for the character settings scope, allowing persistent modifications on the returned object for legacy support.

Returns:

  • (OpenStruct)

    a proxy for the character settings



37
38
39
40
41
42
# File 'documented/common/settings/charsettings.rb', line 37

def self.to_hash
  # NB:  This method does not behave like a standard Ruby hash request.
  # It returns a root proxy for the character settings scope, allowing persistent
  # modifications on the returned object for legacy support.
  Settings.wrap_value_if_container(Settings.current_script_settings(active_scope), active_scope, [])
end