Request with a reward!

Theman123

New member
Hello-

I'm new to the forums and don't know where requests go. Anyway i was hoping if there is a script that will take out the items of my clan stash and sell them in the mall for 1k cheaper then the cheapest mall price. If there is such a script please post here or send a K-mail to Theman123 (me).

If there is no such script and someone is willing to make one please do! :):)!!! Just send me a K-mail!

PS. 50k reward to the player that can make a good script for this that will work! Even if there is a script like this and you post the link here you will get the 50K!:):)

Note: I am the leader of my clan (Tiny Plastic Atlantas) so don't worry about looting and stuff.
 

Sandiman

Member
I doubt you're going to get a script in response to this request. The ability to get the lowest price of an item in real time is purposefully not included in KoLMafia, to the extent that you can't even use visit_url to get the mall prices manually. It would be trivial to create a mallbot if you could determine the lowest cost of an item.

There are, however, some scripts people have written that do similar things. dj_d's "price.ash" script (http://kolmafia.us/showthread.php?t=1498) will get you an estimated price based on external sources. Getting the value of an item over a couple of days would probably give you a decent idea of a price at which you could sell your item.

Hope that helps.
 

Theman123

New member
This kind of helped... What i'm looking for is a script that will take items out of my clan stash and sell them... I don't care anymore for in mall just if they get sold (auto sell). In mall would be nice and the best.

Thanks thou!
 

zarqon

Well-known member
Here you go! This is very close to what you asked for. Save this as a text file with the .ash extension:

Code:
   int amt;
   for i from 1 to 4000 {
      item it = to_item(i);
      if (is_tradeable(it) && stash_amount(it) > 0) {
         amt = stash_amount(it);
         take_stash(amt,it);
         cli_execute("mallsell "+amt+" "+to_string(it));
      }
   }
   cli_execute("undercut");

WARNING: the above code will attempt to remove ALL items from your clan stash and sell them at or below mall minimum. Do not use this code unless you have the approval of your clan.
 
Last edited:

Bale

Minion
By the way zarqon, I liked your code so much that I've added this to the very end of my after run cleanup. (After autoselling, piemaking, displaycasing and using as appropriate.) Thanks for posting that.

Code:
int amt;
for i from 1 to 4000 {
	item it = to_item(i);
	if (is_tradeable(it) && item_amount(it) > 0) {
		amt = item_amount(it);
		cli_execute("mallsell "+amt+" "+to_string(it)+" @ "+to_string(mall_price(it)));
	}
}

I like to have no inventory aside from what I keep in Hagnks. ^_^
 
Last edited:

Bale

Minion
Hmm... No, I suppose not. I can throw away those two lines and do the selling with just:

cli_execute("mallsell * "+to_string(it)+" @ "+to_string(mall_price(it)));

Thanks. Your code is always so tidy.
 
Last edited:

Theman123

New member
Thanks!

Thanks guys! i have one question thou...

I got to codes here and um... which on should i use =S

Thanks!! both of you get something please allow some time...

PS. I am the clan leader no worries
 

Bale

Minion
Use zarqon's. No doubt. His tight little bit of code is full of awesome.

The derivative script I posted was modified from his, for a slightly different purpose.
 

zarqon

Well-known member
Haha -- "slightly different". Bale's code will sell all of your items in your personal inventory! :) He is planning on using it before ascending to clear out his inventory.

Bale -- thanks for the kind words.
 

Bale

Minion
Selling everything in personal inventory is only slightly different from selling everything in clan stash. Very similar. And since everything I really don't want to sell is safely tucked away in Hagnks when I use it, there's practically no possibility of losing anything important. For a softcore player to use that script would admittedly be traumatic, but my inventory is just a source of income.

Anyway, ascended today and got to test it out. :D Took just a little longer to run than I'd like, but that is mostly because of all the mall lookups. I think it might be a little bit quicker if I concatenated together 11 mallsell requests on each line. (The price lookups won't be quicker, but at least there will be 1/11 of the number of mallsell requests.)

Code:
int queue_size = 0;
string mall_queue = "mallsell ";
for i from 1 to 4000 {
	item it = to_item(i);
	if (is_tradeable(it) && item_amount(it) > 0) {
		if (queue_size < 10) {
			mall_queue = mall_queue + "* "+to_string(it)+" @ "+to_string(mall_price(it))+", ";
			queue_size = queue_size + 1;
		} else {
			cli_execute(mall_queue + "* "+to_string(it)+" @ "+to_string(mall_price(it)));
			mall_queue = "mallsell ";
			queue_size = 0;
		}
	}
}
if (queue_size > 0) {
	mall_queue = substring( mall_queue, 0, length(mall_queue) - 1 );
	cli_execute(mall_queue);
}

I'll have to try that out after my current ascension. Though I'm doing an HCO run so it'll be a little while.

If Theman123 wants to use the improved faster version, selling off his clan stash would look like this:

Code:
int amt;
int queue_size = 0;
string mall_queue = "mallsell ";
for i from 1 to 4000 {
	item it = to_item(i);
	if (is_tradeable(it) && stash_amount(it) > 0) {
		if (queue_size < 10) {
			amt = stash_amount(it);
			take_stash(amt,it);
			mall_queue = mall_queue + amt+" "+to_string(it)+", ";
			queue_size = queue_size + 1;
		} else {
			amt = stash_amount(it);
			take_stash(amt,it);
			cli_execute(mall_queue + amt+" "+to_string(it) );
			mall_queue = "mallsell ";
			queue_size = 0;
	}
}
if (queue_size > 0) {
	mall_queue = substring( mall_queue, 0, length(mall_queue) - 1 );
	cli_execute(mall_queue);
}
cli_execute("undercut");

What do you think?
 
Last edited:

zarqon

Well-known member
If you are using undercut, you can avoid mall_price() altogether. It's also much, much faster, since it gets all of those prices from a single KoL server hit. It's also better if you want those items to sell, since undercut looks at min price whereas mall_price() looks at the 5th item.

I like your queue idea to speed things up and save server hits. Although, I'm pretty sure if you give mafia a mallsell request with 24890 items, it will automatically split that up into groups of 11. So some of your code is unnecessary -- you can just build a single CLI command in the loop, which you deliver at the end:

Code:
int amt;
buffer tosell;
for i from 1 to 4000 {
   item it = to_item(i);
   if (is_tradeable(it) && stash_amount(it) > 0) {
      amt = stash_amount(it);
      if (take_stash(amt,it)) {
         if (length(tosell) != 0) tosell.append(", ");
         tosell.append(amt+" "+to_string(it));
      } else print("There was a problem pulling "+amt+" "+it+" from the stash.  Stash contents may have changed.","red");
   }
}
cli_execute("mallsell "+tosell+"; undercut");

If I'm not mistaken, mafia will automatically handle splitting that into groups of 11.
 
Last edited:

Bale

Minion
Really? Mafia would split up that mallsell request for me? Coolness!

Though I'm going to stick with using mall_price() instead of undercut simply because I've been burned by it too many times when someone was selling some item really cheap at a limit of 1/day. I really like that mall_price() will skip those guys. I'm not that obsessed about selling everything instantly.

I really like these lines:
Code:
         if (length(tosell) != 0) tosell.append(", ");
         tosell.append(amt+" "+to_string(it));
So much smoother than my own approach of removing the trailing comma if it was the last item.

Can I ask you a question? I've noticed that you sometimes seem to add functions onto the ends of variables separated by a "." and that puzzles me. Does tosell.append(", ") differ from append(tosell, ", ")? Is there some benefit to one over the other? What rules govern this transposition and when is it not legal to do so?
 

zarqon

Well-known member
Good question...:) I'm not the person to ask. I could explain from a Pascal standpoint, but not a Java or ASH one. In Pascal these would be methods of certain objects or types, so for a variable that is a certain object or type, the method can be called in this manner, since the method "belongs" to the object/type.

As for Java/ASH, I only know that functionally you can do that when the first parameter for an ASH function is the same as its return type, in which case the variable before the . is the first parameter, and is then assigned the return value.

I have no idea which is faster. I only know that I like typing less, so I use that from time to time. Hehe.

Perhaps someone more familiar with Java can set us both straight on this.
 

Bale

Minion
Thanks to your answer, I know more than I did. Now I'll join you in hoping that someone more familiar with Java will cast greater illumination upon us.
 

jasonharper

Developer
The ability to write function calls as either f(a,b) or a.f(b) is unique to ASH, as far as I know. The latter form more closely resembles the underlying Java implementation, but both forms do exactly the same thing, and there should be no difference in speed between them.

There may be differences in readability, especially if several function calls are chained together. Consider:
c(b(a(x)));
vs.:
x.a().b().c();
The second form actually puts the function calls in the order in which they'll be performed. And, if any of them have a second parameter, it will be a lot clearer just which function that parameter goes with.
 

zarqon

Well-known member
Thanks again Jason for the behind-the-scenes explanation.

Theman123: use the most recent one I posted and let me know if it works! Otherwise, the one I posted first will work for sure. (ign: same as here)
 

Bale

Minion
Don't bother rewarding me. I think zarqon came up with most of it while I was just having fun learning from him so that I could improve my after-run "sell off everything" script.

Thanks Jason. Can I ask one more clarification: Is it as zarqon said that can only be done when the first parameter must be the same as the return type?
 
Last edited:
Top