[quote author=Tirian link=topic=345.msg1927#msg1927 date=1155599996]
The problem all along has been that having a function return false when you're not doing anything with the return value is a script-aborting condition. Everyone's solutions posted here would solve the problem.[/quote]
I'd characterize ASH's state last spring as "immature." This kind of thing - people not being sure how to write scripts that would not get aborted in the middle without the script being able to handle it - was a common complaint. Not to mention the various exceptions & stack traces and other woes.
I took on the task of making ASH rock solid and predictable to the programmer. And one of the ways I did that was to define the following behavior:
Many ASH functions can "fail".
Such operations when performed through the GUI make the sidebar go red and stop execution: trying to eat beyond fullness, adventure when drunk, create something without necessary ingredients, whatever.
Such functions always return a boolean to tell the script whether they succeed or not. If you do not "capture" the boolean result by using it in a conditional, assigning it to a variable, passing it as a function parameter, or returning it as a function value, a failed operation will abort the script. If you DO "capture" the result, the script is saying that it is taking responsibility for deciding how to handle the failure, and the script will not abort.
If the user presses the "cancel" button, the script cannot "capture" that failure; the script will immediately abort.
I went through ASH and very carefully made it allow the script to "capture" the value in every single appropriate context; if the value is being saved for later use, errors do not cause the script to abort.
I'm confident that the core ASH engine works correctly in that way.
Now, there have been any number of cases where a built-in function didn't correctly return false on a failure; it would just return true. Adventuring in the Cyrpt originally returned false after the mini-boss was gone, but later got changed (broken) and returned true, before finally being changed (fixed) to return false again.
Feel free to report bugs if a function whose contract says it returns false on failure (which generally means it aborts the script if you don't "capture" the result) returns true.
Also feel free to report bugs if you "capture" a return value and your script aborts anyway on a failure (other than the user pressing Stop). I'd wager money you won't find any such bugs.
