json_savefile
A savefile implementation that handles all data using json. Also saves it using JSON too, fancy. If you pass in a null path, it simply acts as a memory tree instead, and cannot be saved.
Vars | |
auto_save | If this is set to true, calling set_entry or remove_entry will automatically call save(), this does not catch modifying a sub-tree, nor do I know how to do that |
---|---|
download_cooldown | Cooldown that tracks the time between attempts to download the savefile. |
Procs | |
export_json_to_client | Proc that handles generating a JSON file (prettified if 515 and over!) of a user's preferences and showing it to them. Requester is passed in to the ftp() and tgui_alert() procs, and account_name is just used to generate the filename. We don't need to pass in account_name since this is reliant on the json_savefile datum already knowing what we correspond to, but it's here to help people keep track of their stuff. |
get_entry | Gets an entry from the json tree, with an optional default value. If no key is specified it throws the entire tree at you instead |
import_byond_savefile | Traverses the entire dir tree of the given savefile and dynamically assembles the tree from it |
json_export_checks | Proc that just handles all of the checks for exporting a preferences file, returns TRUE if all checks are passed, FALSE otherwise. Just done like this to make the code in the export_json_to_client() proc a bit cleaner. |
remove_entry | Removes the given key from the tree |
set_entry | Sets an entry in the tree to the given value |
wipe | Wipes the entire tree |
Var Details
auto_save
If this is set to true, calling set_entry or remove_entry will automatically call save(), this does not catch modifying a sub-tree, nor do I know how to do that
download_cooldown
Cooldown that tracks the time between attempts to download the savefile.
Proc Details
export_json_to_client
Proc that handles generating a JSON file (prettified if 515 and over!) of a user's preferences and showing it to them. Requester is passed in to the ftp() and tgui_alert() procs, and account_name is just used to generate the filename. We don't need to pass in account_name since this is reliant on the json_savefile datum already knowing what we correspond to, but it's here to help people keep track of their stuff.
get_entry
Gets an entry from the json tree, with an optional default value. If no key is specified it throws the entire tree at you instead
import_byond_savefile
Traverses the entire dir tree of the given savefile and dynamically assembles the tree from it
json_export_checks
Proc that just handles all of the checks for exporting a preferences file, returns TRUE if all checks are passed, FALSE otherwise. Just done like this to make the code in the export_json_to_client() proc a bit cleaner.
remove_entry
Removes the given key from the tree
set_entry
Sets an entry in the tree to the given value
wipe
Wipes the entire tree