boolean adv(location i){
if(my_adventures() >=1)
{
adventure(1, i);
return true;
}
else
{
print("NO MORE ADVENTURES!","red");
abort();
return false;
}
}
r11707 | jasonharper | 2012-12-16 05:17:54 +0000 (Sun, 16 Dec 2012) | 10 lines
Boolean functions that can exit without executing a 'return' statement are
now errors rather than warnings. You've had 9 months to fix these.
boolean binary() {
if(true) {
return true;
} else {
abort();
}
}
void main() {
print(binary());
}
> call testing.ash
Missing return value (testing.ash, line 7)
boolean adv(location i) {
if(my_adventures() < 1)
{
print("NO MORE ADVENTURES!","red");
abort();
}
adventure(1, i);
return true;
}
boolean adv(location i) {
if(my_adventures() < 1)
{
print("NO MORE ADVENTURES!","red");
abort();
}
return adventure(1, i);
}
I like your thinking Theraze. I've made the relevant edit to my copy of the script. Thanks!Why not reduce calculations by 2 and do this?Reduced by 1 because you don't check if my_adventures() > 1; reduced by 1 because you don't check if my_adventures() == 1. And all the executing code lives together.Code:boolean adv(location i) { if(my_adventures() < 1) { print("NO MORE ADVENTURES!","red"); abort(); } adventure(1, i); return true; }
Edit: Note that this adventure-check has an intrinsic weakness... it's calling adventure, which aborts if unfulfilled conditions remain and are not trapped. Because of that, we can (reasonably) expect that a 'failed' adventure is supposed to abort. And we can/should just run:Code:boolean adv(location i) { if(my_adventures() < 1) { print("NO MORE ADVENTURES!","red"); abort(); } return adventure(1, i); }
I've taken this script and renamed/updated it, here: http://kolmafia.us/showthread.php?13732-wrldwzrd89-s-PandamoniumQuest-ash-automated-steel-organI'm getting the following after I load the script:
> call scripts\Azazel.ash
Missing return value (Azazel.ash, line 37)