Jump to content

Recommended Posts

This might already have been suggested, and may even be in the pipeline - I don't read German I'm sorry to say, so I don't know what all the other headings are.

My suggestion is that the track contact on the various signals be capable of being moved away from the signal itself. Either that or have the ability to connect a track contact to a signal. As it is at the moment, you either have the train reach a red signal and stop a little way past it (or stop unrealistically suddenly if you use "set current speed"), or you check each individual track contact with the exact same code but each one having it's own event.

What I have in mind is something like:

When any signal contact is triggered, if the signal [Trigger] is 0 Set vehicle[trigger] target speed to 0.

And have the trai slow realistically to a halt just before the signal.

Edited by simonjackson1964
Link to post
Share on other sites

Good evening, Simon...

I may be reading too much (or not enough..!) into this, and I'm a total beginner, myself, so may be wrong here.
There are Track Contacts integrated into the Signals, but one may also place a separate Track Contact (symbolised by a yellow/green lozenge between the rails...), which can issue orders when triggered, depending on the Signal's state, such that the engine slows and stops well before the Signal itself. In the soon-to-be-released v6, this 'slow down' will be integrated into the Track Contact itself, and will not require lines of code. Meanwhile, using a combination of Track Contacts and Signal Contacts, one may avoid the scenario you've described of over-run.
Correct me if I'm out of line in this, please; hope this helps.


Ich lese vielleicht zu viel (oder nicht genug ..!) Darin und bin selbst ein absoluter Anfänger, also kann es hier falsch sein.
In die Signale sind Gleiskontakte integriert, es kann jedoch auch ein separater Gleiskontakt (symbolisiert durch eine gelb / grüne Raute zwischen den Schienen ...) platziert werden, der je nach Signalstatus Befehle auslösen kann, wenn er ausgelöst wird Motor verlangsamt und stoppt lange vor dem Signal selbst. In der bald erscheinenden Version 6 wird diese "Verlangsamung" in den Track Contact selbst integriert und erfordert keine Codezeilen. In der Zwischenzeit kann durch die Verwendung einer Kombination aus Track-Kontakten und Signalkontakten das von Ihnen beschriebene Szenario eines Überlaufs vermieden werden.
Korrigieren Sie mich bitte, wenn ich diesbezüglich nicht in der Reihe bin. hoffe das hilft.

Link to post
Share on other sites
vor 8 Stunden schrieb simonjackson1964:

As it is at the moment, you either have the train reach a red signal and stop a little way past it (or stop unrealistically suddenly if you use "set current speed"), or you check each individual track contact with the exact same code but each one having it's own event.

Hello simonjackson,
It is as Douglas suggested:

With V6, contacts will obtain a new feature that allows them to decelerate any vehicle in such a manner, that a set speed is reached (rather than triggered) at the contact. And the function itself as well as the target speed is controllable via the event manager. It's as if the train driver can see the contact from afar. He'll slow down at the appropriate time, respecting the set brake force.  

It works a treat and makes traffic control a lot easier.

Kind rergards

Link to post
Share on other sites

@Goetz That is what I was hoping for. I didn't think I could possibly be the first one to see the need.

@Dad3353 Thanks. Yes I'm aware of the track contacts that can be used in conjunction with the signal to slow and/or stop the train, but the problem with the current system is that you have to specifically name each contact and signal (yes it's worth doing that anyway), but then you need a separate event for every contact because each one is dependent on the state of the signal behind it, but there's no link between the signal and the advance contact point.

I suppose one could soft-code a link - create an object variable on the contact that held the state of the signal, and have an event that updated it when the signal changed. But again you'd need a different one for every signal. less work than having an event for every contact for every state of the signal, but it seems a bit superfluous if V6 is coming soon...

When is V6 due out?

Link to post
Share on other sites
vor 22 Minuten schrieb simonjackson1964:

you need a separate event for every contact because each one is dependent on the state of the signal behind it, but there's no link between the signal and the advance contact point.

The trick is to store the relevant signal in the contact. And to give all contacts, that you want to behave the same way, a common keyword.

Now you can write one codeblock that looks up the address of the relevant signal in the contact's object variable. And set this event to be triggered by any contact with that keyword.

In the following V5 video, I'm applying a similar concept to a slightly more complex situation. Rather than just storing a signal in a contact, I'm keeping a list of switch points and their corresponding settings in each of 7 locos, in order to send each engine to its respective destination. The core idea is similar enough to your request. Anything that is individual, is stored in a variable. That enables you to write one little proggy, applicable to all elements that trigger this event.

I hope this helps?

I have videos closer to what you're asking, but they are all with commentary in German. 


P.S.: V6 is currently being tested and finalised. As it goes with these things, no one can quite predict, how long error hunting and bug fixing will take. (How long do you need to find your keys when you mislaid them?) But to my understanding, Neo's goal is to realease V6 in late Autumn ...

Edited by Goetz
Link to post
Share on other sites
2 hours ago, simonjackson1964 said:

... you need a separate event for every contact because each one is dependent on the state of the signal behind it, but there's no link between the signal and the advance contact point...


Our friend Goetz was kind enough to spend some time explaining to me, in terms even I could understand, the basic use of this 'Keyword' notion, using at the start a pair of signals to illustrate. The whole 'lesson' took two hours, but I have generated a five-minute version with just the 'signal' part. It may help to watch this, and take note of exactly what he's doing; this answered many of my questions, along much the same lines as yours. Maybe worth a look..? I've uploaded it to Youtube so as not to overload the 3D-Train server with video; here's the link ...


Link to post
Share on other sites

You two inspired me to give the marriage of contact and signal some thought.

I found a neat way to do this via Lua skript. Multiple ways, actually. I'll start a Twitch session to record my thoughts on this matter. Anyone's welcome, if you don't mind me mumbling to myself


Link to post
Share on other sites

Hey guys

Thanks a million, those were really helpful. V6 looks really amazing and I can't wait to see it.

