Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //////////////////////////////////////////////////////
- //// call "https://pastebin.com/raw/Xb2pDKa6 ////
- //////////////////////////////////////////////////////
- echo ">>> Starting CAN-Trade.txt <<<"
- label TradeScript
- gosub LoadVariables
- label start
- if m_context.maintenanceStart > 0 gosub LoadVariables
- if m_context.maintenanceStart > 0 gosub waitMaint
- #if res == 0 if city.resource.gold > MinGold echo "Minimum Gold {FormatNumber(MinGold)} has been met"
- if city.tradesArray.length > (city.getBuildingByTypeId(23).level - 2) execute "canceltrade " + city.tradesArray[0].id
- if city.tradesArray.length > (city.getBuildingByTypeId(23).level - 2) repeat
- //minres = [(city.reservedResource.food + 1b) * 10,10,10,10,(BuyPrice(res) * 100m) + MinGold ]
- minres = [(MinFood),20m,20m,20m ]
- if BuyPrice(res) < resLvl.bp[res] if city.resource.gold > MinGold echo "Minimum Gold {FormatNumber(MinGold)} required to buy {ResourceIntNames[res]}"
- if BuyPrice(res) < resLvl.bp[res] if city.resource.gold > MinGold execute "buy {ResourceIntNames[res]} 99999999 {min(BuyPrice(res),SellPrice(res))}"
- 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))}"
- res = ++res MOD 4
- if res > 0 goto start
- sleep 10
- if StandAlone goto start
- goto finished
- label LoadVariables
- rssbp = 0.001
- rsssp = 0.001
- MinFood = city.reservedResource.food * 3
- MinGold = ((max(BuyPrice(0),SellPrice(0),BuyPrice(1),SellPrice(1),BuyPrice(2),SellPrice(2),BuyPrice(3),SellPrice(3)) * 99999999) * 1.05) + 100m
- StandAlone = true
- res = 0
- 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)]}
- return
- label waitMaint
- echo ">>> Sleeping 20 min for maint! <<<"
- sleep 20:00
- return
- label finished
- echo "Trade script Complete"
- # resLvl.bp[res]
- # resLvl.sp[res]
- echo ">>> Returning from CAN-Trade.txt <<<"
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement