Advertisement
Guest User

MallRestock.ash

a guest
Oct 31st, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. int [string] desired_amts;
  2. int [string] prices;
  3.  
  4. # 7 meat paste, 123 meat each.
  5. desired_amts["meat paste"] = 7;
  6. prices ["meat paste"] = 123;
  7.  
  8. # 2 meat stacks at 321 meat each.
  9. desired_amts["meat stack"] = 2;
  10. prices ["meat stack"] = 321;
  11.  
  12. for i from 1 to 5 by 1 {
  13. refresh_shop();
  14. foreach itemname in desired_amts {
  15. int mall_amt = shop_amount(to_item(itemname));
  16. int deficit = desired_amts[itemname] - mall_amt;
  17. print("You have " + mall_amt + " " + itemname + " in mall");
  18. print("You want " + desired_amts[itemname] + " " + itemname + " in mall");
  19. if(deficit > 0) {
  20. print("You have " + mall_amt + " " + itemname + " in mall");
  21. print("You want " + desired_amts[itemname] + " " + itemname + " in mall");
  22. int inv_amt = item_amount(to_item(itemname));
  23. print("You have " + inv_amt + " " + itemname + " in inventory");
  24. if(inv_amt >= deficit) {
  25. print("Stocking " + deficit + " " + itemname + " in mall");
  26. put_shop(prices[itemname], 0, deficit, to_item(itemname));
  27. } else if(inv_amt > 0) {
  28. print("Stocking " + inv_amt + " " + itemname + " in mall");
  29. put_shop(prices[itemname], 0, inv_amt, to_item(itemname));
  30. } else {
  31. print("Out of " + itemname + ": can't restock.");
  32. }
  33. } else if(deficit < 0) {
  34. print("You have " + mall_amt + " " + itemname + " in mall");
  35. print("You want " + desired_amts[itemname] + " " + itemname + " in mall");
  36. int surplus = -deficit;
  37. int inv_amt = item_amount(to_item(itemname));
  38. print("Taking " + surplus + " " + itemname + " from mall");
  39. take_shop(surplus, to_item(itemname));
  40. }
  41.  
  42. }
  43. waitq(5);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement