Advertisement
Cancelor

CAN-Trade.txt

Sep 13th, 2020 (edited)
4,921
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //////////////////////////////////////////////////////
  2. ////   call "https://pastebin.com/raw/Xb2pDKa6    ////
  3. //////////////////////////////////////////////////////
  4. echo ">>> Starting CAN-Trade.txt <<<"
  5.  
  6. label TradeScript
  7.     gosub LoadVariables
  8.  
  9. label start
  10.     if  m_context.maintenanceStart > 0 gosub LoadVariables
  11.     if  m_context.maintenanceStart > 0 gosub waitMaint
  12.     #if res == 0 if city.resource.gold > MinGold echo "Minimum Gold {FormatNumber(MinGold)} has been met"
  13.     if city.tradesArray.length > (city.getBuildingByTypeId(23).level - 2) execute "canceltrade " + city.tradesArray[0].id
  14.     if city.tradesArray.length > (city.getBuildingByTypeId(23).level - 2) repeat
  15.     //minres = [(city.reservedResource.food + 1b) * 10,10,10,10,(BuyPrice(res) * 100m) + MinGold  ]
  16.     minres = [(MinFood),20m,20m,20m ]
  17.     if BuyPrice(res) < resLvl.bp[res] if city.resource.gold > MinGold echo "Minimum Gold {FormatNumber(MinGold)} required to buy {ResourceIntNames[res]}"
  18.     if BuyPrice(res) < resLvl.bp[res] if city.resource.gold > MinGold execute "buy {ResourceIntNames[res]} 99999999 {min(BuyPrice(res),SellPrice(res))}"
  19.     if max(BuyPrice(res),SellPrice(res)) > min(BuyPrice(res),SellPrice(res)) if SellPrice(res) > resLvl.sp[res] if (city.resource[ResourceIntNames[res]].amount - minres[res]) > 1 execute "sell {ResourceIntNames[res]} {floor(min(city.resource[ResourceIntNames[res]].amount - minres[res],99999999))} {max(BuyPrice(res),SellPrice(res))}"
  20.     res = ++res MOD 4
  21.     if res > 0 goto start
  22.     sleep 10
  23.     if StandAlone goto start
  24. goto finished
  25.  
  26. label LoadVariables
  27.     rssbp = 0.001
  28.     rsssp = 0.001
  29.     MinFood = city.reservedResource.food * 3
  30.     MinGold = ((max(BuyPrice(0),SellPrice(0),BuyPrice(1),SellPrice(1),BuyPrice(2),SellPrice(2),BuyPrice(3),SellPrice(3)) * 99999999) * 1.05) + 100m
  31.     StandAlone = true
  32.     res = 0
  33.     resLvl = {"bp":[round(min(BuyPrice(0),SellPrice(0))-rssbp,3),round(min(BuyPrice(1),SellPrice(1))-rssbp,3),round(min(BuyPrice(2),SellPrice(2))-rssbp,3),round(min(BuyPrice(3),SellPrice(3))-rssbp,3)],"sp":[round(min(BuyPrice(0),SellPrice(0))+rsssp,3),round(min(BuyPrice(1),SellPrice(1))+rsssp,3),round(min(BuyPrice(2),SellPrice(2))+rsssp,3),round(min(BuyPrice(3),SellPrice(3))+rsssp,3)]}
  34. return
  35.  
  36. label waitMaint
  37.     echo ">>> Sleeping 20 min for maint! <<<"
  38.     sleep 20:00
  39. return
  40.  
  41. label finished
  42.     echo "Trade script Complete"
  43.     # resLvl.bp[res]
  44.     # resLvl.sp[res]
  45.  
  46. echo ">>> Returning from CAN-Trade.txt <<<"
  47. return
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement