Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 23

Thread: Checking for items in Hagnks

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

    Default Checking for items in Hagnks

    Is there a script command to see if you have any item in storage?

    I'm trying to write an informational script for myself to remind me what items I should pull for max rollover turns, and want to check for items before I just start pulling things.

  2. #2
    Developer
    Join Date
    Apr 2010
    Posts
    4,110

    Default

    http://wiki.kolmafia.us/index.php?title=Storage_amount ?

    Or if you want a list, like get_inventory() returns, looks like get_storage() exists from the code.
    Last edited by Darzil; 07-04-2017 at 03:48 PM.

  3. #3
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    261

    Default

    I tried this, wrote the file I wanted mapped, and get nothing in return.

    Or if you want a list, like get_inventory() returns, looks like get_storage() exists from the code.
    Originally Posted by Darzil View Post
    I've looked into those....

    I've tried this too:

    Code:
    int item_count() {
       item x = $item[knob goblin firecracker];
       int counter = item_amount( x ) + closet_amount( x ) + storage_amount( x );
       return counter;
    }
    This returns nothing.

    I can't figure it out... for the time being, I just wrote a simple script to pull the stuff I know I have, and equip it.

  4. #4
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,756

    Default

    Is it possible that mafia thinks you already emptied your hagnks this ascension? Then it wouldn't check storage during session refresh, and storage_amount(x) would == 0 for all x until you force the refresh somehow (does visiting hagnk's work?)

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

    Default

    Is it possible that mafia thinks you already emptied your hagnks this ascension? Then it wouldn't check storage during session refresh, and storage_amount(x) would == 0 for all x until you force the refresh somehow (does visiting hagnk's work?)
    Originally Posted by xKiv View Post
    I'm only testing these scripts when I'm in ronin (which is pretty much all the time). I've even tried this:
    Code:
    int item_count() {
       item x = $item[knob goblin firecracker];
       int counter = storage_amount( x );
       return counter;
    }
    And got nothing returned. I'm also looking at the other thread about clubs/enchantments. It might be able to be done a few ways.

  6. #6
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    261

    Default

    I've discovered multiple ways of looking for things in storage now. I've been screwing around with a bunch of codes, and here's 4 that i've come up with

    This one is pretty simple, and a great way to search for 1 item.
    PHP Code:
    {
    int[iteminventory get_storage() ;
        
    item it $item[2-ball];
       if ( 
    inventory[it] > 
          print (
    "You have " it"green");
        else print (
    "You don't have " it);

    I wanted to search for multiple items though, so I worked to find a way to do it.
    PHP Code:
    {
    int[iteminventory get_storage() ;
        
    item it $item[2-ball];
       if ( 
    inventory[it] > 
          print (
    "You have " it"green");
        else print (
    "You don't have " it);
    }
    //have to split these up, or mafia will come up with error.  This can be repeated as many times as needed/wanted.
    {
    int[iteminventory get_storage() ;
        
    item it $item[3-ball];
       if ( 
    inventory[it] > 
          print (
    "You have " it"green");
        else print (
    "You don't have " it);

    This one is almost identical to the one above, but allows for multiple searches, without writing multiple lines of the same code, like the code above.
    This code is the one I think I will use for the script I'm writing.
    PHP Code:
    {
    int[iteminventory get_storage() ;
        foreach 
    it in $items[8-ball3-ball4-balltalisman of baio]
       if ( 
    inventory[it] >= 
          print (
    "You have " it"green");
        else print (
    "You don't have " it"red');

    This next one is obviously not the best code, but amazingly it was the first one I found that worked. I stole the whole thing from another script that I wrote, and never released.
    PHP Code:
    {
    int[iteminventory get_storage() ;
    boolean firecracker false;
        
    item it $item[knob goblin firecracker];
        if ( 
    inventory [it] >= 1)
            { 
    firecracker true;    }
        if (
    firecracker) {print ("You have " it "green");}
            else {print (
    "You do not have" it "red");}


  7. #7
    Senior Member
    Join Date
    Apr 2009
    Posts
    1,756

    Default

    So get_storage()[it] returns the correct amount, but storage_amount(it) doesn't? Both work for me (in aftercore, but I haven't "pulled all").

    ...

    Code:
    int item_count() {
       item x = $item[knob goblin firecracker];
       int counter = storage_amount( x );
       return counter;
    }
    Is that all? Are you not *calling* the function you defined? That would explain why nothing is returned ...

  8. #8
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    261

    Default

    So get_storage()[it] returns the correct amount, but storage_amount(it) doesn't? Both work for me (in aftercore, but I haven't "pulled all").

    ...

    Code:
    int item_count() {
       item x = $item[knob goblin firecracker];
       int counter = storage_amount( x );
       return counter;
    }
    Is that all? Are you not *calling* the function you defined? That would explain why nothing is returned ...
    Originally Posted by xKiv View Post
    get_storage()[it] returns a true or false.

    I've been messing around with storage_amount(it), and can't get it to work... I'm not sure what you mean about "calling" the function...

    For the script I'm trying to write, the get_storage()[it] command is perfect. Knowing how many if [it] I have doesn't make a difference. BUT having said that, learning how to get storage_amount(it) to work properly would be nice.

  9. #9

    Default

    I'm not sure what you mean about "calling" the function...
    Originally Posted by Pazleysox View Post
    The functions you posted should at least return 0, if mafia was giving bad info about what you have in storage. If it didn't even return that, then your code is at fault. A script that just has a function that you never call will do nothing.

  10. #10
    Senior Member AlbinoRhino's Avatar
    Join Date
    May 2008
    Posts
    707

    Default

    Code:
    int item_count() {
       item x = $item[knob goblin firecracker];
       int counter = storage_amount( x );
       return counter;
    }
    What you have posted is a function definition. The function is named " item_count() ". In order to have the script actually run that code, you need to "call" the function from somewhere in the script.

    You would do that by placing:

    item_count();

    at the place in your script where you want your function to run the code it contains.

    The function returns an integer. In order to actually see that return, you would need to 'capture' the return value and then print it.

    So...

    int x = item_count(); ( x will capture the return value)

    print(x); ( to see what that return value was )

    edit:
    or you could add a

    print(counter);

    line to your function, and it will print the value each time it is " called ".
    Last edited by AlbinoRhino; 07-19-2017 at 04:05 PM.

Posting Permissions

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