Noble.Settings

Operations for game settings / stats.


Functions

Noble.Settings.setup(__keyValuePairs[, __saveToDisk=true[, __modifyExistingOnKeyChange=true]])
Sets up the settings for your game. You can only run this once, and you must run it before using other Noble.Settings functions. It is recommended to place it in your main.lua, before Noble.new().

NOTE: You will not be able to add new keys via the Noble.Settings.set method. This means you need to specify the keys and default values of all of the settings in your game at setup. If you need to add keys that are not known during setup, it is probably not a setting and you should consider using Noble.GameData instead.

Parameters

  • __keyValuePairs table
    table. Your game's settings, and thier default values, as key/value pairs. NOTE: Do not use "nil" as a value.
  • __saveToDisk boolean = true (default)
    Saves your default values immediatly to disk.
  • __modifyExistingOnKeyChange boolean = true (default)
    Updates the existing settings object on disk if you make changes to your settings keys (not values) during development or when updating your game.

Usage

Noble.Settings.setup({
	difficulty = "normal",
	music = true,
	sfx = true,
	players = 2,
	highScore = 0	-- You can store persistant stats here, too!
})
Noble.Settings.get(__settingName)
Get the value of a setting.

Parameters

  • __settingName string
    The name of the setting.

Returns

    any The value of the requested setting.

See

Noble.Settings.set(__settingName, __value[, __saveToDisk=true])
Set the value of a setting.

NOTE: If __settingName is not a key in the __keyValuePairs dictionary given to the setup method it will not be added to the Settings.

Parameters

  • __settingName string
    The name of the setting.
  • __value any
    The setting's new value
  • __saveToDisk boolean = true (default)
    Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).

See

Noble.Settings.reset(__settingName[, __saveToDisk=true])
Resets the value of a setting to its default value defined in setup().

Parameters

  • __settingName string
    The name of the setting.
  • __saveToDisk boolean = true (default)
    Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).

See

Noble.Settings.resetSome(__settingNames[, __saveToDisk=true])
Resets the value of multiple settings to thier default value defined in setup(). This is useful if you are storing persistant stats like high scores in Settings and want the player to be able to reset them seperately.

Parameters

  • __settingNames table
    The names of the settings, in an array-style table.
  • __saveToDisk boolean = true (default)
    Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).

See

Noble.Settings.resetAll([__saveToDisk=true])
Resets all settings to thier default values defined in setup().

Parameters

  • __saveToDisk boolean = true (default)
    Saves to disk immediately. Set to false if you prefer to manually save (via a confirm button, etc).

See

Noble.Settings.save()
Saves settings to disk. You don't need to call this unless you set __saveToDisk as false when setting or resetting a setting (say that five times fast!).

See

Noble Engine by Mark LaCroix, Noble Robot Documentation created using LDoc 1.5.0.