A couple of ASH questions

HgFalling

New member
I've started working on a few scripts in ASH and have a couple of questions about things that have come up, and whether my proposed methods of handling them are needless work.

The first thing I started working on was a not-a-pipe farming script that I could use in conjunction with regular adventuring. The idea is to constantly farm not-a-pipes while doing other things (such as powerleveling or farming something else). I had no trouble with identifying where in the absinthe cycle I was and adventuring properly at the various Wormwood locations.

However, when I tried to incorporate allowing for arbitrary adventuring, I ran into a problem with conditions. I don't have the exact script I was using at the time but the problem I was running into was that if I set conditions using cli_execute() and then adventured in a place for one adventure, if the conditions were not satisfied, the entire ASH script would halt, saying "Conditions not satisfied after 1 adventure," even if there was more script to run.

Here's some sample code that might illustrate better (reconstructed from memory, so it might have bugs, but the idea isn't that complex):

void main(int adv_ct, location otherloc, string conditions)
{
adv_ct = adv_ct - pipeadv(); //pipeadv does the right thing for the absinthe cycle and returns the number of adventures consumed while so doing

while (adv_ct > 0)
{
abs = have_effect($effect[Absinthe-Minded]);
while (abs != 9 && abs!= 5 && abs!=1)
{
cli_execute("conditions clear; conditions add " + string);
adventure(1,$location[otherloc]); //this halts if conditions aren't filled after 1 adventure.
adv_ct = adv_ct - 1;
abs = abs - 1;
}
adv_ct = adv_ct - pipeadv();
}
}

So the idea is to run this script with arguments of a number of adventures, a location, and some conditions, and stay Absinthe-Minded all the time, hitting the 9/5/1 absinthe adventures, and adventuring at otherloc until either adv_ct adventures are consumed total, or until conditions are met, and then halting. I figure that if this behavior is the way it's supposed to work, I can write a conditions parser and test the conditions myself after each adventure. This is probably more flexible but I dont want to do that if I'm just missing something obvious.

Second, something similar caused a problem for me when I tried, for example, to do the Cyrpt quest; only now it was that once I cleared the area, the script got caught in an infinite loop. This was due to somewhat lame scripting on my part, but in light of the halting when conditions weren't met above, I kind of expected the script to when it couldn't go forward in the appropriate area. What are the rules for when an ASH script will halt?

I'll have more questions as I delve...:)
 

holatuwol

Developer
An ASH script halts if there is an 'uncaught' error condition, or if KoLmafia raises a 'world peace' state. You catch an error condition by storing the result of the function call in a variable. You cannot catch an error state raised by cli_execute() as it doesn't return any values so you're going to have to use another function (maybe adventure()).
 

gadlo

New member
I am having trouble with worm wood counters aborting my .ash script. I am using a boolean variable to capture the return of an adventure call, but the counter still aborts the script. This is true for builds 6097, 6100, 6200

EDIT: sorry, that's 6102, not 6200

Here is the script:


boolean capture;
capture = adventure( 2 , $location[poop deck]);
capture = adventure( 1 , $location[windmill]);

I run the script after using absinthe so it should adventure one turn on the poop deck. The worm wood counter should fire with 9 turns of absinthe minded remaining. The "error condition" should be captured and the next call to adventure should be executed if I understand all this correctly. Instead, the script adventures one turn in the poop deck and stops with the wormwood counter expired message.

Am I doing something wrong or is something broken?

Thanks in advance
 

gadlo

New member
Commands to change the wormwood choice adventures are not working for me. I have tried cli_execute("set choiceadventure169=1") as well as the ash command set_property("choiceAdventure169","1"). Neither changes the choiceadventure and the choice remains that which has been selected in the mafia interface window. I have tried this in build 6125 and 6133.

Here is the full script:


set_property("choicadventure164","1");
set_property("choicadventure171","1");
set_property("choicadventure169","1");
cli_execute("conditions clear");
adventure( 1 , $location[windmill]);
cli_execute("conditions add 1 choiceadv");
boolean cap = adventure( 3 , $location[dome]);
int abs = have_effect($effect[Absinthe-Minded]);
cli_execute("conditions clear");
while (abs > 1)
{
adventure( 1 , $location[windmill]);
abs = abs - 1;
}
adventure( 1 , $location[mansion]);

If I set the choices in the mafia window to produce the fancy ball mask then run this script, the ball mask is still produced. Any ideas on this behavior?
 

zarqon

Well-known member
[quote author=gadlo link=topic=1583.msg8326#msg8326 date=1213486599]
set_property("choicadventure164","1");
set_property("choicadventure171","1");
set_property("choicadventure169","1");
[/quote]

You're missing some e's. Correct spelling is choiceAdventure. :)

Also, your settings file now has three new properties called "choicadventureXXX". You might want to delete them.
 
I hate it when that happens. I especially hate it when what's made real obvious in the quote happens to me!!!

[quote author=gadlo link=topic=1583.msg8326#msg8326 date=1213486599]
Commands to change the wormwood choice adventures are not working for me. I have tried cli_execute("set choiceadventure169=1") as well as the ash command set_property("choiceAdventure169","1"). Neither changes the choiceadventure and the choice remains that which has been selected in the mafia interface window. I have tried this in build 6125 and 6133.

Here is the full script:


set_property("choicadventure164","1");
set_property("choicadventure171","1");
set_property("choicadventure169","1");
cli_execute("conditions clear");
[/quote]

Here's a thread that might be of interest: http://kolmafia.us/index.php/topic,528.0.html

I looked at that code 3 times myself and missed that one.
 

gadlo

New member
Thanks for the help. I guess another thing that should be obvious is that wiriting scripts becomes much more collaborative when you are recovering from surgery and are taking vicodin. :-\
 
Top