mall_autosell: autosell "junk" items from your store

rlbond86

Member
mall_autosell: autosell "junk" (minimum price) items from your store

mall_autosell 1.1

This is my first script! mall_autosell requires ZLib.

mall_autosell searches through all of your items in the mall. If the mall price of these items is close to the minimum sell price, it takes those items out of your store and autosells them instead. The user can configure what percent above minimum is "close", the default is 5% -- so something that has a minimum mall price of 200 meat, will be autosold if the current mall price is 210 or lower, by default. The user can also configure a maximum mall price to apply this to, to prevent autoselling "expensive" items, with a default of 5000 meat. All sales are output in the CLI.

The idea is, if something is in the mall at minimum price, it is almost certainly common, and your copies of the item are probably not going to be bought. Better to just autosell them, IMO. This makes it easier to sell stuff, too, since you can just put everything in your mall instead of looking up the price and then deciding whether to mallsell or autosell.

NOTE: there's no way in ash (that I can find) to find the price that you are selling an item for. So this script uses the mall price. This means you could have an item in your store priced at 999,999,999, but if the mall price is 100 it will be autosold.

Comments are welcome. I've tested it quite a bit, but if you're paranoid, you can first test the script results by running the following code in the gCLI:
Code:
ash import "mall_autosell"; testsell();

1.1 - added easier test mode, and a few misc. tweaks
1.0 - initial release.
 

Attachments

  • mall_autosell.ash
    3.6 KB · Views: 182
Last edited:

mredge73

Member
NOTE: there's no way in ash (that I can find) to find the price that you are selling an item for. So this script uses the mall price. This means you could have an item in your store priced at 999,999,999, but if the mall price is 100 it will be autosold.

Here is a snippet from my function library:

Code:
//Shop Parseing  
//Special Thanks to StDoodle
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
int parse_num(string n) {
    string t; matcher m;
    t = replace_string(n, ",", "").to_string();
    m = create_matcher("\\d{1,9}",t);
    if (m.find()) return t.to_int();
    return -1;
}

int limit_parse(string l) {
    if (!contains_text(l, ">(unlimited)<"))
        return (is_integer(l)) ? l.to_int() : 0;
    return 0;
}

mall_item[item] ShopParse()
{
    //define return value
    mall_item [item] my_mallstore;
    //clip page
    string page = visit_url("managestore.php");
    matcher m1 = create_matcher("<div.+?><b>Store Inventory:</b>(.+?)</table></div>",page);
    if (m1.find()) 
    {
        page = m1.group(1);
        matcher m2 = create_matcher("<tr><td><img.+?></td><td>(.+?(?:\\s\\(\\d{1,3}(?:,\\d{3}){0,2}\\))?)</td><td>(\\d{1,3}(?:,\\d{3}){0,2})</td><td>(.+?)</td>.+?</tr>",page);
        matcher m3; 
        item thing; 
        int qty; 
        while (m2.find()) 
        {
            m3 = create_matcher("(.+?)\\s\\((\\d{1,9})\\)", m2.group(1));
            if (m3.find()) 
            {
                thing = m3.group(1).to_item();
                qty = parse_num(m3.group(2));
            } 
            else
            {
                thing = m2.group(1).to_item();
                qty = 1;
            }
            my_mallstore[thing].price = parse_num(m2.group(2));
            my_mallstore[thing].qty=qty;
            my_mallstore[thing].limit= limit_parse(m2.group(3));
            
        } 
        //save map
        //if (map_to_file(my_mallstore, my_name().to_lower_case() + "_mall.txt")) print("Store snapshot saved.", "green");
        //else print("Error saving store snapshot; please try again.", "red");
    }
    else { print("Unable to find any mall items.","red");}
    return my_mallstore;
}

int ShopPrice(item widget)
{
    mall_item [item] myshop = ShopParse();
    if (myshop contains widget)    return myshop[widget].price;
    return 0;
}

Use ShopPrice (item) to get the current price listed in your mall.
I haven't used it in a while so feel free to test it out.
 

rlbond86

Member
Cool, I will give it a test. Though, I'm actually happy with how this script works. Maybe if there's some sort of error I can use this code to return items back.
 

fronobulax

Developer
Staff member
Two comments.

I'm lazy and use the scripts menu and the mouse. If the test mode (which I might call simulate) were triggered by a pop up asking me to set a boolean for simulate when I run from the scripts menu, I would have tried it already. My laziness does not have to mean work for you but it does make for a script that is friendly to a wider variety of usage styles.

Second, I would be interested on knowing some sales volume data before I actually allowed a script to autosell stuff I have put in the mall. I have seen cases where stuff I have priced at 100 has sold anyway. If the sales volume were such that, say, 25% of the available stock turned over in a week then I'd let the stuff sit and hope to be part of the luck 25% or even invest in advertising to increase the chances of that happening.

There is code to get sales volume in my ManageAlice that I stole from ZapWizard. Both are easy to find so I will let you search rather than post links myself.

Very good idea, regardless.
 

rlbond86

Member
Two comments.

I'm lazy and use the scripts menu and the mouse. If the test mode (which I might call simulate) were triggered by a pop up asking me to set a boolean for simulate when I run from the scripts menu, I would have tried it already. My laziness does not have to mean work for you but it does make for a script that is friendly to a wider variety of usage styles.

That's a pretty good idea, maybe I can implement it easily.

Second, I would be interested on knowing some sales volume data before I actually allowed a script to autosell stuff I have put in the mall. I have seen cases where stuff I have priced at 100 has sold anyway. If the sales volume were such that, say, 25% of the available stock turned over in a week then I'd let the stuff sit and hope to be part of the luck 25% or even invest in advertising to increase the chances of that happening.

There is code to get sales volume in my ManageAlice that I stole from ZapWizard. Both are easy to find so I will let you search rather than post links myself.

Very good idea, regardless.

I will definitely check that out, it seems useful.
 

Fwoosh

New member
Hmm. Just something I'd like to point out:

It auto-sold all my murky potions (I had 70 in the mall) because there was a bloke selling murky potions at the minimum selling price.

Does your script only consider the first price it comes across?
 

lostcalpolydude

Developer
Staff member
Without looking at the script, it probably uses mall_price( item ), which returns the price of the fifth cheapest of the item. If it was possible to buy at least 5 from that one person, the script couldn't possibly see any price besides mall minimum (because mafia won't allow it, in order to prevent people using mafia to run a mallbot).
 

fronobulax

Developer
Staff member
Hmm. Just something I'd like to point out:

It auto-sold all my murky potions (I had 70 in the mall) because there was a bloke selling murky potions at the minimum selling price.

Does your script only consider the first price it comes across?

Let's continue the discussion over here.
 
Top