load

API - Loads the .JSON file from the script folder. This can be used to have data persist between streaming sessions, or to just store script settings in a single location.

return function()
    --usually you call load at the top of a script.
    load(); --makes the data global variable exist with all previously stored/saved data.
    
    -- ---------------
    --note this is not needed in this example. it's just for show!
    local mdata = get('data'); --note this is only needed if you 
    -- are accessing the data from a subcoroutine!
    
    --if you want to save data from a subcoroutine, first make a copy like above
    --then use set('data', mdata);
    --then use save();
    -- ---------------
    
    if data.x == nil then
        data.x = 1;
    else 
        data.x = data.x + 1;
    end
    
    save(); --data gets saved in the json settings!
end

Last updated