Ollerton coliery script

anys2

Trainz Commuter
Is there any way to make Ollerton load a moving train? I tried to paste this
Code:
[COLOR=red]TriggerSupportsMovingLoad(Vehicle vehicle, string triggerName)[/COLOR]
[COLOR=red]{[/COLOR]
and
Code:
[COLOR=#2e8b57]void PerformMovingLoad(Vehicle vehicle, string triggerName)[/COLOR]
[COLOR=#2e8b57]{[/COLOR]
[COLOR=seagreen]//[/COLOR]
[COLOR=seagreen]// OUTPUT trigger - load [/COLOR]
[COLOR=seagreen]//[/COLOR]
[COLOR=seagreen]float speed = vehicle.GetVelocity();[/COLOR]
[COLOR=seagreen]if (speed > -5.0f and speed < 5.0f)[/COLOR]
[COLOR=seagreen]{[/COLOR]
from the builtin coalmine and pasted it over the correspondant color in the Ollerton script:
Code:
include "GenericIndustry.gs"
class CoalTower isclass GenericIndustry
 {
 ProductQueue coalOutQueue;
 bool scriptletEnabled = true;
 int coalWBRemain = 0;
bool HandleTrainUnloadCommand(Train train)
{
return false;
}
thread void ViewDetails(void)
{
 if (!info)
 {
  info = Constructors.NewBrowser();
  info.LoadHTMLString(HTMLWindow.GetCompleteIndustryViewDetailsHTMLCode(me, scriptletEnabled));
  info.SetWindowRect(100, 80, 500, 545);
 }
}
bool [COLOR=red]TriggerSupportsStoppedLoad(Vehicle vehicle, string triggerName)[/COLOR]
[COLOR=red]{[/COLOR]
 if (itc.IsTrainCommand(vehicle.GetMyTrain(), Industry.LOAD_COMMAND))
 if (triggerName == "out_load0" or triggerName == "out_load1" or triggerName == "out_load2" or triggerName == "out_load3" or triggerName == "out_load4")
 return true;
 return false;
}
[COLOR=seagreen]void PerformStoppedLoad(Vehicle vehicle, string triggerName)[/COLOR]
[COLOR=seagreen]{[/COLOR]
 int spaceAvailable = coalOutQueue.GetQueueCount();
 LoadingReport report = CreateLoadingReport(coalOutQueue, spaceAvailable);
 vehicle.LoadProduct(report);
 if (coalWBRemain > 0)
 coalWBRemain = coalWBRemain - report.amount;
}
thread void SteamFillingMain(void)
{
 Message msg;
 Vehicle vehicle;
 string triggerName;
 wait()
 {
  on "Scriptlet-Enabled", "1":
  {
           if (!scriptletEnabled)
   {
    scriptletEnabled = true;
    SetProcessEnabled("water_gathering", true);
   }
  continue;
  }
   on "Scriptlet-Enabled", "0":
   {
    if (scriptletEnabled)
    {
     scriptletEnabled = false;
     SetProcessEnabled("water_gathering", false);
    }
   continue;
   }
  }
 }
 public void Init(void)
 {
  inherited();
  usePipeAnimation =false;
  pipeName = "tender";
      coalOutQueue = GetQueue("coal_out");
      AddAssetToIndustryProductInfo("coal", "coal_out", "water_gathering", true, false);
      AddAssetToIndustryProductInfo("coal", "coal_out", "water_gathering", false);
  SteamFillingMain();
 }
 public Requirement[] GetRequirements(void)
 {
      Requirement[] ret = new Requirement[0];
      if (coalOutQueue.GetQueueCount() < 3000 or coalWBRemain > 0)
  {
   ResourceRequirement req = new ResourceRequirement();
   req.resource = coalOutQueue.GetProductFilter().GetProducts()[0];
   req.amount = 50000;
   if (coalOutQueue.GetQueueCount() < 3000 and coalWBRemain == 0)
   coalWBRemain = 50000;
   req.dst = me;
   req.dstQueue = coalOutQueue;
   ret[ret.size()] = req;
  }
  return ret;
 }
 public void AppendDriverDestinations(string[] destNames, string[] destTracks)
 {
      StringTable stringTable = GetAsset().GetStringTable();
  destNames[destNames.size()] = stringTable.GetString("Loadontrack0");
  destTracks[destTracks.size()] = "out_track0";
  destNames[destNames.size()] = stringTable.GetString("Loadontrack1");
  destTracks[destTracks.size()] = "out_track1";
  destNames[destNames.size()] = stringTable.GetString("Loadontrack2");
  destTracks[destTracks.size()] = "out_track2";
  destNames[destNames.size()] = stringTable.GetString("Loadontrack3");
  destTracks[destTracks.size()] = "out_track3";
  destNames[destNames.size()] = stringTable.GetString("Loadontrack4");
  destTracks[destTracks.size()] = "out_track4";
 }
float BeginLoad(LoadingReport report)
 {
      SendMessage(me, "pfx", "+0+1");
      Asset meAsset = GetAsset();
      World.PlaySound(meAsset, "coal_dump.wav", 1000.0f, 20.0f, 1000.0f, me, "");
      return 1.0;
 }
float EndLoad(LoadingReport report)
 {
  Sleep(1.0);
      SendMessage(me, "pfx", "-0-1");
      return 1.0;
 }
};
It didn't work :hehe: But i guess it is not that simple. Any suggestions how to do it?
 
Hi anys2:

I'm sure there is a way to do it but what I know about scripting would fit in the eye of a needle with lots of room left over for a thread.

I have a script file that supports a stopped load and a moving unload. PM me your e-mail address and I'll send it to you. Perhaps you can figure out how to modify it into what you want.

Ben
 
As an alternative I fitted a coal loader track inside the structure and connected the track to that, it loads a moving train perfectly.
 
No config alterations were needed at all Ben.

I've used the coal loader 40 by Mr Den kuid:141417:1071 and it loads a moving train, provided the speed is under 5 mph, which is ideal for the UK Merry Go Round load/unload concept. Have a look at the script with this asset, it is unencrypted and mentions the speed less than 5mph.

It sits nicely within your coal loading structures.
 
Last edited:
Thanks - I'll download it and take a peek. I do have a coal thing to make in the near future but it loads and unloads (400 ton coaling tower).

Ben

EDIT (a few minutes later).

Nice and small and simple but it doesn't have the code for operating under AI (I don't but lots of folks do).
 
Last edited:
I've set the coal loader up to load a train in an automated session- and it works.

It will load anything that moves over it at less than 5mph, and doesn't need a load command, just a drive to trackmark command that is placed at the other side.
 
Back
Top