adventure() sometimes returns false despite consuming an adventure

worshiprick

New member
Perhaps this is a problem with the wiki, but adventure() is documented to return true if the specified number of adventures were used, false if not.

Observation says it returns false if there are any goals at all (even the adventure during which the goals were satisfied!). If there are no goals it returns true of the adventures were used, false if not.

The documented behavior would be much more useful IMO. As it stands, my scripts have to use manual goal-tracking because of this problem.

Here's a screenshot from the gCLI showing that adventure() returned false despite the adventure clearly being consumed:

returned false.png
 

Theraze

Active member
Is the fail there because adventure is failing, or your goals failed? They're not necessarily the same thing... You could try doing something like (this is off the top of my head, not sure how well it'll work, but...)
Code:
ashq boolean worked = adventure(1, my_location()); print(worked);

It's possible that the false at the end is because of conditions failing, not adventure()...
 

slyz

Developer
adventure() will return false if you still have unsatisfied goals, Theraze is right on. Trapping the result in a boolean like above, or doing something like this:
PHP:
if ( adventure(1, my_location()) ) {}
will make sure an ASH script doesn't abort because of that.
 

worshiprick

New member
adventure() will return false if you still have unsatisfied goals, Theraze is right on. Trapping the result in a boolean like above, or doing something like this:
PHP:
if ( adventure(1, my_location()) ) {}
will make sure an ASH script doesn't abort because of that.

That's what I was doing, but was hoping that wouldn't be true. If it actually returned true only if the # of adventures were used (like the wiki says), it could be used to tell if any adventures were used. As it is, I guess I'll have to manually implement my own goal tracking if I want that return value to mean something (and script in a cli_execute("goals clear") at the start of the script).

Thanks for the clarification! I guess I should make a wiki account and update the documentation. ::effort::
 
Top