One JSON document per name in Data/modsdata/<name>.json, through __SFCodeObj.modStorage.
Names are 1 to 64 characters of lowercase letters, digits, ., _ or -. They start with a letter or digit, do not end with ., and the part before the first . is not a Windows device name (con, nul, com1 and so on). Documents are non-empty, valid UTF-8 JSON, at most 5 MiB.
save validates the document and queues the write on xScal's file worker; it returns true once the write is queued. The file is replaced atomically when the worker runs. While a saved document is queued or being written, load returns it from memory; otherwise load reads the file, so edits made outside the game are picked up.
Names give organization, not access control. Any SWF can read or write any name. Storage does not write to xscal.log.
Saves under the name the movie registered with register. Returns false until then.
Arguments
Name
Type
Description
name
String
Storage name. Must not end with . or be a Windows device name.
document
String
Complete JSON document as a string, valid UTF-8, at most 5 MiB.
Returns Boolean
Validates the name and the document and queues the write. Returns false for an invalid name, invalid JSON, a document over 5 MiB, or when the file worker is not running or its queue is full.
Example
data.settings.bars.health.scale = 1.25;
var saved:Boolean = __SFCodeObj.modStorage.save(
"improvedbars", JSON.stringify(data));
Loads the name the movie registered with register. Returns false until then.
Arguments
Name
Type
Description
name
String
Storage name. Must not end with . or be a Windows device name.
Returns *
String (the JSON document) or Boolean false.
Returns the stored document as a String, or Boolean false when the name is invalid or the file is missing, unreadable, invalid or over 5 MiB. Test with !== false.
Example
var stored:* = __SFCodeObj.modStorage.load("improvedbars");
if (stored !== false) {
data = JSON.parse(String(stored));
}
Storage name. Must not end with . or be a Windows device name.
Returns Boolean
Associates the calling movie with one storage name for the one-argument save and zero-argument load forms. Registration lasts for the movie session. Registering the same name again returns true; a different name returns false. The named forms do not need registration; use them when several child SWFs share one HUD movie.