File to map
boolean file_to_map( string file_name , aggregate map )
boolean file_to_map( string file_name , aggregate map , boolean condition_for_loading )
Loads a map from a saved file, and returns a boolean of the operation's success. While all that is required to run it is the saved file's name, and a compatible map, it can also contain a conditional that must evaluate as true to execute the file-map load.
For example:
#Loading (and displaying) an arbitrary map from a file string[int] favorite_things; boolean load_success = file_to_map( "ponies_and_candycanes.txt" , favorite_things ); if( load_success == true ) { print( "All of your favorite things have come here to KoLMafia to play! Yay! There's:" , "#FF6666" ); for cycle from 1 upto (count(favorite_things)-1) { print( ""+favorite_things[cycle]+", and..." , "#FF00CC" ); } print( ""+favorite_things[count(favorite_things)]+", oh my!" , "#FF00CC" ); } else { print( "Your favorite things failed to load. Apparently they don't love you back." , "Red" ); }
With the saved file "ponies_and_candycanes.txt" being:
1 Sunshine 2 Cabbage 3 Computers 4 The Sound of Music 5 Paddington Bear
Would yield an output of:
All of your favorite things have come here to KoLMafia to play! Yay! There's: Sunshine, and... Cabbage, and... Computers, and... The Sound of Music, and... Paddington Bear, oh my!