# load

```lua
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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.streamavatars.com/lua-scripting-api/api-reference-and-tips/global-functions/load.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
