Persistence across sessions

lackita

New member
I have a couple ideas for scripts, but they require information stored in one kolmafia session to be available in subsequent sessions. My first idea was file I/O, but I couldn't find anything about that on the wiki. Did I miss something? Is there another mechanism for storing data?
 

lostcalpolydude

Developer
Staff member
In a script, you can use set_property( name, value ) to save it, and get_property( name ) to retrieve it. If the setting name starts with _ it will reset at rollover.
 

fronobulax

Developer
Staff member
As noted, for small amounts of data setting and reading a preference (or a zlib variable) will work. For large amounts of data I try and represent them in the script as a map and then use file_to_map and the corresponding map_to_file for IO.
 

ckb

Minion
Staff member
Also, you can create data in a map and use map_to_file() to save it (to the /data folder usually) and file_to_map() to load it.

Finally, you can set and save variables with zlib, which will write and read to a special vars_username.txt data file.

Edit: And... ninja
 
Top