There is the ARN or automatic road number script. This script changes the engine or wagon number each time the same item is placed on the track. I've seen this on locomotives and wagons, but I'm not sure if it's possible to add this to existing rolling stock.
John