Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.30 KB | None | 0 0
  1. # desired_amts holds a list of items and the amount you want to stock in your store.
  2. int [string] desired_amts;
  3. # prices holds a list of items (hopefully the same list as desired_amts) and the
  4. # prices you want to sell them at. MAKE SURE THE PRICE IS RIGHT!
  5. int [string] prices;
  6.  
  7. # 7 meat paste, 123 meat each.
  8. desired_amts["meat paste"] = 7;
  9. prices      ["meat paste"] = 123;
  10.  
  11. # 2 meat stacks at 321 meat each.
  12. desired_amts["meat stack"] = 2;
  13. prices      ["meat stack"] = 321;
  14.  
  15. # Main loop.
  16. while(1 == 1) {
  17.     # Force Mafia to reload the prices, otherwise it doesn't notice
  18.     # when stuff gets sold.
  19.     refresh_shop();
  20.     foreach itemname in desired_amts {
  21.         int mall_amt = shop_amount(to_item(itemname));
  22.         # How much do we need to add to the mall to bring the stock up?
  23.         int deficit = desired_amts[itemname] - mall_amt;
  24.         print("You have " + mall_amt + " " + itemname + " in mall");
  25.         print("You want " + desired_amts[itemname] + " " + itemname + " in mall");
  26.         if(deficit > 0) {
  27.             print("You have " + mall_amt + " " + itemname + " in mall");
  28.             print("You want " + desired_amts[itemname] + " " + itemname + " in mall");
  29.             int inv_amt = item_amount(to_item(itemname));
  30.             print("You have " + inv_amt + " " + itemname + " in inventory");
  31.             if(inv_amt >= deficit) {
  32.                 print("Stocking " + deficit + " " + itemname + " in mall");
  33.                 put_shop(prices[itemname], 0, deficit, to_item(itemname));
  34.             } else if(inv_amt > 0) {
  35.                 print("Stocking " + inv_amt + " " + itemname + " in mall");
  36.                 put_shop(prices[itemname], 0, inv_amt, to_item(itemname));
  37.             } else {
  38.                 print("Out of " + itemname + ": can't restock.");  
  39.             }
  40.         } else if(deficit < 0) {
  41.             print("You have " + mall_amt + " " + itemname + " in mall");
  42.             print("You want " + desired_amts[itemname] + " " + itemname + " in mall");
  43.             int surplus = -deficit;    
  44.             int inv_amt = item_amount(to_item(itemname));
  45.             print("Taking " + surplus + " " + itemname + " from mall");
  46.             take_shop(surplus, to_item(itemname));
  47.         }
  48.        
  49.     }
  50.     # waitq is wait, without the countdown.
  51.     waitq(5);
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement