Adding a tail light to rearmost vehicles.

General discussion about Train Simulator, your thoughts, questions, news and views!

Moderator: Moderators

deltic009
Very Active Forum Member
Posts: 4017
Joined: Fri Nov 27, 2009 1:06 am

Adding a tail light to rearmost vehicles.

Post by deltic009 »

A semi-technical question that comes courtesy of my own Facebook page when I posted about further expansions of the mk1s, asking about adding tail lights.

So, what's required to have a scripted taillight that only appears on a coach when it's the last vehicle AND has a loco on it? I know a lot of default stock has it, but I'd like to replicate it for the DT Mk1 stock if I can.
Matthew Wilson, development team at Vulcan Productions

http://www.vulcanproductions.co.uk
https://www.facebook.com/VulcanFoundry/
gptech
Very Active Forum Member
Posts: 19585
Joined: Fri Oct 10, 2008 5:48 pm
Location: Wakefield, West Yorkshire

Re: Adding a tail light to rearmost vehicles.

Post by gptech »

Basically, a model of a tail light to add as a child object and the script itself. I'm sure RW Tools includes both these so you can add them to whatever you want and you'd be able to see just what has come into play.
User avatar
rfletcher72
Very Active Forum Member
Posts: 8643
Joined: Sat Apr 28, 2007 10:59 pm
Location: The Steel City
Contact:

Re: Adding a tail light to rearmost vehicles.

Post by rfletcher72 »

I suspect Matt is looking to add one automatically when a vehicle is the rearmost in a consist and the headlights are activated, as opposed to a permanent child object addition.

I too would be keen to understand how this is accomplished, as of yet I haven't worked it out. Looking at script files has provided nothing useful and I am minded to think it is some sort of animation linked to the model/.Geo. Happy as usual though to be proven wrong, and even so I am sure a script would be able to acheive this,
Richard
deltic009
Very Active Forum Member
Posts: 4017
Joined: Fri Nov 27, 2009 1:06 am

Re: Adding a tail light to rearmost vehicles.

Post by deltic009 »

rfletcher72 wrote:I suspect Matt is looking to add one automatically when a vehicle is the rearmost in a consist and the headlights are activated, as opposed to a permanent child object addition.

I too would be keen to understand how this is accomplished, as of yet I haven't worked it out. Looking at script files has provided nothing useful and I am minded to think it is some sort of animation linked to the model/.Geo. Happy as usual though to be proven wrong, and even so I am sure a script would be able to acheive this,
You're absolutely correct Richard, I'm making enough variations for these coaches without worrying about giving every vehicle and livery variation a tail lamp version, I hope that doesn't sound ungrateful though Gary.

If I find anything out Richard, and I get it to work, you can rest assured you'll be the first to know (it'll go on the Facebook page too).
Matthew Wilson, development team at Vulcan Productions

http://www.vulcanproductions.co.uk
https://www.facebook.com/VulcanFoundry/
gptech
Very Active Forum Member
Posts: 19585
Joined: Fri Oct 10, 2008 5:48 pm
Location: Wakefield, West Yorkshire

Re: Adding a tail light to rearmost vehicles.

Post by gptech »

Ahhhh.. I'm up to speed with what you're after now, but if the RSC 'auto' lights are part of the coach model then adding one to DT stock can only be done as a child. The trick then is to find the scripting to make the child visible/operative only when it's the last vehicle in a consist.
User avatar
Carinthia
Very Active Forum Member
Posts: 1123
Joined: Tue Mar 06, 2012 7:07 pm
Location: at the end of the regulator

Re: Adding a tail light to rearmost vehicles.

Post by Carinthia »

deltic009 wrote:I know a lot of default stock has it, but I'd like to replicate it for the DT Mk1 stock if I can.
Have you not noticed that the DT Mark 1s do indeed have a tail lamp that operates in the circumstances you describe? It just happens that it appears on the wrong end of the coach concerned.

All power to your elbow if you can fix it, neither Digital Traction nor Armstrong Powerhouse seem to have been able to.

John
User avatar
AndiS
Very Active Forum Member
Posts: 6207
Joined: Fri Sep 23, 2005 4:43 pm
Location: Jester's cell in ivory tower
Contact:

Re: Adding a tail light to rearmost vehicles.

Post by AndiS »

I know half of two popular solutions. Plus all of one that nearly no one likes. :roll:

Solution 1 revolves around the head and tail light naming convention for vehicles. If you get that right, the game treats the tail lamp as your rear light and shows it when the train moves forward. There have been complaints about AI not getting that right and I lost track of how much was true and how much of that was fixed over the years. See here for the naming convention.


