On this page
klaytonkowalski/library-defold-persist/persist.persist
A simple interface for saving and loading data.
- GitHub: klaytonkowalski/library-defold-persist — pinned to
2fe3aed- Pick a release from klaytonkowalski/library-defold-persist releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as persist from "persist.persist"
- Pick a release from klaytonkowalski/library-defold-persist releases and add its Source code (zip) URL (or a packaged
Functions
create(file_name: string, data: any, overwrite?: boolean)
Creates a file with the specified data. If the file already exists, then its data can be overwritten.
Parameters
file_name:stringdata:anyoverwrite?:boolean
write(file_name: string, key: string, value: any)
Writes data to a file.
Parameters
file_name:stringkey:stringvalue:any
flush(file_name: string, key?: string)
Flushes unsaved data from a file. If a key is specified, then only that field is flushed.
Parameters
file_name:stringkey?:string
save(file_name: string)
Saves data that was written to a file.
Parameters
file_name:string
load(file_name: string): {} | undefined
Loads data from a file, including data that has not yet been saved.
Returns an object, or undefined if the file does not exist.
Parameters
file_name:string
Returns
{} | undefined