Quick script to autosell all in the mall priced at 999,999,999?

daychilde2

New member
Maybe my google-fu is just bad, but I was hoping to find a simple script that would auto-sell everything in my store that's priced at 999,999,999 - because doing an autoprice leaves things that probably won't sell at that price. Surely I'm not the only one who wants this or has thought of this, but maybe I just can't find where it's been done?

Many thanks in advance, and I apologize if I've just missed a simple answer somewhere.
 

Bale

Minion
As far as I know you're the only one who has ever wanted that. Something like this I guess.

Code:
int [item] nosell;

batch_open();
foreach it,x in get_shop()
   if(shop_price(it) == 999999999) {
      nosell[it] = x;
      take_shop(it);
   }
batch_close();

batch_open();
foreach it, x in nosell;
   autosell(x, it);
batch_close();
 

fronobulax

Developer
Staff member
I've never needed such a script because I let Bale's OCD price things for me. As noted in the ManageStore thread ManageStore will autosell things that are at mall minimum and unlikely to sell but it is built with the assumption that if something is not priced at mall minimum the user had their reasons. Nothing I use on a regular basis actually prices at 999,999,999 so I did not consider that.
 

adeyke

Member
While we're on the topic, is there an easy way to reset the price of everything in the mall store to 999,999,999?
 

daychilde2

New member
As far as I know you're the only one who has ever wanted that. Something like this I guess.

Code:
int [item] nosell;

batch_open();
foreach it,x in get_shop()
   if(shop_price(it) == 999999999) {
      nosell[it] = x;
      take_shop(it);
   }
batch_close();

batch_open();
foreach it, x in nosell;
   autosell(x, it);
batch_close();

Many many thanks. Weird that nobody has wanted to do this before. I wonder if there's something I'm missing on my logic - which is basically that if things are selling at mall minimums, I should be able to easily re-buy anything that's sold....

On to running the script. It looks to me like that's ASH as opposed to a regular script, so I threw it in a file.ash and tried to load it. "Unknown variable 'x' on line 13", i.e. in the second batch. I've looked at the ASH scripting guide and tried a couple of things (like putting the whole thing in a main(); trying to declare x as a global variable) and.... uh... I'm kinda stuck. I speak PHP, but this is more C-like, and I'm a bit lost. :/

If it's not a simple thing that you see, don't worry about it, I'll sit down with the ASH scripting guide and try to basically work out how to re-write this. Probably won't be pretty, but that's okay. :) I don't want to be a hassle, especially when you basically wrote a solution for me.
 

Bale

Minion
Oh. I had an extra semi-colon. x is defined in the scope of the foreach statement. Because of that semi-colon it was cut off from the place where it is used, hence the error

Try this:

Code:
int [item] nosell;

batch_open();
foreach it,x in get_shop()
   if(shop_price(it) == 999999999) {
      nosell[it] = x;
      take_shop(it);
   }
batch_close();

batch_open();
foreach it, x in nosell
   autosell(x, it);
batch_close();
 
Top