Help making a ash cleanup script

HasteBro

Member
I'm trying to make this script, I haven't really started writing it, just got the functions I think I should be using.

My plan is to transform these 2 cli lines into ash:
Code:
mallsell * Game Grid Token, * scrumptious reagent, * dry noodles, * little paper umbrella, * coconut shell, * magical ice cube, * "Bricko Brick", * "Bricko Eye Brick", * "drink me" potion, * sugar sheet, * pumpkin, * llama lama gong, * paint bomb, * transporter transponder
mallsell -3 agua de vida, -1 prismatic wad, -100 disassembled clover, -20 scratch 'n' sniff unicorn sticker, -20 scratch 'n' sniff UPC sticker

The reason I want to do that is because the CLI aborts if I don't have the items or specified amounts.

But, given that my experience on scripting is near null, I have a few questions.

First, what's the operator or command for placing "all but X" of an item somewhere?

Second, how do I use the 'int mall_price' of an item to set my own price for that item? More specifically I want to undercut the mall price by 100 meat in some cases.

Lastly, how do I avoid pricing my items at minimum if someone just happens to be doing an AR or a giveaway of that item a the time?

I know I could just do a 'int item_amount' plus the 'cli_execute', but where's the fun in that? :cool:

Anyway, thanks in advance.
 
Well, I've already created the ultimate cleanup script, but I'll give you a hand with this anyway.


First, what's the operator or command for placing "all but X" of an item somewhere?

There is no operator, but we have a function. Generally we use item_amount(item). If we want to keep 10, then we can use max(item_amount(item) - 10, 0)

Second, how do I use the 'int mall_price' of an item to set my own price for that item? More specifically I want to undercut the mall price by 100 meat in some cases.

Oh dear. That is several questions. mall_price() is actually the price of the 5th cheapest purchasable item. If you want to undercut it you can use

PHP:
item it = $item[spicy mushroom quesadilla];
int price = max(mall_price(it) - 100, 2 * autosell_price(it)); 
// Minimum price is twice autosell
put_shop(price, 0, item_amount(it), it);

I did something fancy in there. Notice that max() will return the higher of two values. In this case we want the highest of twice autosell or 100 meat under mall_price().

Lastly, how do I avoid pricing my items at minimum if someone just happens to be doing an AR or a giveaway of that item a the time?

I think I covered that in the previous answer. Just raise 2 * autosell to something higher.

Now for bonus tips! Take a look at the following code. batch_open() and batch_close() are used to have transfers happen in groups of 11 to reduce server hits. Also see the power of $items[] (note the plural).

Code:
batch_open();
foreach it in $items[Game Grid Token,scrumptious reagent, dry noodles, little paper umbrella, coconut shell, magical ice cube, Bricko Brick, Bricko Eye Brick, drink me potion, sugar sheet, pumpkin, llama lama gong, paint bomb, transporter transponder]
	put_shop(mall_price(it), 0, item_amount(it), it);
batch_close();
 
Last edited:
Back
Top