Module: Lich::Common::GameSettings

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

Overview

Module for managing game settings in Lich 5 Provides methods to access and modify game settings.

Examples:

Accessing a game setting

setting_value = GameSettings["setting_name"]

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object

Retrieves a scoped setting by name.

Examples:

Getting a setting value

value = GameSettings["setting_name"]

Parameters:

  • name (String)

    The name of the setting to retrieve.

Returns:

  • (Object)

    The value of the specified setting.



27
28
29
# File 'documented/common/settings/gamesettings.rb', line 27

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.

Examples:

Setting a value

GameSettings["setting_name"] = "new_value"

Parameters:

  • name (String)

    The name of the setting to set.

  • value (Object)

    The value to assign to the setting.



37
38
39
# File 'documented/common/settings/gamesettings.rb', line 37

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

.active_scopeString

Helper to get the active scope for GameSettings Assumes XMLData.game is available and provides the correct scope string. Retrieves the active scope for GameSettings. Assumes XMLData.game is available and provides the correct scope string.

Examples:

Getting the active scope

scope = GameSettings.active_scope

Returns:

  • (String)

    The active game settings scope.



18
19
20
# File 'documented/common/settings/gamesettings.rb', line 18

def self.active_scope
  XMLData.game
end

.autonil

Deprecated.

This method is not applicable and will log a deprecation warning.

Retrieves the auto setting (deprecated).

Returns:

  • (nil)


107
108
109
110
# File 'documented/common/settings/gamesettings.rb', line 107

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

.auto=(_val) ⇒ void

Deprecated.

This method is not applicable and will log a deprecation warning.

This method returns an undefined value.

Sets the auto setting (deprecated).

Parameters:

  • _val (Object)

    The value to set for the auto setting.



100
101
102
# File 'documented/common/settings/gamesettings.rb', line 100

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

.autoloadnil

Deprecated.

This method is not applicable and will log a deprecation warning.

Retrieves the autoload setting (deprecated).

Returns:

  • (nil)


115
116
117
118
# File 'documented/common/settings/gamesettings.rb', line 115

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

.clearnil

Deprecated.

This method is not applicable and will log a deprecation warning.

Clears game settings (deprecated).

Examples:

Clearing settings

GameSettings.clear

Returns:

  • (nil)


91
92
93
94
# File 'documented/common/settings/gamesettings.rb', line 91

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

.loadnil

Deprecated.

This method is not applicable and will log a deprecation warning.

deprecated Loads game settings (deprecated).

Examples:

Loading settings

GameSettings.load

Returns:

  • (nil)


61
62
63
64
# File 'documented/common/settings/gamesettings.rb', line 61

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

.savenil

Deprecated.

This method is not applicable and will log a deprecation warning.

Saves game settings (deprecated).

Examples:

Saving settings

GameSettings.save

Returns:

  • (nil)


71
72
73
74
# File 'documented/common/settings/gamesettings.rb', line 71

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

.save_allnil

Deprecated.

This method is not applicable and will log a deprecation warning.

Saves all game settings (deprecated).

Examples:

Saving all settings

GameSettings.save_all

Returns:

  • (nil)


81
82
83
84
# File 'documented/common/settings/gamesettings.rb', line 81

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

.to_hashObject

Converts the current game settings to a hash-like structure. This method does not behave like a standard Ruby hash request. It returns a root proxy for the game settings scope, allowing persistent modifications on the returned object for legacy support.

Examples:

Converting settings to hash

settings_hash = GameSettings.to_hash

Returns:

  • (Object)

    A proxy object representing the game settings.



48
49
50
51
52
53
# File 'documented/common/settings/gamesettings.rb', line 48

def self.to_hash
  # NB:  This method does not behave like a standard Ruby hash request.
  # It returns a root proxy for the game 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