I want to make a mail car to fit neatly with some passenger cars I made, without having to implement the mail cars as different refits, because of compatibility reasons. Below there's an illustration to help explain what I mean.
So if we take setup a as a basis, where blue indicates a locomotive, green is the mail car and red is the passenger car, then what I want is I want the front-most car that is not a locomotive to have a certain pattern to indicate that it is the front-most one, indicated by the yellow stripes, as shown in b. This should not depend on where the chain starts, as shown in c. I want this to happen regardless of whether it's a mail car or a passenger car, as shown in d.
How I was thinking of implementing it: the cars (both red and green) check what the ID of the entity in front of it is, which would result in a switch like:
Code: Select all
switch(FEAT_TRAINS, SELF, SWITCH_STRIPES_RED, other_vehicle_type_id(-1)) {//Check ID of wagon in front of this one
ID_GREEN: SPRITESET_RED;
ID_RED: SPRITESET_RED;//If the wagon in front is red or green, use normal sprite
SPRITESET_RED_STRIPES;//If the wagon in front is not green nor red, use sprite with yellow stripes
}

a: Setup without this feature (unwanted)
b: Example setup with one locomotive
c: Example setup with two locomotives
d: Example setup with green in the back
This should obviously also work using just the red ones, or just the green ones