Library | Install | Documentation | Examples | Contact Information |
---|
This library allows you to save the settings of your script in the easiest way possible. This library handles converting of datatypes like Color3 into strings in the way so the table can be encoded into JSON format without any null
values.
For loading configs, the library decodes the JSON table (turns it into a Lua table) and later restores all the values by checking the signature types.
Your script executor must support the following filesystem functions in order for the library to function:
- readfile
- isfile
- writefile
- isfolder
- makefolder
Color3.fromRGB(...)
->"Color3_(...)"
Vector3.new(...)
->"Vector3_(...)"
Vector2.new(...)
->"Vector2_(...)"
CFrame.new(...)
->"CFrame_(...)"
Enum[...]
->"EnumItem_(...)"
You can load this library into your script's environment by copying the code below.
local Library = loadstring(game:HttpGet("https://github.com/raw/Exunys/Config-Library/main/Main.lua"))()
- Encodes Table to JSON format.
print(ConfigLibrary.Encode({Bool = true})) -- {"Bool":true}
- Decodes JSON Table (Content) & converts it to a Lua table.
print(ConfigLibrary.Decode([[{"Bool":true}]])[1]) -- true
- Iterates through nested / inner tables. Will pass through every value and call Callback with the parameters i (index of value) & v (value).
local TestTable = {
Bool = true,
Number = 123,
String = "Hello",
Color = Color3.fromRGB(255, 255, 255),
InnerTable = {
Color2 = Color3.fromRGB(150, 150, 150),
InnerInnerTable = {
Color3_ = Color3.fromRGB(100, 100, 100),
Vector3_ = Vector3.new(50, 200, 100),
Vector2_ = Vector2.new(10, 20),
InnerInnerInnerTable = {
Key = Enum.KeyCode.X
}
}
}
}
ConfigLibrary:Recursive(TestTable, warn)
Output:
- Edits the parsed value's type to the library's signature type.
print(ConfigLibrary.EditValue(Color3.fromRGB(50, 100, 200))) -- Color3_(50, 100, 200)
- Edits the parsed value (if the value's type is the library's signature type) to a default Luau value.
print(ConfigLibrary.RestoreValue("Color3_(50, 100, 200)")) -- 50, 100, 200 <Color3>
- Clones the parsed Table and returns the Clone.
local TestTable = {
Bool = true,
Number = 123,
String = "Hello",
Color = Color3.fromRGB(255, 255, 255),
InnerTable = {
Color2 = Color3.fromRGB(150, 150, 150),
InnerInnerTable = {
Color3_ = Color3.fromRGB(100, 100, 100),
Vector3_ = Vector3.new(50, 200, 100),
Vector2_ = Vector2.new(10, 20),
InnerInnerInnerTable = {
Key = Enum.KeyCode.X
}
}
}
}
local Clone = ConfigLibrary:CloneTable(TestTable)
print(TestTable)
print(Clone)
print(TestTable == Clone)
print(string.rep("=", 25))
ConfigLibrary:Recursive(TestTable, warn)
print(string.rep("=", 10).."Clone"..string.rep("=", 10))
ConfigLibrary:Recursive(Clone, warn)
Output:
- Edits all the values of parsed table (Data) depending on the Method.
"Edit"
method calls ConfigLibrary.EditValue function."Restore"
method calls ConfigLibrary.RestoreValue function.
local TestTable = {
Bool = true,
Number = 123,
String = "Hello",
Color = Color3.fromRGB(255, 255, 255),
InnerTable = {
Color2 = Color3.fromRGB(150, 150, 150),
InnerInnerTable = {
Color3_ = Color3.fromRGB(100, 100, 100),
Vector3_ = Vector3.new(50, 200, 100),
Vector2_ = Vector2.new(10, 20),
InnerInnerInnerTable = {
Key = Enum.KeyCode.X
}
}
}
}
ConfigLibrary:Recursive(ConfigLibrary:ConvertValues(TestTable, "Edit"), warn)
Output:
- Converts the parsed Data's values to the library's signature values and later encodes the result to a JSON table. The JSON-Encoded table later gets saved at the parsed Path. If Path doesn't exist, the library creates the path and the file with the given extension (with folders and everything).
local TestTable = {
Bool = true,
Number = 123,
String = "Hello",
Color = Color3.fromRGB(255, 255, 255),
InnerTable = {
Color2 = Color3.fromRGB(150, 150, 150),
InnerInnerTable = {
Color3_ = Color3.fromRGB(100, 100, 100),
Vector3_ = Vector3.new(50, 200, 100),
Vector2_ = Vector2.new(10, 20),
InnerInnerInnerTable = {
Key = Enum.KeyCode.X
}
}
}
}
ConfigLibrary:SaveConfig("a/b/c/d/test.json", TestTable)
- Opens the file located at Path and decodes the JSON table and restores its values to Luau format.
local TestTable = {}
TestTable = ConfigLibrary:LoadConfig("a/b/c/d/test.json")
ConfigLibrary:Recursive(TestTable, warn)
Output:
local Library = loadstring(game:HttpGet("https://github.com/raw/Exunys/Config-Library/main/Main.lua"))()
local ESP_Settings = {
TextColor = Color3.fromRGB(255, 0, 0),
Outline = true,
OutlineColor = Color3.fromRGB(0, 0, 0),
Transparency = 0.7
}
Library:SaveConfig("My Cool Hub/Config.json", ESP_Settings)
local Library = loadstring(game:HttpGet("https://github.com/raw/Exunys/Config-Library/main/Main.lua"))()
local ESP_Settings = {}
ESP_Settings = Library:LoadConfig("My Cool Hub/Config.json")
loadstring(game:HttpGet("https://github.com/raw/Exunys/Config-Library/main/Main.lua"))():SaveConfig("test.json", {b = "c", d = {e = "f", g = {h = "i", j = {"k"}}}})
->
{"b":"c","d":{"e":"f","g":{"h":"i","j":["k"]}}}