Multiple maps in one data file?

DaMaster0

Member
I have a script, and it uses a lot of different data files. I really like zarqons load_current_map() function, but I don't want to crowd his website with a bunch of different data files. ;) But I still don't want to make a lot of arrays by hand that don't update. My idea was, could I somehow put all my arrays into one data file and have my scripts filter out which map belongs to them? Any ideas/suggestions would be appreciated. Thanks!
 

Grotfang

Developer
If you use the same format for each array, then it is tricky.

For example,

string [int] map1;
map1[0] = "Hi";

string [int] map2;
map2[0] = "There";

In your data file, these will be saved as:

0 Hi

0 There

Obviously, when you do a file_to_map you only generate one map. This is how the function works. And that means only "There" will be produced. The onus is on you is to separate them. Why not have one giant array with predetermined cut offs for the maps? If you know that 0-25 is for map1, 26 - 50 map2 and so on, then simply fill them after using map_to_file. This would not handle updating nicely though.
 

Alhifar

Member
I'd have to say use something like:
Code:
string scriptname="script1"
string[string][int] map1;
map1[scriptname][0]="Hi";

string scriptname="script2";
string[string][int] map2;
map2[scriptname][0]="There"

Then your map would be something like
Code:
script1<TAB>0<TAB>Hi
script2<TAB>0<TAB>There
However, I can imagine this quickly becoming convoluted. I'd just recommend using seperate data files for each script.
 

DaMaster0

Member
Ya, if I make my map exceed 25, then it would break the script and users would have to update to a new one. (which kinda defeats the purpose) What if I make a forum post here that has all my map information, and I could parse a visit_url() to get the maps from here?
 

DaMaster0

Member
I'm having problems with it. I have this unfinished code:
Code:
boolean load_from_my_website(string datafile, string[int] map)	//not finished
{
	string domain = "http://******.webs.com/kolmafia.htm";
	string pointone = "0 Toot!1";  //for some reason the html I'm using puts the entries together, will fix that later
	string pointtwo = "Bat.4";
	string curr = visit_url(domain);
	print (curr);
	curr = excise_non_zlib(curr, pointone, pointtwo);
	print (curr);
        print ("done");
	return true;
}
At first, it prints out everything, just as it should, and then it prints out an empty line and then done. Here's half (it's really long) of the first printout:
*quests:</p><p>*<form method="post" action=""><textarea name="comments" cols="40" rows="5">0 Toot!1 Looking for a Larva in All the Wrong Places2 Ooh, I Think I Smell a Rat.3 Ooh, I Think I Smell a Bat.4 The Goblin Who Wouldn't Be King5 Trial By Friar6 Cyrptic Emanations7 Am I my Trapper's Keeper?8 A Quest, LOL9 The Rain on the Plains is Mainly Garbage10 Make War, Not... Oh, Wait11 The Final Ultimate Epic Final Conflict12 My Other Car Is Made of Meat13 Me and My Nemesis14 Out of Your Gourd15 What's Up, Doc?16 A Bugbear of a before Problem17 Suffering For His Art18 Driven Crazy19 Hammer Time20 Baker, Baker21 When Rocks Attack22 I Rate, Your Rate23 The Wizard of Ego</textarea><br><input type="submit" value="Submit"

Hmmm... When I preview my post, the asterisks before quest and <form method appear, and they weren't there when I put the code in... Strange. But since I'm working with different endpoints, they shouldn't make a difference. What's wrong??
 
Last edited:
Top