Module: Lich::Common::GameSettings

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

Class Method Summary collapse

Class Method Details

.[](name) ⇒ OpenStruct

Retrieves a scoped setting by name from the active game settings.

Parameters:

  • name (String)

    the name of the setting to retrieve

Returns:

  • (OpenStruct)

    the value of the setting



15
16
17
# File 'documented/common/settings/gamesettings.rb', line 15

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 in the active game settings.

Parameters:

  • name (String)

    the name of the setting to set

  • value (OpenStruct)

    the value to assign to the setting



23
24
25
# File 'documented/common/settings/gamesettings.rb', line 23

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

.active_scopeOpenStruct

Returns the currently active game settings scope.

Returns:

  • (OpenStruct)

    the active game settings scope.



8
9
10
# File 'documented/common/settings/gamesettings.rb', line 8

def self.active_scope
  XMLData.game
end

.to_hashOpenStruct

Converts the current game settings into a hash-like structure.

Returns:

  • (OpenStruct)

    a hash-like representation of the game settings



30
31
32
33
34
35
# File 'documented/common/settings/gamesettings.rb', line 30

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