Code: Select all
local engineList = AIEngineList(AIVehicle.VT_RAIL);
engineList.Valuate(AIEngine.IsWagon);
engineList.KeepValue(0);
engineList.Valuate(AIEngine.CanPullCargo, cargo);
engineList.KeepValue(1);
Debug("Engines for " + AICargo.GetCargoLabel(cargo));
for (local engine = engineList.Begin(); engineList.HasNext(); engine = engineList.Next()) {
Debug(AIEngine.GetName(engine));
}
However, I can manually build a steam or diesel loco and attach an appropriate wagon without problems.AIEngine.CanPullCargo wrote:This function is not exhaustive; a true here does not mean that the vehicle can pull the wagons, a false does mean it can't.
Meta-issue: I'm not even trying to select a locomotive yet - I'm trying to find a rail type on which a locomotive can run, which can pull the desired cargo (i.e., not monorail). There's no way to find out which AIRail.RailType is which, is there? Except hardcoding the numeric IDs, but that's a little fragile...