Elite's Thread of Questions

Hey guys, got another question. I am saving data repeatedly to a file based on the results of what I am doing. However, the file does not save the information I am writing into it in a chronological fashion rather it puts the information in alphabetical order. Is there a way to make it not do this? I guess I could put a time stamp at the start of the info of H:M?

Here is what the test code looks like.
Code:
file_to_map("filename.txt", info);
info ["We got 3 A-Boo Clues in 10 adventures"] = "";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info ["I love dogs"] = "";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info ["1 I love dogs"] = "";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info ["This is a test"] = "";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info ["2 This should be last...."] = "";
map_to_file(info, "filenametxt", false);

It gives me this for the output.
Code:
1 I love dogs
2 This should be last....	
I love dogs
This is a test	
We got 3 A-Boo Clues in 10 adventures

I was hoping it would be "We got..." first and then so on as I had written it. Any Suggestions?

Edit: So after thinking more about it, as far as I know the best way would be to add something like:
Code:
file_to_map("filename.txt", info);
info [""+now_to_string("HH:mm")+" I love dogs"] = "";
map_to_file(info, "filenametxt", false);

And that would give my information a chronological ordering rather than alphabetic. I'd rather not have such information added, but I guess it isn't the worst of things =\
 
Last edited:
Or you could...

Code:
string [string] info
file_to_map("filename.txt", info);
info [now_to_string("HH:mm")] = "We got 3 A-Boo Clues in 10 adventures";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info [now_to_string("HH:mm")] = "I love dogs";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info [now_to_string("HH:mm")] = "1 I love dogs";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info [now_to_string("HH:mm")] = "This is a test";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info [now_to_string("HH:mm")] = "2 This should be last....";
map_to_file(info, "filenametxt", false);

Or if you actually wanted to make use of the blank values on each line, there is this option:

Code:
record chrono {
   string text;
   string value;
};
chrono [string] info; 

file_to_map("filename.txt", info);
info [now_to_string("HH:mm")].text = "We got 3 A-Boo Clues in 10 adventures";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info [now_to_string("HH:mm")].text = "I love dogs";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info [now_to_string("HH:mm")].text = "1 I love dogs";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info [now_to_string("HH:mm")].text = "This is a test";
map_to_file(info, "filenametxt", false);

file_to_map("filename.txt", info);
info [now_to_string("HH:mm")].text = "2 This should be last....";
map_to_file(info, "filenametxt", false);
 
The problem with keying the map by timestamp is that you'll overwrite any entry made in the same minute.
e.g. you'll just get a file which contains:
Code:
15:05	2 This should be last....

If you want stuff saved in the order you're entering it, then its probably best to just key by integer, getting the next integer by counting the map elements. (That method can break if you later remove some elements from the map.)
Code:
string [int] info;
file_to_map("filename.txt", info);
info [count(info)] = "We got 3 A-Boo Clues in 10 adventures";
map_to_file(info, "filename.txt", false);

file_to_map("filename.txt", info);
info [count(info)] = "I love dogs";
map_to_file(info, "filename.txt", false);

file_to_map("filename.txt", info);
info [count(info)] = "1 I love dogs";
map_to_file(info, "filename.txt", false);

file_to_map("filename.txt", info);
info [count(info)] = "This is a test";
map_to_file(info, "filename.txt", false);

file_to_map("filename.txt", info);
info [count(info)] = "2 This should be last....";
map_to_file(info, "filename.txt", false);

Outputs:
Code:
0	We got 3 A-Boo Clues in 10 adventures
1	I love dogs
2	1 I love dogs
3	This is a test
4	2 This should be last....
 
Hey dark, I thought about that too. Originally I was going to add in seconds too, but I think adding in just the counting ints makes it simpler. Thanks for the idea! :)
 
Question about casting Buffs, does KoLMafia automatically equip the best item to increase the buff count or do I have to do that check myself?
 
Do you still have to equip items? I thought that KoL recently changed it to use your best inventory item, regardless of what was equipped...
 
Well, within the last few months. Thought that changed around the time of the AT class revamp, or at least that's when I first remember hearing about that change.
 
OK, I think I misunderstood you. Yes, a weak equipped accordion will not override a better unequipped accordion, so there is no longer a need to UNEQUIP accordions. That was a recent-ish change.

I was confused because elite wrote: "does KoLMafia automatically equip the best item to increase the buff count or do I have to do that check myself" - and there has never been a need to EQUIP the best item - and you responded by saying "Do you still have to equip items?" - when what you probably should have said was "Do you still have to UNequip items?"

;)
 
Sorry, sometimes my clarity ends up lacking, as has been pointed out.

There has never been a reason to equip buffing items if you didn't have a weak item equipped, as KoL in recent years has used the best inventory item when no buffing item was equipped. There is no longer a reason to UNequip weaker buffing items if they happen to be equipped, which is a more recent change.

Better? :)
 
I have a question about consumption of goods. If I got to the item manager => Usable => Food it lists the best food by room (with it checked). Is there an easy ash command I can run to just have it eat the best one listed there? I know I can run eatdrink, but I ran into a compatibility issue and it does more than I want it to do.
 
It's relatively simple to iterate through all items, see which you can eat, and eat the best one you own.

here have some untested almost certainly buggy ash
Code:
record myfood {item it; float adv_per_full;};
myfood [int] myfoods;

foreach it in $items[] { 
     if ( it.fullness > 0 &&  available_amount(it)>0 && it.fullness <= fullness_limit()-my_fullness()) { 
          myfood thisfood;
          thisfood.it = it;
          string[int] range = split_string(it.adventures, "-"); 
          if (count(range)==1) thisfood.adv_per_full = to_float(range[0]);
          else thisfood.adv_per_full = (to_float(range[0])+to_float(range[1]))/2;
          myfoods[count(myfoods)]=thisfood;
     }
}
sort myfoods by 0-value.adv_per_full;
if (myfoods[0].it != $item[none]) eat(1,myfoods[0].it);
 
It's relatively simple to iterate through all items, see which you can eat, and eat the best one you own.

here have some untested almost certainly buggy ash
Code:
record myfood {item it; float adv_per_full;};
myfood [int] myfoods;

foreach it in $items[] { 
     if ( it.fullness > 0 &&  available_amount(it)>0 && it.fullness <= fullness_limit()-my_fullness()) { 
          myfood thisfood;
          thisfood.it = it;
          string[int] range = split_string(it.adventures, "-"); 
          if (count(range)==1) thisfood.adv_per_full = to_float(range[0]) / it.fullness;
          else thisfood.adv_per_full = ((to_float(range[0])+to_float(range[1])) /2) / it.fullness;
          myfoods[count(myfoods)]=thisfood;
     }
}
sort myfoods by 0-value.adv_per_full;
if (myfoods[0].it != $item[none]) eat(1,myfoods[0].it);

edit - whoops forgot to divide adventure yield by fullness

edit2 - post is not edit
 
Last edited:
Back
Top