Saving data
Save stores values by name. Writing to disk is automatic, on the same frame.
Save.set("recorde", self.pontos)local recorde = Save.get("recorde", 0)
Save.set("inventario", { "espada", "escudo" })local itens = Save.get("inventario", {})Save::set("recorde", pontos);int recorde = Save::getInt("recorde");
Save::set("fases", std::vector<int>{1, 2, 5});std::vector<int> fases = Save::getInts("fases");| Function | What it does |
|---|---|
Save.set(name, value) |
Stores a number, text or true/false. Lua: tables too. C++: also a std::vector of numbers or texts. |
Save.get(name, default) |
Lua: the value as it was stored, or default. |
Save.getInt(name, default) |
The stored integer, or default. |
Save.getNumber(name, default) |
The stored number. |
Save.getBool(name, default) |
The stored true/false. |
Save.getText(name, default) |
The stored text. |
Save.has(name) |
true if there is a value with that name. |
Save.remove(name) |
Deletes a value. |
Save.clear() |
Deletes everything. |
- The file is at
%APPDATA%\Brasa\Jogos\<game name>\save.json, outside the game folder. - The game name is the one in Project settings. Changing the name starts a new file.
- C++: lists with
getInts,getNumbersandgetTexts; any JSON withsetJsonandgetJson. In C++ the functions are underSave::. - To pass values between rooms without writing to disk: Keep data between rooms.
