What was YOUR last encounter?

Fluxxdog

Active member
KoLmafia has a function that returns the last monster you fought, namely last_monster(). However, I can't find anything that would return your last encounter, such as a choice adventure or other non-combat. Any insights? Am I overlooking something?
 

StDoodle

Minion
On a related note, is there any easy way I'm just missing to convert the results of that property to the choice adventure number, if applicable? By "easy" I mean "not involving building up a massive array in-script?"
 

Camber

Member
-.- I really gotta check the properties more often. Thanks ^^

JasonHarper has a handy alias for reference checking:


alias prefref => ash record r{string d;}; r[string,string]m; file_to_map("defaults.txt",m); foreach t,p,d in m if(to_lower_case(p).contains_text(to_lower_case($string[%%]))) print(p+" ("+t+", now '"+get_property(p)+"', default "+d.d+")")
 

heeheehee

Developer
Staff member
StD -- I suppose hitting the KoLwiki with
Code:
int choiceAdvNumber = -1;
matcher m = create_matcher("Choice adventure number</a>: </b>(\\d+)", visit_url("http://kol.coldfront.net/thekolwiki/index.php/"+get_property("lastEncounter")));
if(m.find()) choiceAdvNumber = m.group(1).to_int();
should do the trick. Not entirely sure that it'll work with any degree of accuracy, of course.
 

StDoodle

Minion
Hmm.. with as often as the wiki goes down, that doesn't seem like a good idea. However, it could be helpful in generating a data file to read from.
 

Bale

Minion
Is there a particular reason to convert adventure name to choice adventure number? The only time you'd need the number is if you were deciding which choice to pick. However, by the time you get the lastAdventure property, the choice has already been selected so the number doesn't matter. Am I missing something?
 

StDoodle

Minion
This was actually a thought that occurred to me while working on the combat button thingie, before realizing that you could just use "auto." Which could be useful for weird edge cases like the fantasy airship combat / chest / stats adv; you'd rather have the combat if you don't yet have a metallic A and have enough ML for the mech, otherwise you'd rather have stats, UNLESS you have around 80 or more ML, in which case you want the combat again; such things could be easier to handle via a script while adventuring. But I guess for such situations you'd just hardcode the few that would need checking, and use "auto" for the rest.
 

Bale

Minion
You've puzzled me again. What exactly do you mean by using "auto"? Is this something scriptable?

I just set those choiceAdventure### values before the adventure comes up. I never need to do anything in media res. zarqon's BBB is a good example of how I do that and it even uses my logic for that particular example.
 

Theraze

Active member
Using Auto would be combining the relay browser and the ChoiceAdventure settings from the GUI. You click the auto button, the relay browser follows your selected option and you don't need to remember which choice you want. It's basically the "I want to manually combat (not using a CCS) but not think about choice adventures" way to play. :)
 

Bale

Minion
Oh right. He was trying to script the auto button. I got it now. By auto he meant choice.php?action=auto. No need to explain further StDoodle.
 

Fluxxdog

Active member
JasonHarper has a handy alias for reference checking:


alias prefref => ash record r{string d;}; r[string,string]m; file_to_map("defaults.txt",m); foreach t,p,d in m if(to_lower_case(p).contains_text(to_lower_case($string[%%]))) print(p+" ("+t+", now '"+get_property(p)+"', default "+d.d+")")

I have that alias, and it is handy, I just didn't think to check it first ^^ Since we're on the topic now, any idea how that could be adapted for your own personal setting? my_name()+"_prefs.txt"? I'm have trouble wrapping my head around it. There are setttings used by scripts that jut won't show up with prefref unless they came prepackaged with mafia.

Edit: While I'm thinking of it also, can file_to_map and map_to_file search directories within the data directory? Say, for example, I want to store a bunch of data files in the "separate" sub-folder. Can I use file_to_map("separate/whatever.txt",foobar);?
 
Last edited:

StDoodle

Minion
Fluxxdog; you can store them that way, but if you plan on updating them in the script with map_to_file() they'll end up back in the top-level.
 
Top