Newbie Adventuring Question (stop on conditions)

Glazius

Member
So, getting my feet wet with ASH scripting, I made the attached script to automate a fun thing I was doing - adventuring with my stocking mimic until it dropped a particular kind of candy, eating that candy, and continuing on adventuring.

I originally just used while (adventure(advs, place)) to adventure with, but apparently adventure returns false if you meet, say, an item condition.

I had no idea what to search for, and the reference wiki isn't much help, so (assuming one exists) can someone point me to a list of things that make adventure exit and whether it returns true or false because of them?

If there isn't such a list, can someone explain the difference between adventure() returning true and returning false?
 

Attachments

  • iwantcandy.ash
    1.5 KB · Views: 27
Last edited:

Bale

Minion
A long time ago I accepted that the various functions that do something and return a boolean like use() or adventure() do not have a useful return value. My understanding is that the return value does not indicate success or failure. It indicates whether or not mafia encountered an error in the execution.

In order to tell if you got your goal met, you'll have to check it. The return value will not assist you.
 

Glazius

Member
Aw. So I'm guessing there's no way to tell why adventure() stops, either?

So, for example, if adventure() stops because mafia stopped the adventure sequence when my familiar's sugar shield broke, there's no way to figure out what happened?
 

zarqon

Well-known member
If you set things up right, the return value of adventure() is useful. If you're adventuring with breakable equipment, make sure you have the preference set to re-equip and that you have plenty of them in inventory. Then clear your conditions, set your conditions, and check adventure(my_adventures(), place). Assuming you're not adventuring in a memories zone or hunting hobo glyphs/demon names, if adventure returns false it means you met your conditions. It only returns true if it consumes all the adventures specified in the first parameter.

You could also do something like this which would work around it:

PHP:
   int targetadvs = max(0,my_adventures() - advs);
   while (my_adventures() > targetadvs) {
       cli_execute("conditions clear");
       add_item_condition(1,goalcandy);
       adventure(my_adventures() - targetadvs,place);
       if (item_amount(goalcandy) > 0) use(1,goalcandy);
    }

In this example you can see it doesn't matter why adventure() stops.
 
Last edited:
Top