Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: if(!in_hardcore()) question

  1. #1
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    216

    Default if(!in_hardcore()) question

    Here's what I'm trying to do.

    Code:
    void main()
    
    do stuff here
    
    if(!in_hardcore()) gohere();
    
    do stuff here
    
    void gohere()
    Function 'gohere( )' undefined. This script may require a more recent version of KoLmafia and/or its supporting scripts.

    is what I get. I know there's a simple way around this, but I'm not seeing it...

  2. #2
    Senior Member AlbinoRhino's Avatar
    Join Date
    May 2008
    Posts
    681

    Default

    place void gohere() above any call to it. This looks like you are calling the function before defining it.

  3. #3
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,095

    Default

    Either put gohere() farther up in the file before you call it, or put a "forward reference" to it before you call it. That would be:

    void gohere();
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  4. #4
    Senior Member AlbinoRhino's Avatar
    Join Date
    May 2008
    Posts
    681

    Default

    Today I learned about "forward reference". Thanks V !

  5. #5
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    216

    Default

    Either put gohere() farther up in the file before you call it, or put a "forward reference" to it before you call it. That would be:

    void gohere();
    Originally Posted by Veracity View Post

    Is there another way to do this? I tried this, and got the same error.

    Essentially what I'm trying to do is skip a chunk of code that I don't want to check if user is in hardcore. It's a rollover script that I'm updating for someone.

  6. #6
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,095

    Default

    You want a goto statement? Uh, no.

    Put the stuff you want to "skip over" in its own function - or in the block associated with an if statement that is controlled by the "conditional" associated with the if.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  7. #7
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    216

    Default

    You want a goto statement? Uh, no.

    Put the stuff you want to "skip over" in its own function - or in the block associated with an if statement that is controlled by the "conditional" associated with the if.
    Originally Posted by Veracity View Post
    Code:
    if ($item[time sword].available_amount() > 0 && (have_familiar($familiar[Disembodied Hand]) && (!in_hardcore())))
    			{
       				use_familiar($familiar[Disembodied Hand]);
    					equip($slot[familiar], $item[time sword]);		
    			}
    This would check for time sword first, disembodied hand second, and hardcore third, right?

    If this i the case, can I do it this way:

    Code:
    if (!in_hardcore() && ($item[time sword].available_amount() > 0 && (have_familiar($familiar[Disembodied Hand])))))
    			{
       				use_familiar($familiar[Disembodied Hand]);
    					equip($slot[familiar], $item[time sword]);		
    			}
    Or is that two ways of saying exactly the same thing?

  8. #8

    Default

    Those are the same thing, basically. You really don't need all those parentheses though, when you're just using && to compare all of your boolean expressions.

    Code:
    if (!in_hardcore() && $item[time sword].available_amount() > 0 && have_familiar($familiar[Disembodied Hand])))
    is a perfectly good line. If you start mixing && and || then using parentheses becomes important to make sure you know what order things will be compared in.

  9. #9
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    216

    Default

    Thanks everyone, I greatly appreciate the help. I think I finally have it working.

  10. #10
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    216

    Default

    Part of the same script, so I'll keep it in the same thread.

    Code:
    	print ("Maxamizing turn count... This might take a moment, we have a lot to check...", "Blue");
    	if ($item[time sword].available_amount() > 0 && (have_familiar($familiar[Disembodied Hand])&&(!in_hardcore())))
    			{
       				use_familiar($familiar[Disembodied Hand]);
    					equip($slot[familiar], $item[time sword]);		
    			}
    	else if($item[solid shifting time weirdness].available_amount() > 0 &&(!in_hardcore()))
    			{
    					equip($slot[familiar], $item[solid shifting time weirdness]);
    			}
    	else if ($item[The Nuge's favorite crossbow].available_amount() > 0 && (have_familiar($familiar[Disembodied Hand])&&(!in_hardcore())))
    			{
       				use_familiar($familiar[Disembodied Hand]);
    					equip($slot[familiar], $item[The Nuge's favorite crossbow]);
    			}
    	else if($item[li'l unicorn costume].available_amount() == 0 && (have_familiar($familiar[Trick-or-Treating Tot])))
    		{
    		cli_execute ("buy li'l unicorn costume");
    		}
    	else if ($item[li'l unicorn costume].available_amount() > 0 && (have_familiar($familiar[Trick-or-Treating Tot])))
    			{
       				use_familiar($familiar[Trick-or-Treating Tot]);
    					equip($slot[familiar], $item[li'l unicorn costume]);
    			}
    
            cli_execute("maximize adv -tie -familiar");
    
    	print("Finished checking for rollover adventures.", "green");
    The script doesn't look past the time shifting weirdness, regardless of other items being available.

Posting Permissions

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