Results 1 to 7 of 7

Thread: Help with sorting map

  1. #1
    Senior Member
    Join Date
    Dec 2008
    Posts
    510

    Default Help with sorting map

    I have created a short script to print the values of all the drops I can get from my familiars:

    PHP Code:
    int get_price(item item_to_checkfloat acceptable_age) {
        return ((
    historical_age(item_to_check) <= acceptable_age)? historical_price(item_to_check) : mall_price(item_to_check));
    }

    void print_drop_values() {
        
    familiar f;
        
    int[familiardrop_value;
        
        foreach 
    f in $familiars[] {
            
    //print(f.name);
            
    if (have_familiar(f)) {
                if (
    f.drops_limit 0) {
                    
    drop_value[f] = get_price(f.drop_item1);
                }
            }
        }
        
        
    sort drop_value by value;
        foreach 
    f in drop_value {
            print(
    " - " f.drop_item " - " drop_value[f]);
        }
    }
    void main() {
        
    print_drop_values();

    Hoewever, I have some issues with understanding the output I get:
    Code:
    > test.ash
    
    Astral Badger - astral      mushroom - 0
    Green Pixie - tiny bottle of absinthe - 0
    Llama Lama -      llama lama gong - 0
    Cotton Candy Carnie - none - 0
    Baby Sandworm -      agua de vida - 105
    Rogue Program - Game Grid token - 115
    Li'l      Xenomorph - transporter transponder - 825
    Pair of Stomping Boots - none      - 900
    Bloovian Groose - groose grease - 1475
    Blavious Kloop -      devilish folio - 1500
    Angry Jung Man - psychoanalytic jar - 1500
    Unconscious      Collective - Unconscious Collective Dream Jar - 2900
    Grimstone Golem -      grimstone mask - 7250
    Grim Brother - grim fairy tale - 7300
    Miniature      Sword & Martini Guy - mini-martini - 9500
    Galloping Grill - hot      ashes - 9539
    Fist Turkey - none - 9800
    Golden Monkey - powdered gold      - 9800
    Adventurous Spelunker - Tales of Spelunking - 9850
    Puck Man -      power pill - 9950
    Ms. Puck Man - power pill - 15000
    Machine Elf -      Deep Machine Tunnels snowglobe - 15000
    How come some of the values are 0? Furthermore, values for e.g. the dream jar seems too low compared to what I get when I search for it in the mall (current price is 9200 meat).

    Finally, I wanted the drops to be sorted descending instead of ascending, so I tried to change line 18 of the script to
    Code:
    sort drop_value by -value;
    After doing this, the output from the script changes to

    Code:
    > test.ash
    
    Astral Badger - astral      mushroom - 15000
    Green Pixie - tiny bottle of absinthe - 15000
    Llama      Lama - llama lama gong - 9950
    Cotton Candy Carnie - none - 9850
    Baby      Sandworm - agua de vida - 9800
    Rogue Program - Game Grid token - 9800
    Li'l      Xenomorph - transporter transponder - 9539
    Pair of Stomping Boots -      none - 9500
    Bloovian Groose - groose grease - 7300
    Blavious Kloop -      devilish folio - 7250
    Angry Jung Man - psychoanalytic jar - 2900
    Unconscious      Collective - Unconscious Collective Dream Jar - 1500
    Grimstone Golem -      grimstone mask - 1500
    Grim Brother - grim fairy tale - 1475
    Miniature      Sword & Martini Guy - mini-martini - 900
    Galloping Grill - hot      ashes - 825
    Fist Turkey - none - 115
    Golden Monkey - powdered gold -      105
    Adventurous Spelunker - Tales of Spelunking - 0
    Puck Man - power      pill - 0
    Ms. Puck Man - power pill - 0
    Machine Elf - Deep Machine      Tunnels snowglobe - 0
    The order of the familiars is still the same, but the values stored for each of them has changed. Can someone please give me a pointer on where I am going wrong with this?

  2. #2

    Default

    For your second point, this page has some info about what you need to do to use sort properly.

    For your first point, some of the items being printed are "none", so those will give a price of 0. Using sort to unlink prices from familiars is the source of your confusion about identifying that issue.

  3. #3
    Senior Member
    Join Date
    Dec 2008
    Posts
    510

    Default

    Ah, so if I am reading that correctly, I can't sort my map while keeping the values linked to the keys?

    What I'll have to do is e.g. changing my map to an array holding the familiars drops, and then do something like

    Code:
    sort drop_values by get_price(value);
    -edit-
    Here we go.
    Code:
    int get_price(item item_to_check, float acceptable_age) {
        return ((historical_age(item_to_check) <= acceptable_age)? historical_price(item_to_check) : mall_price(item_to_check));
    }
    
    void print_drop_values() {
        familiar f;
        familiar[50] item_drop;
        int i;
        
        foreach f in $familiars[] {
            if (have_familiar(f)) {
                if (f.drops_limit > 0) {
                    item_drop[i] = f;
                    i = i + 1;
                }
            }
        }
        
        sort item_drop by -get_price(value.drop_item, 1);
        foreach i in item_drop {
            f = item_drop[i];
            if (item_drop[i] != $familiar[none]) {
                print(f + " - " + f.drop_item + " - " + get_price(f.drop_item, 1));
            }
        }
    }
    void main() {
        print_drop_values();
    }
    Now to figure out a sensible way to incorporate the familiars with drop_item = $item[none]. Do any of you have any suggestions?
    Last edited by ereinion; 09-05-2017 at 09:52 PM.

  4. #4
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    251

    Default

    Code:
        
        foreach f in $familiars[] {
    Now to figure out a sensible way to incorporate the familiars with drop_item = $item[none]. Do any of you have any suggestions?
    Originally Posted by ereinion View Post
    Try putting the familiar type in, rather than leaving it blank. This way you're only searching for familiars with drops, and familiars you have.

    Code:
    foreach f in $familiars[Adventurous Spelunker, Ancient Yuletide Troll, Angry Jung Man, Astral Badger, Baby Bugged Bugbear, Baby Sandworm, 
    				Blavious Kloop, Bloovian Groose, BRICKO chick, Cotton Candy Carnie, Crimbo Shrub, Fist Turkey, Galloping Grill,
    				Gelatinous Cubeling, Golden Monkey, Green Pixie, Grim Brother, Grimstone Golem, Knob Goblin Organ Grinder,
    				Lil' Barrel Mimic, Li'l Xenomorph, Llama Lama, Mechanical Songbird, Miniature Sword &amp; Martini Guy, Ms. Puck Man, Obtuse Angel, 
    				Penguin Goodfella, Pottery Barn Owl, Puck Man, Rock Lobster, Rogue Program, Slimeling, Stocking Mimic, 
    				Sugar Fruit Fairy, Twitching Space Critter, Unconscious Collective]
    EDIT: Now, I could be wrong, but I believe this is the complete list of familiars with drops. And before you say it, TPTB (The powers that be) already know "Miniature Sword &amp; Martini Guy"

    Heh, look at that. I helped someone. lol Usually the other way around.
    Last edited by Pazleysox; 09-05-2017 at 11:53 PM.

  5. #5

    Default

    EDIT: Now, I could be wrong, but I believe this is the complete list of familiars with drops.
    Originally Posted by Pazleysox View Post
    It is for now, maybe. New familiars get made often enough, and then the list needs updating.

    Your suggestion won't change the fact that $familiar[Fist Turkey].drop_item == $item[none], so it doesn't actually help here.

    For an actual solution, I don't know that there is one besides hard-coding the drops somehow.

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

    Default

    It is for now, maybe. New familiars get made often enough, and then the list needs updating.

    Your suggestion won't change the fact that $familiar[Fist Turkey].drop_item == $item[none], so it doesn't actually help here.

    For an actual solution, I don't know that there is one besides hard-coding the drops somehow.
    Originally Posted by lostcalpolydude View Post
    Hard coding familiar drops won't be any better than hard coding the familiars, the script will still have to be updated.

    I ran the script with the addition of the familiar names, then re-ran it after removing Fist Turkey. Here's the 2 results:
    Code:
    Puck Man - power pill - 15000
    Golden Monkey - powdered gold - 10000
    Rogue Program - Game Grid token - 9539
    Grimstone Golem - grimstone mask - 7250
    Galloping Grill - hot ashes - 825
    Fist Turkey - none - 0
    Code:
    Puck Man - power pill - 15000
    Golden Monkey - powdered gold - 10000
    Rogue Program - Game Grid token - 9539
    Grimstone Golem - grimstone mask - 7250
    Galloping Grill - hot ashes - 825

  7. #7

    Default

    Hard coding familiar drops won't be any better than hard coding the familiars, the script will still have to be updated.
    Originally Posted by Pazleysox View Post
    Hard-coding familiars provides no benefit. The script might have to be updated, but only if drop_item is none for a new familiar.

Posting Permissions

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