Solution 2 revolves around messages sent between vehicles. The ugly bit about it is that you need to do it constantly all the time. And if you are unlucky, it only works with wagons that implement that same feature.

Solution 2a: Send a message of your choice to either side of the vehicle. See what the return value of the Call is when the wagon is connected and when it is not. For signal messages, the return value tells you whether there was a receiver or not, at this present moment. I never tried it out for vehicles. Now if you get return value 1 (e.g.) if there is a recipient, i.e., another vehicle, and 0 if there is none, then all you need to do is send some dummy message and you immediately know whether you are at the end of the train or not - without collaboration of the receiving vehicle. Then of course, you use ActivateNode to show and hide the tail light.

Beware that it might be necessary for the receiving vehicle to have an OnConsistMessage function in its script - and a vehicle script in the first place. Maybe if either is missing, you get the "no" return value from Call even if there is a vehicle. You need to try it out.

See here for someone who seems to have succeeded. Heed Pete's suggestion to not query at every call to Update. Just run a counter to 100 and only query every 100th time, says the simple guy in me.

Solution 2b: On receipt of some "Hello there" message, send a message "Yes, I am here" back. On receipt of the latter message, you know that you are not the last one and the tail light ought to be hidden. This is known to work for sure, but it only works if all the vehicles use such a script. So it is only an option for creators who prefer to lock out creations of others from trains running theirs.


Solution 3: Make the tail light the load of the vehicle concerned. Of course, you cannot have a load then, but showing the vehicle loaded all the time is a good option in most cases anyway, and other than open wagons, vehicles don't show their load anyway. Now the scenario author is in full control of the tail lamp which means it does not show on all groups of stapled wagons (which is stupid). Flip the wagon to have the tail lamp on the right end.

This last variant can be done without modification of the shape and without scripting, and you can freely mix vehicles.


Solution 4: Some people create a version with tail lamp of every wagon they consider. The tail lamp is just a child that is always there. Think of it as a less elegant variant of Solution 3.
gptech
Very Active Forum Member
Posts: 19585
Joined: Fri Oct 10, 2008 5:48 pm
Location: Wakefield, West Yorkshire

Re: Adding a tail light to rearmost vehicles.

Post by gptech »

I'm not doubting you've seen that John, but could you provide an example?...I've just tried various combinations of the coaches and can't see a tail light anywhere!

EDIT:

Found one; I have a NSE liveried bunch of coaches (are these default or a reskin?) BSK, CK, FO, RMB, and TSO which feature a 'back to front' light. These however are the only ones I have that that call for any light related textures in the .GeoPcDx
deltic009
Very Active Forum Member
Posts: 4017
Joined: Fri Nov 27, 2009 1:06 am

Re: Adding a tail light to rearmost vehicles.

Post by deltic009 »

Carinthia wrote:
deltic009 wrote:I know a lot of default stock has it, but I'd like to replicate it for the DT Mk1 stock if I can.
Have you not noticed that the DT Mark 1s do indeed have a tail lamp that operates in the circumstances you describe? It just happens that it appears on the wrong end of the coach concerned.

All power to your elbow if you can fix it, neither Digital Traction nor Armstrong Powerhouse seem to have been able to.

John
I hadn't noticed that, and having just took a cursory glance at one of the default BCK config files, it is hard to see where it is called from as there is no script referenced and no tail light child object either. Officially baffled.

Edit: Now seen Gary's post above
gptech wrote:I'm not doubting you've seen that John, but could you provide an example?...I've just tried various combinations of the coaches and can't see a tail light anywhere!

EDIT:

Found one; I have a NSE liveried bunch of coaches (are these default or a reskin?) BSK, CK, FO, RMB, and TSO which feature a 'back to front' light. These however are the only ones I have that that call for any light related textures in the .GeoPcDx
NSE are one of the default liveries included, yes.
Last edited by deltic009 on Mon May 04, 2015 11:20 pm, edited 1 time in total.
Matthew Wilson, development team at Vulcan Productions

http://www.vulcanproductions.co.uk
https://www.facebook.com/VulcanFoundry/
TransportSteve
Very Active Forum Member
Posts: 4645
Joined: Sat Dec 12, 2009 12:43 am
Location: Nottingham, England.

Re: Adding a tail light to rearmost vehicles.

Post by TransportSteve »

