Page 3 of 6 FirstFirst 1 2 3 4 5 ... LastLast
Results 21 to 30 of 53

Thread: Save items from pvp theft

  1. #21
    Senior Member nworbetan's Avatar
    Join Date
    Aug 2010
    Posts
    145

    Default

    I added a few embellishments:
    Code:
    
    int minimum_value = 1000; // Closet everything stealable worth more than this; 0 = closet everything stealable.
    boolean verbose = true; // false = Only print the items that gonna be or woulda been closeted.
    
    
    void main(string show_or_go)
    {
    
        boolean go = (show_or_go.to_lower_case() == "go"); // Anything other than "go" = just show what woulda happened.
        if (minimum_value < 0) abort ("A minimum_value less than zero makes no sense at all.");
        int count_cheap, count_closet, count_total, count_unstealable;
        int [item] inv = get_inventory();
        boolean [item] pvp_unimportant = $items[tenderizing hammer, dramatic range, Queue Du Coq cocktailcrafting kit];
        boolean is_stealable(item it) { return is_tradeable(it) && autosell_price(it) > 0; }
        foreach it, qty in inv {
            int price = -1;
            if (is_stealable(it) && !(pvp_unimportant contains it)) price = historical_price(it);
            if (price < 0) {
                count_unstealable += 1;
                if (verbose) print_html("<span color=\"green\">Not closeting " + qty + " " + (qty == 1 ? to_string(it) + ", it's" : to_plural(it)  + ", they're") + " unstealable.</span>");
            } else if (price >= minimum_value) {
                count_closet += 1;
                print_html("<span color=\"teal\">" + (go ? "Gonna closet " : "Woulda closeted ") + qty + " " + (qty == 1 ? to_string(it) : to_plural(it)) + ".</span>");
                if (go) put_closet(qty, it);
            } else if (price < minimum_value) {
                count_cheap += 1;
                if (verbose) print_html("<span color=\"red\">Not worth closeting " + qty + " " + (qty == 1 ? to_string(it) : to_plural(it)) + ".</span>");
            }
        }
        count_total = count_closet + count_cheap + count_unstealable;
        if (count_closet > 0) print("+ " + count_closet + (go ? "" : " woulda been") + " closeted", "teal");
        if (count_cheap > 0) print("+ " + count_cheap + " worth less than " + minimum_value + " meat", "red");
        if (count_unstealable > 0) print("+ " + count_unstealable + " unstealable", "green");
        if (count_total > 0) print(" = " +  count_total + " of " + count(inv) + " items accounted for.");
        print_html("<b>Done<a href=\"http://kolmafia.us/showthread.php?10059\">!</a></b>");
    }
    The first time you run it, use any argument other than "go" and it'll do a dry run so you can see whether you like the verbosity and/or 1000 meat setting. Setting verbosity to false hides the unstealable and cheap items, but it will always show the closeted items and the brief report at the end.

    I think it might be worth adding this functionality to an autoselling script, or vice versa.
    Attached Files
    Last edited by nworbetan; 05-14-2012 at 06:04 AM.

  2. #22

    Default

    Nworbetan, I love you very, very much right now.

    Being able to do a dry run - awesome
    Having verbosity turned on for that first categorizing run - awesome and enlightening
    Being able to turn off verbosity - awesome
    Having including a link to the script that I could click and have it download because I still can't figure out how to make it a working script when someone just posts the code in their post - most awesome ever

    Thank you very much, as well as thanks to the folks whose work you built on.

    You folks make every day playing a little more amazing.

    Edited to add a question and avoid nasty double posting:

    Where would I add in that script an item that would normally be Closeted, because it meets all the conditions, but I would rather not have to take it out of the Closet each and every day so I'm okay with the script ignoring it? Item I'm specifically thinking of is a tiny plastic bitchin' meatcar?

    ~Aramada
    Last edited by Aramada; 06-22-2012 at 10:37 PM. Reason: Edited to add a question and avoid nasty double posting

  3. #23
    Senior Member nworbetan's Avatar
    Join Date
    Aug 2010
    Posts
    145

    Default

    You can add items to the line:
    Code:
    boolean [item] pvp_unimportant = $items[tenderizing hammer, dramatic range, Queue Du Coq cocktailcrafting kit, tiny plastic bitchin' meatcar];

    And that will stop them from being closeted. Capitalization isn't important, but spelling kind of is. Fuzzy matching can be kind of a double-edged sword sometimes if you're not expecting it.

  4. #24

    Default

    So I've been using Nworbetan's Protection script pretty much daily for the past 4 months. Today, it failed. As in, I ran it and this popped up: Unknown variable 'than' (protection.ash, line 6)

    I deleted my copy from my scripts file, and redownloaded the one from this thread...ran it, and got the exact same message.

    I have no idea what changed, why "than" is suddenly an unknown variable, but I love, love, love this script and would very much like it if it could be made to work again. Is there something I can do to fix it?

    ~Aramada

  5. #25
    Senior Member Theraze's Avatar
    Join Date
    Mar 2010
    Posts
    8,746

    Default

    Just downloaded it from post 21, changed the line breaks, and ran it without problems...
    + 25 woulda been closeted
    + 263 worth less than 1000 meat
    + 68 unstealable
    = 356 of 356 items accounted for.
    Done!
    Attaching the version I just ran. Maybe your system just decided it doesn't like *nix line breaks?
    Attached Files

  6. #26

    Default

    Maybe your system just decided it doesn't like *nix line breaks?
    Originally Posted by Theraze View Post
    Apparently that was it. Downloaded the one you attached and it was perfectly fine with it. WHY it just decided it doesn't like *nix line breaks? Hell if I know.

    Thanks for your lightning fast trouble shooting, Theraze!

    ~Aramada

  7. #27

    Default

    I added a few embellishments:
    Code:
    
    int minimum_value = 1000; // Closet everything stealable worth more than this; 0 = closet everything stealable.
    boolean verbose = true; // false = Only print the items that gonna be or woulda been closeted.
    
    
    void main(string show_or_go)
    {
    
        boolean go = (show_or_go.to_lower_case() == "go"); // Anything other than "go" = just show what woulda happened.
        if (minimum_value < 0) abort ("A minimum_value less than zero makes no sense at all.");
        int count_cheap, count_closet, count_total, count_unstealable;
        int [item] inv = get_inventory();
        boolean [item] pvp_unimportant = $items[tenderizing hammer, dramatic range, Queue Du Coq cocktailcrafting kit];
        boolean is_stealable(item it) { return is_tradeable(it) && autosell_price(it) > 0; }
        foreach it, qty in inv {
            int price = -1;
            if (is_stealable(it) && !(pvp_unimportant contains it)) price = historical_price(it);
            if (price < 0) {
                count_unstealable += 1;
                if (verbose) print_html("<span color=\"green\">Not closeting " + qty + " " + (qty == 1 ? to_string(it) + ", it's" : to_plural(it)  + ", they're") + " unstealable.</span>");
            } else if (price >= minimum_value) {
                count_closet += 1;
                print_html("<span color=\"teal\">" + (go ? "Gonna closet " : "Woulda closeted ") + qty + " " + (qty == 1 ? to_string(it) : to_plural(it)) + ".</span>");
                if (go) put_closet(qty, it);
            } else if (price < minimum_value) {
                count_cheap += 1;
                if (verbose) print_html("<span color=\"red\">Not worth closeting " + qty + " " + (qty == 1 ? to_string(it) : to_plural(it)) + ".</span>");
            }
        }
        count_total = count_closet + count_cheap + count_unstealable;
        if (count_closet > 0) print("+ " + count_closet + (go ? "" : " woulda been") + " closeted", "teal");
        if (count_cheap > 0) print("+ " + count_cheap + " worth less than " + minimum_value + " meat", "red");
        if (count_unstealable > 0) print("+ " + count_unstealable + " unstealable", "green");
        if (count_total > 0) print(" = " +  count_total + " of " + count(inv) + " items accounted for.");
        print_html("<b>Done<a href=\"http://kolmafia.us/showthread.php?10059\">!</a></b>");
    }
    The first time you run it, use any argument other than "go" and it'll do a dry run so you can see whether you like the verbosity and/or 1000 meat setting. Setting verbosity to false hides the unstealable and cheap items, but it will always show the closeted items and the brief report at the end.

    I think it might be worth adding this functionality to an autoselling script, or vice versa.
    Originally Posted by nworbetan View Post

    I think a recent change to mafia finally broke this script.. anyone know how to fix it? Fixing the name of the dramatic range wasn't enough. Looks like the mall refactoring in
    r14295 broke it.
    Last edited by Captain Kirk; 08-01-2014 at 03:15 AM.

  8. #28

    Default

    If you have 14295, try grabbing 14296. Otherwise, describe the problem in more detail.

    Also
    Code:
    boolean is_stealable(item it) { return is_tradeable(it) && autosell_price(it) > 0; }
    is wrong in that script, since there are items with an autosell value that cannot be discarded anyway (silver shrimp fork is an example). I don't know if there's any way to actually autosell those items, but mafia has the autosell value for min mallprice purposes.

  9. #29

    Default

    If you have 14295, try grabbing 14296. Otherwise, describe the problem in more detail.

    Also
    Code:
    boolean is_stealable(item it) { return is_tradeable(it) && autosell_price(it) > 0; }
    is wrong in that script, since there are items with an autosell value that cannot be discarded anyway (silver shrimp fork is an example). I don't know if there's any way to actually autosell those items, but mafia has the autosell value for min mallprice purposes.
    Originally Posted by lostcalpolydude View Post
    Well, turns out I had an even older version of this script ... the newer one seemed to work better. How would you fix that line?

  10. #30
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,862

    Default

    replace "autosell_price(it) > 0" with "is_discardable(it)"
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

Similar Threads

  1. Replies: 0
    Last Post: 08-07-2015, 06:00 PM
  2. Feature - Implemented Cache store items so that shop_amount() can save server hits
    By zarqon in forum Bug Reports
    Replies: 9
    Last Post: 09-10-2012, 11:33 PM
  3. Replies: 0
    Last Post: 06-24-2011, 08:41 PM
  4. Feature - Rejected Save Connection Options
    By mredge73 in forum Bug Reports
    Replies: 10
    Last Post: 02-14-2011, 11:59 PM
  5. Ubuntu Save Path
    By conan359 in forum Community Support
    Replies: 3
    Last Post: 01-01-2010, 08:15 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
  •