Jump to content

Vehicle Name


Recommended Posts

Hello George,

if you're using V7 and the vehicle has stopped on a contact which belongs to the signal:

First, here's how to check for a keyword.
A keyword is a treated like a variable, with the actual word being the name of this variable.

That's why the condition may look like this:


check if vehicle "MAK1202-1205" has a variable named "freighttrain"

To find the train sitting on the contact of a particular signal, you may use an iteration.
It will return a list of all vehicles on that contact. This may sound strange, because there shouldn't be more than one. But the same iteration is also used to get all vehicles on a particular track. And that may well be a larger number than 1.

Here is the iteration:


return all elements wich sit on the contact of signal "H/V main signal" - one by one - and give each one the temp name "Iter"

And here is how you enter each element from that iteration into the condition:


Click on the small cog wheel next to the object (where the train name was before) and selet "Iteration".

If you feel comfortable with Lua, use the small <> button to convert everything into a script.
In the script, you can eliminate the iteration and go straight for the first element of the returned list. That is the vehicle parked on that contact:

local t = layout:getVehiclesOn($("H/V main signal"))
if t[1].variables["freighttrain"] ~= nil then
-- enter tasks here


Kind regards

Link to comment
Share on other sites

I hope this helps.

First, a keyword is a shortcut to name one or more objects in the Events Manager


In this case there are more than seven track contacts, and I want to set an event that will work for any of them.  Vehicle (Trigger) refers to the Locomotive (any) that triggers a "Stop" contact.


Here, I have used a track contact to trigger a track signal.  The rest of the event sets specific routes.


Each Locomotive has an object variable called Track that sets a specific track.


Here, The Track for Loco 3 sets a series of three track switches for track3

Link to comment
Share on other sites

My apologies, @Curt84328

I just realised, I misunderstood Jud91.
He simply want's to keep an eye on the timer values.
And you, together with @simonjackson1964 gave the correct answer.

For some reason I was under the impression that he wanted to evaluate it, using the event manager.
THat he wanted to use the value as a condition or print it on a label.

Sorry about that ;)

Link to comment
Share on other sites

Sorry to not be clear.  Both answers are of help BUT I wish to display a current clock on the layout.  This clock needs to show the simulation time.

(If in real time it will show real time like a clock on the layout somewhere.


Thanks for you help and apologies for not being very clear.




Link to comment
Share on other sites

Hello @Jud91,

in the Lua editor, press ctrl + spacebar to open a list of all available commands and parameters.
You may find that the simulation time is held in a variable named layout.time



Unfortunately, this value is only available from within a Lua script.

Here's how you give the time to the text property of a label item (called Label in this example):

$("Label").text = layout.time

You can use a timer (set to 60 seconds) to refresh the text once every minute.



Kind regards

Link to comment
Share on other sites

vor 3 Minuten schrieb Goetz:

You can use a timer (set to 60 seconds) to refresh the text once every minute.

Small hint, you can use the event "Time is reached" to react on layout time changes without a timer.

Kind regards,


Link to comment
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...