Save lua table and retrieve

I’m trying to make a plugin, and I noticed that there’s little documentation on reading files and saving custom settings? I’m trying to create a mod, but it needs to save data in case of a server restart. (Storing user stats)

you can read and write files with


-- read
local handle ="Resources/Server/myPlugin/data.json", "r")
local data = handle:read("*all")

-- write
local handle ="Resources/Server/myPlugin/data.json", "w")
handle:write("whatever data")


local json = Util.JsonEncode(yourtable)
-- and
local yourtable = Util.JsonDecode(json)

you can encode/decode your data before writing it to a file and after reading it

1 Like

Ah, seems weird for it to not be in FS as an alias, but thanks :grinning: