ManageStore and CFStat - Weed out your store


ManageStore is not working. I am aware of that and will fix, although not necessarily in the next three days. The code needs to adjust to the changes in the Store/Mall interface.


New member
Looking forward to the update! I've got WAY too much stuff stagnating in my inventory. I need to clean house!


New member
I may have been wrong. When adapting the store_value function for my needs it seems as if I either broke something or the number the script picks up is not the price but the shop_amount meaning that both .myPrice and .numStore is the same number and neither of them is my current price. You may want to double check my findings. My current function currently looks like this:
record mall_item {
    item thing;
    int price;
    int qty;

int store_value() {
    int value = 0;
    int i = 0;
    int k;
    int l;
    mall_item [int] my_mallstore;
    string start = "<td valign=\"center\"><b>";
    int ss = length(start);
    string s2 = "<td align=\"center\"><span class=\"tohide\">";
    int ss2 = length(s2);
    string page = visit_url("backoffice.php?which=1");
    //Skip over a whole bunch of stuff that won't yield, item, price pairs
    int j = index_of(page, ">Actions<");
    if (j > 0) {
       page = substring(page, j);
       k = index_of(page, start);
       //As long as we think there is one pair, process it without
       //checking to see of both parts are there.
       while (k > 0) { 
          l = index_of(page, "</b></td>", k);
          my_mallstore[i].thing = to_item(substring(page,k+ss,l));
          page = substring(page, l);

          k = index_of(page, s2);
          l = index_of(page, "</span><input", k);
          my_mallstore[i].price = to_int(substring(page,k+ss2,l));

          page = substring(page, l);
          k = index_of(page, start);

          my_mallstore[i].qty = shop_amount(my_mallstore[i].thing);
          //print("Item " + my_mallstore[i].thing + " is in the store for " + my_mallstore[i].price + " (" + my_mallstore[i].qty + ")");
          i = i + 1;
    for m from 0 to count(my_mallstore)-1
        value = value + my_mallstore[m].price * my_mallstore[m].qty;
    return value;


I'm not in an especially mafia friendly environment for several days but I will check when I can. Thank you for the feedback.


Definitely bugged. Not getting my price properly. Wish I had more than 5 minute chunks to look at this, but I will.


New member
The code I quoted above works and used yours as a basis so should be possible to just adapt back without too much trouble hopefully. I stepped through the HTML with your function as a starting point and the print statement shows quantity and price fine so seems to be working.


ManageStore apparently uses kBay, which for now appears to be going away. That jumped out at me as I was putting together a json file of SVN scripts for roippi to use.


Yes. I have it on my todo list to clean it out but since the announcement on GD held out the possibility that someone might take it over, I figured I'd hold off.

Right now I'm thinking that what makes sense, (because I am lazy) is to either autosell stuff that was languishing in the store or just pull it and let it sit in inventory. (Whereas before it either autosold or kBay'd). That lets people who want to pulverize do so. If someone wants to make a case that the choices should be autosell or pulverize, I'll certainly consider it, but at some point what we really need is to let OCD handle the disposition and use the "is languishing" status to trigger a reminder for the user to reconsider what OCD does.


I'll certainly consider it, but at some point what we really need is to let OCD handle the disposition and use the "is languishing" status to trigger a reminder for the user to reconsider what OCD does.

OCD is still holding out hope for a replacement to kBay. If that doesn't happen soon, OCD will uncategorize all currently kBayed Items and no longer have kBay as an action. Thought that might be relevant information.


I have an unreleased version that I am considering pushing out. Compared to the current version it does the following:

It now checks for items available to the player from NPC stores and offers to "do something" if the player's store's price is greater than the NPC store's price.

"Do Something" is now limited to "Pull all from Store" or "Pull all from Store and Autosell". The kBay option is no more and the pulverize suggestion remains unimplemented (but see below).

Optionally, if something is done to an item, the script will delete the item from the OCD database, provided that the OCD data file exists for the character, the item is in the file and the action for the item is "MALL".

This last is worthy of some discussion. From a mechanical stand point it makes me nervous because I have not implemented a lot of error checking to find and change the file, and I am using a number of OCD implementation details that in a different software environment would be private to Bale and OCD. Bale is allowed to change those and it is my problem if it breaks my script or causes my script to do something that breaks OCD. I can live with that because Bale is a pretty reasonable fellow but it does make me nervous.

I went this way for a couple of reasons. First it seemed stupid to have OCD keep sending stuff to the store that would later be pulled and disposed of by ManageStore. Second, deleting the item makes it uncharacterized in OCD land and gives the user the option to obsessively send it back to the mall, autosell it next time, pulverize it or whatever. So this is a good thing for me because it means I don't have to duplicate support for kBay, should it return, nor deal with the nuances of pulverize.

But I ran it for one character and suddenly had 300+ OCD entries to make and that, combined with my nervousness about maintaining compatibility with OCD's internals, makes me wonder whether it is a good idea or whether the implemention needs to be more robust, such as making a backup of the OCD file or using even more knowledge of OCD's internals than I already am using.

Does anyone care or have comments? I know there are several people who have not deleted the notify command and so have run this at least once :)

The character where the OCD feature is useful is a never ascending obsessive collector so if it is not in the DC or part of an attempt at a leader-board I might as well sell it one way or another. The character where I regretted this is an ascending obsessive collector. Thus, with certain exceptions, I want one of everything in the display case and a second, if I have one, in inventory. This means I have almost one of everything in Hagnk's and means if something about the game changes in run I can react to it immediately with pulls. This made the PITA since ManageStore deleted entries but OCD's mass default characterization kept zero for the ones it decided to autosell. In this case Excel was my friend, but if what my code did annoyed me then perhaps it is not the good idea it seemed like at the time.


New member
I have the OCD Inventory Control, and I use ManageStore in simulate mode, so that from time to time I can check if I should change an entry to OCD for an item.
I'm not sure I can offer great insight, but I can say how I use both of the scripts and what is specific for me.

I don't like the idea of ManageStore deleting entires for items in OCD.
Partly because I do not want to figure out again if I was saving 1 or 3 or 50 of an item in my inventory prior to malling, or now be it, autoselling.
Partly because I haven't yet managed to make an entry for every item in my inventory in OCD. (I know, I know, but there are far to many items in this game :( ) So for me, if ManageStore were to delete entries for items and decategorize them, I woulnd't be able to differ those from the other hundreds of items not yet categorized.
I understand that my case is specific, and that most people have all the items already sorted in OCD.

I prefere being given a list of items, that I can go through and manually change in OCD.
That said, I can see why some people would appreciate the option to have changes made to OCD automatically.
I only would ask that be an option, that can be turned off.

Regardless, many thanks for making this script!


Thanks for the feedback. I have decided that actually deleting the entry from OCD is not want I want and for the same reason it is not what you want - I only want to MALL or AUTO the excess items for some definition of excess. Changing the existing MALL entry to AUTO works until someone wants to pulverize so your suggestion, that I just log the item, is probably better than what I was thinking. Off to tweak some code. Thank you.


New member
I had intended to post on this, but then I forgot... I use both OCD and ManageStore very infrequently and would probably also not like to have to recategorise the items that I no long remember what I had them set up as. Printing a log of what should be removed and what it suggest I do with it is fine.


Finally pushed an update.

I removed support for kBay. I had experimental support to delete entries from an OCD file if things were pulled from a store. That code has been left in and disabled but it is a two line change to re-enable it if someone really thinks it is a good idea.

If something is pulled from a store then there will be a entry in a file named ManageStoreFauxOCDdata_<username>.txt. Format is the same as OCD. It will always add entries so users may want to manage it manually by deleting entries once they have modified the OCD preferences.

zlib verbosity of 5 and 6 will add some more information about why something was done.

The checkNPC option was added. If selected it will check whether an item is available in a NPC store and pull (or pull and autosell) if the NPC price undercuts. It uses the function npc_price so if npc_price varies with path or equipment or inventory then so will the check NPC results.


New member
Downloaded this today and ran it and it ignored a bunch of stuff in my store set at 999,999,999 after a KoLMafia autopricing, and only sold about a dozen items - frilly skirt, spring, cog, don't remember what else.

Am I misunderstanding what should happen? :) I thought because KoLMafia didn't reprice those items, this script would basically sell them. I've tried different combos of vars, including Coldfront volume of 0 and 99999, which should cover either way it's supposed to work...

Thanks in advance for your advice. :)


Probably a misunderstanding based on a lack of clarity on my part. The overarching goal is to identify things in your store that will probably never sell. A loose definition of such an item is one that is priced at the mall minimum, that value is effectively the historical price and you have more in your store than were sold in the past X days where X is related to the ColdFront volume factor.

I didn't consider price setting because sometimes people have reasons for choosing a price other than the mall minimum and when the goal is to set a reasonable low price I use Bale's OCD for that. What triggered this script is I would periodically empty my store, run OCD (which had the effect of resetting prices) and realized some things were never selling so I was pulling them and OCD was putting them back in the store at a minimum price.