PDA

View Full Version : Script request: Sending all the junk you accumulated in a run to a mall multi



Elayne
05-26-2010, 02:05 AM
Hi all,

When I'm in need of meat, I tend to look for collectors in /trade to buy "junk" that I accumulated in-run. The thing is, I have no time to hang out in /trade with my main and thus stop ascending for a time, and would rather that I do that with my mall multi.

Only, sending each and every item that I accumulated to the mall multi is so time consuming and tedious, that I was hoping that there was a way a script can just take all my inventory items and send it to my multi. If this has been asked before, can I be directed to the right place? My searching skills seem to have failed me.

Thanks,

Elayne

heeheehee
05-26-2010, 03:19 AM
import <zlib.ash>

void main(string player) {
kmail(player, "", 0, get_inventory(), "");
}

Simple enough, but it requires ZLib (http://kolmafia.us/showthread.php?2072-ZLib-Zarqon-s-useful-function-library).

(Untested.)

lostcalpolydude
05-26-2010, 05:17 AM
Alternatively, People -> Send a Message, Click to attach an item, highlight the entire list (Ctrl + A should work), click ok, put in your mall multi's name, and send message.

slyz
05-26-2010, 07:00 PM
If you do it lost's way, I think it will ask the quantity you want to send for each item. heeheehee's script seems like the way to go.

Bale
05-27-2010, 03:09 AM
The great thing about heeheehee's script is that it can so easily be turned into an alias!


alias sendall => ashq import <zlib.ash>; kmail("%%", "", 0, get_inventory(), "");

Replace %% with the name of your mall multi. (Or else leave it and use the muti's name as an argument; either way works.)

That FN Ninja
05-27-2010, 03:20 AM
or rather:


alias sendall => ashq import <zlib.ash>; kmail("%%", "", 0, get_inventory());Forgot the ashq and the quotes around %%. This could be handy.

Bale
05-27-2010, 03:23 AM
Does it work with quotes? I use several alias with %% and no quotes. They're optional then.

The ashq is a definite oops though. I edited it into my post. Thanks.

That FN Ninja
05-27-2010, 03:25 AM
In this instance the quotes are necessary. Without them you get: "Unknown variable %% ()"

Bale
05-27-2010, 03:30 AM
Ah. Of course. Since I'm trying to use it as a string constant. Stupid me. Thankie.

lostcalpolydude
05-27-2010, 05:12 AM
If you do it lost's way, I think it will ask the quantity you want to send for each item. heeheehee's script seems like the way to go.

I tried it before making my post. It doesn't prompt. And I just now added a single item to see the prompt to be sure that it's different when adding everything.

Getting to use an alias seems nice, but zlib seems like it would be a bit bulky for something so simple.

zarqon
05-27-2010, 06:09 AM
That's the point -- the "bulk" of ZLib is what makes this simple. Without it, you'd need a much larger script -- or a small one that hammered the server.

Bale
05-27-2010, 06:19 AM
Getting to use an alias seems nice, but zlib seems like it would be a bit bulky for something so simple.

Simple?! It is not a simple task. This is only the necessary part of zlib.


boolean vprint(string message, string color, int level) {
if (level == 0) abort(message);
# if (to_int(vars["verbosity"]) >= abs(level)) print(message,color);
if (3 >= abs(level)) print(message,color);
return (level > 0);
}
boolean vprint(string message, int level) { if (level > 0) return vprint(message,"black",level); return vprint(message,"red",level); }

boolean send_gift(string to, string message, int meat, int[item] goodies, string insidenote) {
// parse items into query string
string itemstring = "";
int j = 0;
int[item] extra;
foreach i in goodies {
if (is_tradeable(i) || is_giftable(i)) {
j = j+1;
if (j < 4)
itemstring = itemstring + "&howmany"+j+"="+goodies[i]+"&whichitem"+j+"="+to_int(i);
else extra[i] = goodies[i];
}
}
int shipping = 200;
int pnum = 3;
if (count(goodies) < 3) {
shipping = 50*max(1,count(goodies));
pnum = max(1,count(goodies));
}
if (my_meat() < meat+shipping) return vprint("Not enough meat to send the package.",-2);
// send gift
string url = visit_url("town_sendgift.php?pwd=&towho="+to+"&note="+message+"&insidenote="+insidenote+"&whichpackage="+pnum+"&fromwhere=0&sendmeat="+meat+"&action=Yep."+itemstring);
if (!contains_text(url,"Package sent.")) return vprint("The message didn't send for some reason.",-2);
if (count(extra) > 0) return send_gift(to,message,0,extra,insidenote);
return true;
}
boolean send_gift(string to, string message, int meat, int[item] goodies) { return send_gift(to,message,meat,goodies,""); }

boolean kmail(string to, string message, int meat, int[item] goodies, string insidenote) {
if (meat > my_meat()) return vprint("You don't have "+meat+" meat.",-2);
// parse items into query strings
string itemstring = "";
int j = 0;
string[int] itemstrings;
foreach i in goodies {
if (is_tradeable(i) || is_giftable(i)) {
j = j+1;
itemstring = itemstring + "&howmany"+j+"="+goodies[i]+"&whichitem"+j+"="+to_int(i);
if (j > 10) {
itemstrings[count(itemstrings)] = itemstring;
itemstring = '';
j = 0;
}
}
}
if (itemstring != "") itemstrings[count(itemstrings)] = itemstring;
if (count(itemstrings) == 0) itemstrings[0] = "";
else vprint(count(goodies)+" item types split into "+count(itemstrings)+" separate kmails.",5);
// send message(s)
foreach q in itemstrings {
string url = visit_url("sendmessage.php?pwd=&action=send&towho="+to+"&message="+message+"&savecopy=on&sendmeat="+meat+itemstrings[q]);
if (contains_text(url,"That player cannot receive Meat or items"))
return (vprint("That player cannot receive stuff, sending gift instead...",4) && send_gift(to, message, meat, goodies, insidenote));
if (!contains_text(url,"Message sent.")) return vprint("The message didn't send for some reason.",-2);
}
return true;
}

Feel free to copy-paste that into your script. Or just use zlib. I'm happy to let zarqon worry about making sure it gets updated if mafia or KoL change things... That's already happened once since this function was added to zlib.

Bulky?

lostcalpolydude
05-27-2010, 06:27 AM
I personally don't like the idea of redownloading zlib every time cool new features are added/fixed that I'm not using, or ignoring update messages that will come up all the time. But I'm probably just being stubborn.

I didn't mean that the code was simple (I'm pretty sure I couldn't write it), I meant that using the GUI is simple, since I was able to find it quickly in a part of the interface that I never use.

zarqon
05-27-2010, 06:33 AM
Ah, so by "bulk" you were including the update experience. (Secret: if you edit the update function in ZLib, you will only have the annoyance when ZLib itself updates. But don't blame me if something breaks that I've already fixed.)

Bale and I suggested a scripting fix, you a GUI one. Considering that it will likely be done once per ascension, the difference is negligible and depends entirely on how much Elayne would like to script vs. click.

heeheehee
05-27-2010, 07:13 AM
Or, y'know, hold down the Enter key.

Winterbay
05-27-2010, 07:53 AM
Or, y'know, hold down the Enter key.

The problem with that one is that if you come to the end and still hold enter it appears to start over from the top. At least it does that if you try to transfer everything from your inventory to your store...

slyz
05-27-2010, 10:54 AM
Or, y'know, hold down the Enter key.

Lost pointed out (and you can try it for yourself), that when sending a message, if you do ctrl-a to select everything in your inventory, you won't be prompted about quantities.