Is there any way to make Ollerton load a moving train? I tried to paste this
and
from the builtin coalmine and pasted it over the correspondant color in the Ollerton script:
It didn't work :hehe: But i guess it is not that simple. Any suggestions how to do it?
Code:
[COLOR=red]TriggerSupportsMovingLoad(Vehicle vehicle, string triggerName)[/COLOR]
[COLOR=red]{[/COLOR]
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]
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;
}
};