Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # desired_amts holds a list of items and the amount you want to stock in your store.
- int [string] desired_amts;
- # prices holds a list of items (hopefully the same list as desired_amts) and the
- # prices you want to sell them at. MAKE SURE THE PRICE IS RIGHT!
- int [string] prices;
- # 7 meat paste, 123 meat each.
- desired_amts["meat paste"] = 7;
- prices ["meat paste"] = 123;
- # 2 meat stacks at 321 meat each.
- desired_amts["meat stack"] = 2;
- prices ["meat stack"] = 321;
- # Main loop.
- while(1 == 1) {
- # Force Mafia to reload the prices, otherwise it doesn't notice
- # when stuff gets sold.
- refresh_shop();
- foreach itemname in desired_amts {
- int mall_amt = shop_amount(to_item(itemname));
- # How much do we need to add to the mall to bring the stock up?
- int deficit = desired_amts[itemname] - mall_amt;
- print("You have " + mall_amt + " " + itemname + " in mall");
- print("You want " + desired_amts[itemname] + " " + itemname + " in mall");
- if(deficit > 0) {
- print("You have " + mall_amt + " " + itemname + " in mall");
- print("You want " + desired_amts[itemname] + " " + itemname + " in mall");
- int inv_amt = item_amount(to_item(itemname));
- print("You have " + inv_amt + " " + itemname + " in inventory");
- if(inv_amt >= deficit) {
- print("Stocking " + deficit + " " + itemname + " in mall");
- put_shop(prices[itemname], 0, deficit, to_item(itemname));
- } else if(inv_amt > 0) {
- print("Stocking " + inv_amt + " " + itemname + " in mall");
- put_shop(prices[itemname], 0, inv_amt, to_item(itemname));
- } else {
- print("Out of " + itemname + ": can't restock.");
- }
- } else if(deficit < 0) {
- print("You have " + mall_amt + " " + itemname + " in mall");
- print("You want " + desired_amts[itemname] + " " + itemname + " in mall");
- int surplus = -deficit;
- int inv_amt = item_amount(to_item(itemname));
- print("Taking " + surplus + " " + itemname + " from mall");
- take_shop(surplus, to_item(itemname));
- }
- }
- # waitq is wait, without the countdown.
- waitq(5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement