Ir para o conteúdo principal
Version: latest - a1.64.x ⚖️

Dados persistentes

Como armazenar e recuperar dados persistentes do disco usando o sistema integrado.

No mundo do nanos é possível armazenar e recuperar dados de disco com funções simples.

tip

It is possible to store Persistent Data in both Client and Server!

Formato do arquivo

The persistent data is automatically stored in the TOML format in the file PersistentData.toml inside your Package/ folder. This file is only created if you call Package.SetPersistentData().

Armazenando e Recuperando dados

All PersistentData files are loaded automatically when the Package loads and stored in memory. You can easily access the whole file with Package.GetPersistentData() method.

For storing data you will need to pass a key value, which will store any lua value in that key.

Examples

local minha_table = {
meu_id = 123,
meu_data_02 = "dadosa"
}

Pacote. etPersistentData("awesome_table", my_table)

-- PersistentData.toml será:
-- awesome_table = {my_id = 123, meu_data_02 = "data"}
local my_table = Package.GetPersistentData().awesome_table

Console.Log(my_table.my_id)

-- Will print:
-- 123