Currently I'm working on SimpleAI to add support for NUTS. The problem there is that the same wagon can be used for carrying passengers and mail. My AI usually adds one mail wagon to the end of passenger trains, but as the mail and passenger wagons are of the same type, they get attached to the same wagon chain as I'm building them. I need to have the mail wagon in a separate chain to refit it, but AIVehicle.MoveWagon(firstwagon, 1, -1, 0) (assuming that the mail wagon is the second one) does nothing to the wagon chain, although it returns true. Note that I'm trying to move a wagon away from a chain which has no locomotive yet.
So, am I overlooking something, is it a bug in the API, or I need to do some workaround?
How to break a wagon chain into two parts?
Moderator: OpenTTD Developers
Re: How to break a wagon chain into two parts?
there's no "virtual" vehicle and we have no function to get a wagon except inside a vehicle, as such, any wagon move out of a vehicle not into another vehicle is lost as soon as its var holding its id is lost. LOL yeah, dead wagons stay in depot and you then cannot delete the depot 
you need to workaround that, refit it once built, or delete the wagon to build and refit a new one.

you need to workaround that, refit it once built, or delete the wagon to build and refit a new one.
Re: How to break a wagon chain into two parts?
My problem is not that I have dead wagons. When building a passenger train, I build the locomotive first, then a passenger wagon (called 'firstwagon'), and then the mail wagon (called 'mailwagon'). After this, I usually have 3 separate chains. But in the case of NUTS, the passenger wagon and the mail wagon are the same, so I have 2 chains instead of 3, and I cannot refit the mail wagon without moving it away from the passenger wagon first. I tried to do this using the command I described in my first post, but that does nothing, although the documentation says that -1 creates a new chain. I have the ID of that wagon, so it wouldn't be dead.
So most probably I need an ugly workaround for this
So most probably I need an ugly workaround for this

Re: How to break a wagon chain into two parts?
Well, i'm not sure if this has ever work. The code show it use ::INVALID_VEHICLE when using -1
Anyway even if this work, moving it to some unknow vehicle won't help. To work as it should this function should return the new vehicleID where the cart were attach to.
Because even having the ID of the wagon you would be able to refit it, but still in a unknow vehicle or refit at depot, but it will remain "dead". As if you wish move that wagon again, you will need to give it not the ID of the wagon, but the ID of the vehicle that now have the wagon
Anyway even if this work, moving it to some unknow vehicle won't help. To work as it should this function should return the new vehicleID where the cart were attach to.
Because even having the ID of the wagon you would be able to refit it, but still in a unknow vehicle or refit at depot, but it will remain "dead". As if you wish move that wagon again, you will need to give it not the ID of the wagon, but the ID of the vehicle that now have the wagon

Who is online
Users browsing this forum: No registered users and 21 guests