Page 1 of 1

Sending vehicles to depot

Posted: 28 Aug 2011 16:25
by marco.r
Greetings,

what are the reasons that may cause a call to AIVehicle.SendVehicleToDepot ?
All I get is a ERR_UNKNOWN when I use AIError.GetLastError.

Moreover, is there a way to know that a given vehicle is already going to a depot,
so that I can avoid to undo the action by mistake ?

Re: Sending vehicles to depot

Posted: 28 Aug 2011 16:53
by Yexo
The only reasons I can find for getting ERR_UNKNOWN is calling the function on a vehicle that has 1) crashed or 2) is already stopped inside a depot.

You can check if a vehicle is going to a depot by testing AIRoad.IsRoadDepotTile(AIOrder.GetOrderDestination(vehicle_id, AIOrder.ORDER_CURRENT));. Subsitute AIRoad.ISRoadDepotTile with the appropriate function for the vehicle type you're using.

Re: Sending vehicles to depot

Posted: 28 Aug 2011 21:46
by marco.r
Hi Yexo, thanks for answering.

Even after adding a check to see if the truck is alread in the depot, I still get ERR_UNKNOWN errors...
If I keep trying to do the command, something like

Code: Select all

while( !AIVehicle.SendVehicleToDepot(vehicle) )  ;
(Yuck :D), eventually the command will succeed, but taking quite a while,
so instead I get the same result by removing existing orders and adding one to go to
a depot. Seems a more reliable way... at least for now.
Thanks also for the other suggestion (but with the way I handle it now, it shouldn't be necessary)

Re: Sending vehicles to depot

Posted: 29 Aug 2011 04:37
by Zuu
The command will fail (not sure about exactly which error message) for road vehicles when they are in certain states in road stations. Just telling a vehicle to go to depot will also not make it stop loading in some (all?) conditions. Therefore, I use the approach to unshare orders, remove all orders and then add a goto depot order. In some cases it is also a good idea to tell road vehicles to turn around if they are stuck in a queue.