Results 1 to 8 of 8

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

  1. #1

    Default 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

  2. #2
    Senior Member
    Join Date
    Jun 2016
    Posts
    206

    Default

    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.

  3. #3
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    812

    Default

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

  4. #4
    Senior Member
    Join Date
    Oct 2014
    Posts
    159

    Default

    In ash:
    PHP Code:
    if (!to_boolean(get_property("_clanFortuneBuffUsed"))) { cli_execute("fortune buff item a a a"); } 
    Originally Posted by ckb View Post
    That isn't ignoring the error and continuing running. That's just avoiding the error in the first place. For shame!! (please note sarcasm).

  5. #5
    Developer
    Join Date
    Aug 2009
    Posts
    2,774

    Default

    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.
    Originally Posted by the dictator View Post
    In particular, to use try, you'd want to just do
    Code:
    try; fortune buff item a a a

  6. #6
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    812

    Default

    Or do nothing with a returned boolean, in ash:
    PHP Code:
    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 by ckb; 04-28-2018 at 12:01 AM.

  7. #7

    Default

    Thanks for the help everyone!

  8. #8
    Senior Member
    Join Date
    Dec 2008
    Posts
    549

    Default

    Or do nothing with a returned boolean, in ash:
    PHP Code:
    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)
    Originally Posted by ckb View Post
    you can also do
    PHP Code:
    if (cli_execute("fortune buff item a a a")) {} 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •