Requesting mall script

arcticwolf15

New member
Hi. First post. Anyway, I recently started using KoLmafia and I want it to automatically put things in the mall for me. Unfortunately, I don't know how to script. If possible, can someone make me a script that does the following? Here's what I want:

Hats and equipment that I have multiple of:
Put all but 1 in mall at default price

Accessories:
Put all but 3 in mall at default price, all but 1 if I can't equip more than one (if possible)

Can anyone do this?
 

philmasterplus

Active member
Assuming that by "default" price you mean the lowest price in the mall, it cannot be done because KoLmafia does not allow you to access it. However, you can use the price of the 5th cheapest item in the mall instead. I'm afraid I don't have the time to whip it up myself, but see the KoLmafia wiki; in particular, put_shop() and get_inventory().

To do it manually: From the Item Manager window, elect "Equipment", then the type of equipment you want to sell (hats/pants/accessories), then "all but usable", and finally "place in mall". Repeat for other types of equipment. Finally, go to the Store Manager window and click "auto reprice."
 
Last edited:

Theraze

Active member
Well, from what it says in the wiki at http://wiki.kolmafia.us/index.php?title=Put_shop it appears that if you give it a price of 0, it defaults to the 999 million price.

What you probably want to do is parse through your inventory, if the item type is accessory and you have more than 3, drop to shop. If item type is not accessory and you have more than 1, drop to shop.

Something similar to, but not necessarily (based on a bit of wiki reading):
Code:
batch_open();
int[item] inventory = get_inventory() ;
foreach it in inventory
   if ( item_type(it) == "accessory" && inventory[it] > 3 )
      put_shop( 0, 0, (inventory[it] - 3), it ) ;
   else if ( item_type(it) != "accessory" && can_equip(it) && inventory[it] > 1 )
      put_shop( 0, 0, (inventory[it] - 1), it ) ;
batch_close();

What that should do is, batch items, so it works in groups of 11... less server hits. Map your current inventory, and on each item, check if it's an accessory. If so, and you have more than 3, drop all except 3 to your shop at either max price or current price. If not an accessory, but still equippable (should get weapons, hats, pants, shirts, etc, but skip food items) then drop to mall all but 1, as long as there is more than one...
 

Winterbay

Active member
That seems like it should be working. If you then want to set the price to a lower one you can do so by using the cli-command "undercut" by adding a line of
Code:
clie_execute("undercut");
which will set the price to somewhere below the current lowest price I think.
 

Theraze

Active member
That seems like it should be working. If you then want to set the price to a lower one you can do so by using the cli-command "undercut" by adding a line of
Code:
cli_execute("undercut");
which will set the price to somewhere below the current lowest price I think.
Except that he said:
What I mean is the 999,999,999 price that is set when you don't specify a price.

He actually WANTS the 999,999,999 price bit... :) I'd have tried to parse cheapest or added undercut or something like that in there if he'd gone for that, but... niche script, I suppose.

Edit: From looking, if you use mall_price(it) for the first variable instead of using 0, it'll price the item the same as undercut would, except it'll do it on the initial item pricing. Slightly less niche, but...
 
Last edited:

Winterbay

Active member
Except that he said:

He actually WANTS the 999,999,999 price bit... :) I'd have tried to parse cheapest or added undercut or something like that in there if he'd gone for that, but... niche script, I suppose.

Edit: From looking, if you use mall_price(it) for the first variable instead of using 0, it'll price the item the same as undercut would, except it'll do it on the initial item pricing. Slightly less niche, but...

True, I just added that for completeness :)

I think if you use undercut you might get less server hits than if you use mall_price() for every batch but I'm not sure.
 

Theraze

Active member
Well, it still has to look up each item regardless... the question is whether it posts the item price once (mall_price, put_shop, one page-hit each, 2 total) or twice (put_shop, undercut - lookup and update prices - causing 3 page hits). Unless I misunderstand, the mall_price method should be less server hits total... The only way it would be more is if it did a mall_price on items that weren't being posted. Even in the case of the shop already being populated, undercut should update the prices with the current prices...

I suppose if undercut were using historic prices, that could be less hits, but you wouldn't want something based on current mall prices to use historic data, even if it was merely 6 hours old. If undercut were a KoL function instead of being a function of KoLmafia, that could save hits as well... but as it's a mafia function, using (presumably) accurate data, I don't see it actually SAVING server hits...
 

slyz

Developer
I'll see your code and raise you a
PHP:
int[item] inventory = get_inventory() ;
batch_open();
foreach it in inventory
     if ( (to_slot(it) != $slot[none]) && (available_amount(it) > 1+2*to_int(item_type(it) == "accessory")) )
          put_shop( 0, 0, (inventory[it] - (1+2*to_int(item_type(it) == "accessory"))), it ) ;
batch_close();

arcticwolf15: know that in both snippets, 'equipment' also means familiar equipment, although you probably don't have more than one of each.
 

fronobulax

Developer
Staff member
If I put something in the mall with a price of 999,999,999 won't I have to incur a server hit (or two) some point in the future to change that to a different price? I presume this is not the "too cheap to buy a Display Case" ploy.

Also someone (Bale?) reported a case where batching the requests resulted in a Java "Out of Memory" error. That is not a reason to avoid the batch but it is something to be aware of.
 

arcticwolf15

New member
I'll try Thereaze's and slyz's codes. I'll report back on how they work.

Slyz' works, and so does the other one. However, I prefer Slyz' because the other one put up all of my stuff in my miscellaneous in there, I think. I didn't want that. I'll be using his.
 
Last edited:

Theraze

Active member
Odd... should items in Misc qualify for can_equip? Would that be a bug if it claims they're equippable and you actually can't? *shrugs*
 

Bale

Minion
Also someone (Bale?) reported a case where batching the requests resulted in a Java "Out of Memory" error. That is not a reason to avoid the batch but it is something to be aware of.

The error doesn't occur for me until I'm at more than 20 transfers, so now I do a batch_close(); batch_open(); when I get to 165 items malled. That give me plenty of leeway.
 

slyz

Developer
Odd... should items in Misc qualify for can_equip? Would that be a bug if it claims they're equippable and you actually can't? *shrugs*
Apparently, EquipmentManager.canEquip() doesn't check if the item passed on is an equipment: it just checks that you comply the stat requirements. If an item doesn't have any stat requirements, Mafia returns true.
I think adding
PHP:
if ( !EquipmentDatabase.isEquipment( ItemDatabase.getConsumptionType( itemId ) ) )
{
	return false;
}
on line 1345 should fix that.
 

philmasterplus

Active member
Also, kind-of sad that there is no base implementation of is_equipment() when the equivalent clearly exists in the Java source code :(
Using to_slot() != $slot[none] is imperfect because it considers stickers as equipment, something that most players would find counterintuitive.
 

slyz

Developer
Using to_slot() != $slot[none] is imperfect because it considers stickers as equipment, something that most players would find counterintuitive.
I hadn't thought about the possibility, but:
Code:
> ashq print( to_slot($item[UPC sticker]) );

none
It just happens that to_slot() doesn't know about stickers =)
 

philmasterplus

Active member
Eh. I shouldn't post things that I have neither tested nor verified by reading KoLmafia source code. (I'm afraid I can't test it at the moment, though)

So, how does it handle fake hands? The wiki needs updating.
 
Top