Scrappy Settings

by Scrappy Ferret

About

Scrappy Settings is a simple settings management library for Solar2D that simplifies customisable settings.

All settings are stored in plain text in a settings.ini file in the project’s root directory, and modified ones are stored in the app’s documents directory.

API

A full API listing can be found here.

Examples

A basic settings.ini file to include in your project’s root directory.

easyModeEnabled:true,
defaultVolumeLevel:0.75,
defaultLanguage:en

Accessing some settings, changing them, and resetting back to defaults.

-- Load plugin library
require "plugin.scrappySettings"

-- Initiate the settings library
Scrappy.Settings:init()

-- Print out the default volume
print( "Default Volume:",  Scrappy.Settings:get( "defaultVolumeLevel" ) )

-- And the current volume - will be nil on first run as it's not set
print( "Current Volume:",  Scrappy.Settings:get( "currentVolumeLevel" ) )

-- Set the current level to something
Scrappy.Settings:set( "currentVolumeLevel", 0.5 )

-- And print it out again
print( "Current Volume:",  Scrappy.Settings:get( "currentVolumeLevel" ) )

-- Settings can also be strings
print( "Default Language: ", Scrappy.Settings:get( "defaultLanguage" ) )

-- As well as booleans
print( "Easy Mode Enabled: ", Scrappy.Settings:get( "easyModeEnabled" ) )

-- And you can check if a settings is set to something specific like this
print( "Current volume set to 0.5?", Scrappy.Settings:is( "currentVolumeLevel", 0.5 ) )

-- The settings will get automatically saved, but you can reset them individually like this
Scrappy.Settings:reset( "currentVolumeLevel" )

-- And print it out again
print( "Current Volume:",  Scrappy.Settings:get( "currentVolumeLevel" ) )

-- Or reset them all like this
Scrappy.Settings:reset()

Trusted vendor

Documentation

$5.00

Log in now to purchase this plugin from Scrappy Ferret.

Once you've activated this plugin, appropriate build.settings code will be generated for you to copy into your Solar2D project. Download links will also be available for inclusion into a Solar2D Native project.

Latest Solar2D contributions by Scrappy Ferret view all