I don't know if this is of any use to Matthew in his cause. I tried this myself a few years ago, but, to have to edit the files of every wagon I owned was a bit daunting, so, I gave up in the end. The included files have an in depth wagon blueprint file amendment developed by Dave Brindley, it might be a starting point, or, some appropriate information, I'll leave you technical whizzkids to it. :lol:

http://www.uktrainsim.com/filelib-info. ... leid=19985

Cheerz. Transport Steve.
i5 4690 3.5GHz Quad Core CPU, Gigabyte Z97-HD3, 16GB RAM, nVidia GTX1060 6GB, WIN 7 PRO 64-bit.
Visit my flickr account - http://www.flickr.com/photos/59849121@N08/
gptech
Very Active Forum Member
Posts: 19585
Joined: Fri Oct 10, 2008 5:48 pm
Location: Wakefield, West Yorkshire

Re: Adding a tail light to rearmost vehicles.

Post by gptech »

I've managed to alter the position of the light on one of the NSE liveried coaches, albeit only 2 metres or so up in the air but the problem is it involved an edit of the .Geo, so there'd be no chance of distributing the files.

Steve, that taillight's the one that's always there; Matthews after getting the DT coaches to have the "hidden unless it's the last coach in a consist that has the lights on" behaviour that the Kuju coaches have. I believe it's also the one that comes with RW Tools that I erroneously suggested. Thanks for getting involved though, :) the more digging we do the deeper we'll get---even though that may be only deeper into the hole.....
As Matthews found there's no clues in the .bin file, no script referenced so it really does look like it's a very low level and basic element.
User avatar
Carinthia
Very Active Forum Member
Posts: 1123
Joined: Tue Mar 06, 2012 7:07 pm
Location: at the end of the regulator

Re: Adding a tail light to rearmost vehicles.

Post by Carinthia »

gptech wrote:I'm not doubting you've seen that John, but could you provide an example?...I've just tried various combinations of the coaches and can't see a tail light anywhere!
I only use the maroon ones with black ends and all but one (that I have used in scenarios as the last vehicle) display this curiosity. These days I use the Maroon Mk1s in the "6MT pack" (Clan) for the rearmost vehicle which are not a glaringly different shade.

John
User avatar
rfletcher72
Very Active Forum Member
Posts: 8643
Joined: Sat Apr 28, 2007 10:59 pm
Location: The Steel City
Contact:

Re: Adding a tail light to rearmost vehicles.

Post by rfletcher72 »

gptech wrote:I've managed to alter the position of the light on one of the NSE liveried coaches, albeit only 2 metres or so up in the air but the problem is it involved an edit of the .Geo, so there'd be no chance of distributing the files.
If my memory serves me correctly, the entries within the .geo for the positioning of nodes are in the same order as those entries that are in a .bin file for setting the position of a child object, though of course not in the same format which can be somewhat disconcerting.

I will try and grab a gander at this later today, if nobody beats me to it in the meantime :) ,

Richard
Richard
deltic009
Very Active Forum Member
Posts: 4017
Joined: Fri Nov 27, 2009 1:06 am

Re: Adding a tail light to rearmost vehicles.

Post by deltic009 »

rfletcher72 wrote:
gptech wrote:I've managed to alter the position of the light on one of the NSE liveried coaches, albeit only 2 metres or so up in the air but the problem is it involved an edit of the .Geo, so there'd be no chance of distributing the files.
If my memory serves me correctly, the entries within the .geo for the positioning of nodes are in the same order as those entries that are in a .bin file for setting the position of a child object, though of course not in the same format which can be somewhat disconcerting.

I will try and grab a gander at this later today, if nobody beats me to it in the meantime :) ,

Richard
I won't be beating you, working now and a little ones first birthday when I get home after.....it would be good if only there were some way for a script to manipulate the position of an object or node in the .Geo file.
Matthew Wilson, development team at Vulcan Productions

http://www.vulcanproductions.co.uk
https://www.facebook.com/VulcanFoundry/
gptech
Very Active Forum Member
Posts: 19585
Joined: Fri Oct 10, 2008 5:48 pm
Location: Wakefield, West Yorkshire

Re: Adding a tail light to rearmost vehicles.

Post by gptech »

From memory, as I won't be home till late, there are 2 long lists of transforms. I changed the value of -1 to 1 in the second list after taking a punt on the names defined in list 1 were in the same order order as those values in list 2.
This put the light over the roof of the coach but did support the link between the lists. There are 2 entries for the light, front facing and rear facing I think so I was going to see what happened with them swapped over.


That's about as far as I got, maybe it'll help you along.
Locked

Return to “[TS] General Discussion”