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 ?
Sending vehicles to depot
Moderator: OpenTTD Developers
Re: Sending vehicles to depot
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.
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
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
(Yuck
), 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)
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) ) ;

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
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.
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Who is online
Users browsing this forum: No registered users and 8 guests