-
Notifications
You must be signed in to change notification settings - Fork 1
Data
LRE implements a way for components to holds all type of data, and to keep it between loads.
It is available for LRE sheets and LRE components with the method data
LREObject.data(name, value, persist)
Attach data to the object
LREObject.deleteData(name)
Remove the data from the object (volatile or persistent)
LREObject.hasData(name)
Return true if the object has the given named data (volatile or persistent)
There is two kind of data storage : volatile and persistent
This data are saved for each component, but are always blank at the game start (sheet initialisation). They are useful for saving script state of components (like boolean editing, saved, etc)
cmp.data('saving', true); // create or overwrite the 'saving' data to 'true'
log(cmp.data('saving')); // log "true"
cmp.deleteData('saving'); // remove this dataImportant
If there was a persistent data with the given name, it won't be persistent anymore.
This data are saved for each component and stored to be reusable event after a new game start.
if (!cmp.hasData('initiated')) {
cmp.data('initiated', false, true); // Third argument is for persistence
}
initiateComponent(cmp);
cmp.data('initiated', true, true); // create or overwrite the 'saving' data to 'true'Important
If there was a volatile data with the given name, it will now be persistent and not volatile any more.