Loading

Paste #pdfyikkqi

  1. class MyTest extends AIController {
  2.   function Start();
  3. }
  4.  
  5. function MyTest::Start() {
  6.   local cargoes = AICargoList();
  7.   local oil;
  8.   foreach (cargo, value in cargoes) {
  9.     if( AICargo.GetCargoLabel(cargo) == "OIL_") {
  10.       oil = cargo;
  11.       break;
  12.     }
  13.   }
  14.  
  15.   local oilrigs = AIIndustryList_CargoProducing(oil);
  16.   oilrigs.Valuate(AIIndustry.HasDock);
  17.   oilrigs.KeepValue(1);
  18.  
  19.   oilrigs.Valuate(AIIndustry.GetLastMonthProduction, oil);
  20.   local myRig = oilrigs.Begin();
  21.   AISign.BuildSign(AIIndustry.GetLocation(myRig), "origin");
  22.  
  23.   local refineries = AIIndustryList_CargoAccepting(oil);
  24.   refineries.Valuate(AIIndustry.GetDistanceManhattanToTile, AIIndustry.GetLocation(myRig));
  25.   refineries.Sort(AIList.SORT_BY_VALUE, true);
  26.   local myRef = refineries.Begin();
  27.   AISign.BuildSign(AIIndustry.GetLocation(myRef), "destination");
  28.  
  29.   local accepting = AITileList_IndustryAccepting(myRef, 4);
  30.   AILog.Info("I found " + accepting.Count() + " tiles for the initial candidate");
  31.   accepting.Valuate(AITile.IsCoastTile);
  32.   accepting.KeepValue(1);
  33.   AILog.Info("I found " + accepting.Count() + " coast tiles.");
  34.  
  35.   foreach(myTile, value in accepting) {
  36.     local slope = AITile.GetSlope(myTile);
  37.     AILog.Info("Slope at tile " + myTile + " is " + slope + ".");
  38.     if (AIMarine.BuildDock(myTile, AIStation.STATION_NEW)) {
  39.       break;
  40.     }
  41.   }
  42.  
  43.   while (true) {
  44.     this.Sleep(50);
  45.   }
  46. }

Version history

Revision # Author Created at
pfif4lzeo Sylf 26 Aug 2017, 03:36:24 UTC Diff
prif7bccz Sylf 26 Aug 2017, 03:31:28 UTC Diff

Comments