How do I force the script to ignore errors and continue running?

I have a command in my script to get fortune buffs
Code:
fortune buff item a a a

but sometimes I have already manually obtained the buff, as such I get the below error.
Code:
You already received a buff from the clan fortune teller.

Is it possible to put a line in the code to override these errors?

I'm familiar with Excel vba coding, and in such cases I usually use the below code. Is there a similar code I can use for kolmafia?
Code:
On Error Resume Next
 
You could use try, but that's a little ugly.
For this, but for most cases in mafia, there's usually a setting to track if you already used whatever daily recourse you want, so you can use an if statement to see if that's the case. 'prefref fortune' shows me _clanFortuneBuffUsed as the property to use, though I don't know how/if you can test a property in cli commands, or if you would need to write in ash for that.
 

ckb

Minion
Staff member
In ash:
PHP:
if (!to_boolean(get_property("_clanFortuneBuffUsed"))) { cli_execute("fortune buff item a a a"); }
 
In ash:
PHP:
if (!to_boolean(get_property("_clanFortuneBuffUsed"))) { cli_execute("fortune buff item a a a"); }

That isn't ignoring the error and continuing running. That's just avoiding the error in the first place. For shame!! (please note sarcasm).
 

heeheehee

Developer
Staff member
You could use try, but that's a little ugly.
For this, but for most cases in mafia, there's usually a setting to track if you already used whatever daily recourse you want, so you can use an if statement to see if that's the case. 'prefref fortune' shows me _clanFortuneBuffUsed as the property to use, though I don't know how/if you can test a property in cli commands, or if you would need to write in ash for that.

In particular, to use try, you'd want to just do
Code:
try; fortune buff item a a a
 

ckb

Minion
Staff member
Or do nothing with a returned boolean, in ash:
PHP:
boolean idontcare = cli_execute("fortune buff item a a a");
(Does this work? I think it does). (yes, I just checked, it works. This is the cheesecookie method)
 
Last edited:

ereinion

Member
Or do nothing with a returned boolean, in ash:
PHP:
boolean idontcare = cli_execute("fortune buff item a a a");
(Does this work? I think it does). (yes, I just checked, it works. This is the cheesecookie method)
you can also do
PHP:
if (cli_execute("fortune buff item a a a")) {}
 
Top