Callback

Signature

void onLoad(string filepath, table data)

Description

The callback function that is responsible for processing the data from the JSON file when save data is loaded.

Arguments

File Path

The path of the save game.

Data

The data loaded from a save game for the given identifier.

Set to nil if no data exists or if it could not be deserialized due to an error.

Example

Callback

local function onLoad(filename, data)
  if data == nil then
    return
  end

  --process data
end

event.registerLoadHandler("test", onLoad)
test.json
{
    "name1": "value1",
    "name2": [
        11,
        22,
        33
    ],
    "name3": {
        "1": "aa",
        "3": "cc",
        "nn": "bb"
    }
}

Notes

Table keys are not sorted after loading data.

Last updated