Module: Lich::Common::CharSettings

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

Overview

Provides character settings management for the Lich5 project. This module allows for dynamic access and modification of character settings.

Examples:

Accessing a character setting

setting_value = CharSettings["setting_name"]

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object

Retrieves a character setting by name.

Examples:

value = CharSettings["setting_name"]

Parameters:

  • name (String)

    The name of the setting to retrieve.

Returns:

  • (Object)

    The value of the specified setting.



26
27
28
# File 'documented/common/settings/charsettings.rb', line 26

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

.[]=(name, value) ⇒ Object

Sets a character setting by name.

Examples:

CharSettings["setting_name"] = "new_value"

Parameters:

  • name (String)

    The name of the setting to set.

  • value (Object)

    The value to assign to the setting.

Returns:

  • (Object)

    The value that was set.



36
37
38
# File 'documented/common/settings/charsettings.rb', line 36

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 game and character name.

Returns:

  • (String)

    The active scope in the format “game:name”



16
17
18
19
# File 'documented/common/settings/charsettings.rb', line 16

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

.autonil

Deprecated.

This method is not in use.

Retrieves the auto setting (deprecated). This method is no longer applicable and will log a deprecation warning.

Returns:

  • (nil)

    Always returns nil.



101
102
103
104
# File 'documented/common/settings/charsettings.rb', line 101

def CharSettings.auto
  Lich.deprecated("CharSettings.auto", "not using, not applicable,", caller[0], fe_log: true)
  nil
end

.auto=(_val) ⇒ nil

Deprecated.

This method is not in use.

Sets the auto setting (deprecated). This method is no longer applicable and will log a deprecation warning.

Parameters:

  • _val (Object)

    The value to set for auto.

Returns:

  • (nil)

    Always returns nil.



93
94
95
# File 'documented/common/settings/charsettings.rb', line 93

def CharSettings.auto=(_val)
  Lich.deprecated("CharSettings.auto=(val)", "not using, not applicable,", caller[0], fe_log: true)
end

.autoloadnil

Deprecated.

This method is not in use.

Retrieves the autoload setting (deprecated). This method is no longer applicable and will log a deprecation warning.

Returns:

  • (nil)

    Always returns nil.



110
111
112
113
# File 'documented/common/settings/charsettings.rb', line 110

def CharSettings.autoload
  Lich.deprecated("CharSettings.autoload", "not using, not applicable,", caller[0], fe_log: true)
  nil
end

.clearnil

Deprecated.

This method is not in use.

Clears character settings (deprecated). This method is no longer applicable and will log a deprecation warning.

Returns:

  • (nil)

    Always returns nil.



83
84
85
86
# File 'documented/common/settings/charsettings.rb', line 83

def CharSettings.clear
  Lich.deprecated("CharSettings.clear", "not using, not applicable,", caller[0], fe_log: true)
  nil
end

.loadnil

Deprecated.

This method is not in use.

deprecated Loads character settings (deprecated). This method is no longer applicable and will log a deprecation warning.

Returns:

  • (nil)

    Always returns nil.



56
57
58
59
# File 'documented/common/settings/charsettings.rb', line 56

def CharSettings.load
  Lich.deprecated("CharSettings.load", "not using, not applicable,", caller[0], fe_log: true)
  nil
end

.savenil

Deprecated.

This method is not in use.

Saves character settings (deprecated). This method is no longer applicable and will log a deprecation warning.

Returns:

  • (nil)

    Always returns nil.



65
66
67
68
# File 'documented/common/settings/charsettings.rb', line 65

def CharSettings.save
  Lich.deprecated("CharSettings.save", "not using, not applicable,", caller[0], fe_log: true)
  nil
end

.save_allnil

Deprecated.

This method is not in use.

Saves all character settings (deprecated). This method is no longer applicable and will log a deprecation warning.

Returns:

  • (nil)

    Always returns nil.



74
75
76
77
# File 'documented/common/settings/charsettings.rb', line 74

def CharSettings.save_all
  Lich.deprecated("CharSettings.save_all", "not using, not applicable,", caller[0], fe_log: true)
  nil
end

.to_hashObject

Note:

This method does not behave like a standard Ruby hash request.

Converts the character settings to a hash-like structure. This method returns a proxy for the character settings scope, allowing for persistent modifications.

Returns:

  • (Object)

    A proxy object representing the character settings.



44
45
46
47
48
49
# File 'documented/common/settings/charsettings.rb', line 44

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