Config system

Yes, you can do that too

Basic config system

This is probably the easiest way to set up a config system.

local menu = {
    enable = pui.switch("General", "Master")
    rage = {
        switch = pui.switch("Rage", "Enable"),
    },
    visuals = {
        color = pui.color_picker("Group", "Color"),
    },
    misc = {
        combo = pui.combo("Group", "Combo", {"A", "B", "C"}),
    }
}

pui.setup(menu)

Everything's ready. Now you can save and load your configs.

Saving and loading

When you have set the config system up, you can use it easily.

pui.save(...) : table

As you can see, this function will return a table of values. This table is identical to the original table of elements.

local config = pui.save()

Done.

You may also want to serialize and encrypt it:

local encrypted = base64.encode( json.stringify(config) )

pui.load(config, ...)

There is nothing complicated as well.

local config = pui.save()
pui.load(config)

local encrypted = base64.encode( json.stringify(config) )
local decrypted = json.parse( base64.decode(encrypted) )
pui.load(decrypted)

Packages - Isolated config system

This is a much better way to use the config system in pui, as it won't be affected by other scripts and can be created multiple times.

You can create several config systems, but that is superfluous, since you can just define regions to save and load.

Creating

neverlose
local package = pui.setup(menu, true)
gamesense
local package = pui.setup(menu)

Saving and loading

config:save(...) : table

As you can see, this method will return a table of values. This table is identical to the original table of elements.

local config = pui.setup(menu)
local data = config:save()

Done.

You may also want to serialize and encrypt it:

local encrypted = base64.encode( json.stringify(data) )

config:load(data, ...)

There is nothing complicated as well.

local config = pui.setup(menu)

local data = config:save()
config:load(data)

local encrypted = base64.encode( json.stringify(data) )
local decrypted = json.parse( base64.decode(encrypted) )
config:load(decrypted)

Last updated