save

API - saves the global variable: data on the main coroutine. This data can be found as a .JSON file in the script's folder.

return function()
    data = {};
    setProperty(data, 'x', 100); --set the default value to 100. If x already exists, nothing will happen!
    
    save(); --data.x gets saved as 100
    
    data.x = 300; --since we don't save after settings this, this value will be lost when loaded
    
    load(); --data.x gets reset back to 100
    
    log(data.x); --prints 100
end

You can call save() within other coroutines, but it will save the data object from the main coroutine!

Last updated