Config - lnx00/Lmaobox-Library GitHub Wiki
lnxLib.Utils.Config
Allows you to save and load options into a JSON file.
Functions
.new(name)
Creates a config instance with the given name. The name should be unique and represent your script.
Fields
.AutoSave
Set this totrue
to automatically save the config after changing a value..AutoLoad
Set this totrue
to automatically load the config before retrieving a value.
Methods
Call these methods on a config object you've created using .new(...)
!
:GetPath()
Returns the path of your config file.:Load()
(Re-)Loads the settings from the config file.:Delete()
Deletes the config file.:Save()
Saves the current setting to the config file.:SetValue(key, value)
Sets the key to the value (and saves the config).:GetValue(key, default)
Returns the value of the key (or the given default value if the key doesn't exist).
Example
...
local myConfig = Config.new("MyScript")
myConfig.AutoSave = true
local userName = myConfig:GetValue("userName", "Unknown")
local function OnCreateMove()
local me = WPlayer.GetLocal()
myConfig:SetValue("userName", me:GetName())
end
...