(By the way, I spotted the missing full-stop before either of you! My wife must think I'm crazy, because I was all but yelling "There's a full-stop missing...!" at the computer screen!)


Link to post
Share on other sites

So... With programming/coding there is no "Right" way of achieving something as long as it works... I have just done the same on V5, (because I have no patience and I want it now!) and it's actually a bit simpler...

An object variable on the track contact, which is set further back from the signal to allow the train to slow (distance by trial and error!), holds the address of the signal it relates to. When the contact with the keyword STOP is triggered on entry,

if contact.variables["Signal for"].state == 0 then
  vehicle.targetSpeed = 0

  contact.variables["Signal for"].variables["Train at"] = vehicle

When  a signal with keyword "signal" is changed

if not (signal.state == 0) then
  if signal.variables["Train At"] ~= nil then
    signal.variables["Train At"].targetSpeed = 100

    signal.variables["Train At"] = nil

And that's it...

Well, apart from "Closing the door".

On the prototype, back in the old days of manned signal boxes on every station and at every junction, the signalman would wait until the train had passed completely before setting the signal on and blocking the track - he would do this latter by sending a coded bell message down the telegraph to the next signal box, saying "Train in block". (And I'm not being sexist, just historical, I don't think there were female signalpeople until very recently. Not in the UK anyway.)

But these days,in the UK at least there is an actual track contact, something like this(?), just beyond the signal and when the locomotive passes over it, it sets the signal red.


Which is why, when watching from the window of a passenger train in the UK, the signals always seem to be red when you go past them, unless you are right at the front of the train. If the track is straight enough (or curved just right) you can sometimes see the signal change as you get closer to it.

Because of this I prefer to use the signal track contact event "On entering (Vehicle Centre)" which realistically changes the signal while the train is still passing it. (Of course to be totally true to prototype one could use one of these and have it set the signal "on entering"... But that's too much hard work!


Link to post
Share on other sites


Now I just have to put the rest of the signals in where I think I need them, along with their contacts, decide how I'm going to set the preceding signal to green (probably when signal contact is activated on leaving, and store the name of the preceding signal in each one). But most importantly I need to figure out how to automate this:


Yep, that's a single track viaduct with a train waiting at both ends. (view from the cab of one and the other is that raised blip in the far distance...) I really wanted a viaduct, and couldn't find a two-track one I liked. And I figured it would make operating the layout entertaining to have a single track section.

It's only since I got the "stop at red" working that I was able to put two trains on the track, and it is good fun sending them past each other manually, but I want to get on with other parts of the layout, so now I have to create an event for a train arriving at each end that checks if a train is already on the viaduct and if not, sets the route and clears the signals (There's an exit signal at both ends to prevent the train going onto the wrong track).

I've already got events that set and clear a global boolean "Viaduct blocked". My one concern is the one in a million chance that two trains arrive at the same time. Because it's bound to happen! Murphey's law says so... :/ And just delaying execution on one side doesn't help, because it just means that the other train has to arrive that little bit later to be at exactly the same time. I've not been able to think of a solution for that one since I first downloaded the free version 3 and then bought version 4.

I suppose I could use two booleans, one for each direction, so I check the one for my direction. If it's true, I stop. If it's false, I set the one for the other direction true, wait a second then check the one for my direction again. If that's true I flash a big red light and pause the program....

Link to post
Share on other sites
vor 26 Minuten schrieb simonjackson1964:

My one concern is the one in a million chance that two trains arrive at the same time. Because it's bound to happen!

Even if it does, the Event Manager will always receive one train's call before the other. And it's only one event manager at work. So when the second train calls, regardless how soon after the first this may happen, this one Event Manager will always find the "engaged" flag raised because it set that flag when allowing the first train onto the viaduct. The secret is to combine "allow train in" with setting the "viaduct occupied" flag in one event and not wait for the train to actually step onto the viaduct.

Edited by Goetz
Link to post
Share on other sites

Got that working, I used the track contact on advance (pre-) signals to check the block indicator and set things accordingly. I've also managed to get a train exiting the viaduct to start a train waiting to enter. Currently figuring out how to combine the two so a train that has already passed the advance signal but not stopped yet still gets started... I think I have a solution... Yep, that will work! :D

Link to post
Share on other sites

Well that turned out to be trickier than I thought it would be...

The hard part was making it so it would take trains alternately if they were waiting, but just pass the trains from one side if none were coming the other way... Still not perfect - If I take all the trains off going anticlockwise but leave them running clockwise, I have to manually change a couple of points and signals to start things moving for some reason I don't want to try and solve...

Now looking at my junctions...

Oh yes, this is going to be interesting when I get it going. I'm going to use a variant of storing the train's route in the locomotive - Which I would never have thought of so thanks @Goetz

Bu one thing that was bugging me was how to get a pre-signal to change the signal it is repeating when a point between them is thrown?

I tried using an event on the point to change the property "link", but I realised that's the "physical link" that makes two objects move together, not the "connection" which is what I was trying to change...

Then I came up with the perfect solution. I'm not using the pre-signals for anything except decoration. I might at some future date add something that causes a train to go slower if it passes a signal at VR0, but I'm not yet and if I do I will allow for this.

So, we have a pre-signal, a facing junction and two main signals, and we want the pre-signal to show the aspect that mirrors the main signal that the junction is currently set to. How do we do this? We can't change the signal's connection property, and we can't connect both main signals back to the pre-signal because that would result in one of those signals changing the other. How do we do it? We use two pre-signals. Link one to one main signal and link the other to the other one. Then use the event on the points to toggle the visibility of both signals. Then we simply put them both in the same place (on the mast of the main signal before the junction). And the effect is exactly what I wanted!

I just had to tell someone... And there might be someone reading this who realises that the visibility property is exactly what they need but hadn't thought of it!

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...