Jump to content

Lua script?


Recommended Posts

Hi 

 

Who can help me with either commands or LUA script

 

I have two trains running "Loc1" and "Loc2", and each train has two keywords:

 

LOC1 = keyword             "Module1" which refers to an user-defined event called "Loc1OpenDoors"

             second keyword "Module2" which refers to an user-defined event called "Loc1CloseDoors"

LOC1 = keyword             "Module1" which refers to an user-defined event called "Loc2OpenDoors"

            second keyword  "Module2" which refers to an user-defined event called "Loc2CloseDoors"

 

Now I want that when a trains hits a track contact the train stops and its corresponding event "Loc1OpenDoors" or "Loc2OpenDoors" is called,

and when the train leaves the contact, the corresponding event "Loc1CloseDoors" or "Loc2CloseDoors" is called.

I know that you can set this with a command that when a train hits a contact according to the trains name you can run its according event, but if you have 20 trains running then you have to do that for each train. Lot of work, lot of commands, which slows down the program.

 

Thanks in advance for the help.

Raf

 

 

Link to comment
Share on other sites

Hello Raf,

here is what I would suggest you should do:

  • store the apropriate door names in each waggon.
  • upon entering the station halt, go through all waggons in your train, check if a door name exists and animate that door
  • wait some time
  • with a second loop, close all doors again (because surely you don't want to close the doors after leaving the station?)
  • set the train in motion (when appropriate)

my demo layout:    door opener.mbp

Kind regards
Goetz

Link to comment
Share on other sites

Hi Goetz

 

Thanks for the effort, but thats what im doing now. I check if for instance Loco1 hits a track contact and then open and close its according doors.

But i have a layout with over 30 trains (all self created belgian trains with ketchup)  and i have to do that for every train hitting that rail contact. This means a lot of commands.

What i want is that with one command it works for all trains using keywords to execute their according opening and closing procedures.

Thanks a lot.

Link to comment
Share on other sites

vor 58 Minuten schrieb raf.sonneville:

This means a lot of commands.

No, it doesn't.
In my example, I use one command for all three trains. And I could use the same command for as many trains as you like.

Keywords don't help in this context. Use object variables to have every train carry it's individual door names.

Wanna check my example again, maybe? In fact, did you even bother to look at the example layout?

Edited by Goetz
spelling mistakes fixed
Link to comment
Share on other sites

vor 52 Minuten schrieb raf.sonneville:

Do i load that example in 3DTS?

Yes!!!
It's a layout, exported into a file.

You may either double click it after downloading.
Or start the train studio first, go to "Online catalog" on the start page and look for "import existing layout" at the bottom right of that screen. Click on that and navigate to the downloaded file to open it.

vor 41 Minuten schrieb raf.sonneville:

Can u send this as pdf file pls?

A layout as a pdf file?
Are you having me on, Raf?

Or do you maybe misunderstand the term layout? Just in case, here's a picture of it:

586304273_layoutscreenshot.thumb.jpg.241cb7fc0cecaf80cfa805c4b95d3766.jpg

 

9_9
Goetz

 

Link to comment
Share on other sites

Hi Goetz

Sorry to disturb you again

I tried your layout and works fine.

Then i tried this on my layout with nearly 30 trains and it works wonderful.

Whatever train that stops at a signal the doors open.... however...

The doors don't close when th train leaves, and the reason is that I am using automated routes, the trains stop at a signal and stand therewaiting until the signal is turned green by the automated routes.

This means that the command "For all vehicles on a track/contact" does not work because I cannot not use a trigger there.

If a put this command within the command for a signal changing to green then I cannot select at" Vehicle" on the right the trigger option, so the train leaves when the signal goes green but the doors don't close.

Can you once more help me on this please.

Thanks so much

Regards

 

Link to comment
Share on other sites

If you will use "signal with keyword changes to green" you have to store the train in a variable in the signal to access the train.
Maybe you could also use "route is activated" then store the train in the route.

You must use "for all vehicles in a train" instead of "on a track" then.

Regards
Thomas

 

Link to comment
Share on other sites

Hello Raf,

vor 29 Minuten schrieb raf.sonneville:

The doors don't close when th train leaves

Have you ever seen a train, where doors close when it leaves a station?
They should be closed before the train is set in motion, don't you aggree?

You have some mechanism which changes the signal and sets the train in motion, correct?
That's where you should insert some method to close the doors, wait the appropriate time and then send your train on it's journey afterwards.

Without knowing how your current mechanism works. I find it difficult to give you some appropriate advice.

Kind regards
Goetz

Link to comment
Share on other sites

You are right, in real life the doors close before leaving. In 3DTS the train leaves when the signal turns green, and speed is set by the settings of the signal, "accelerate to".

I think all i can do is leave the doors open for some time, then close them, and then let the train wait with closed doors until the signal turns green.

Anyway, thanks a lot for all your help.

Regards

 

Link to comment
Share on other sites

12 minutes ago, HaNNoveraNer said:

If you will use "signal with keyword changes to green" you have to store the train in a variable in the signal to access the train.
Maybe you could also use "route is activated" then store the train in the route.

You must use "for all vehicles in a train" instead of "on a track" then.

Regards
Thomas

 

Thanks for the help, i will try that.

Link to comment
Share on other sites

vor 35 Minuten schrieb raf.sonneville:

In 3DTS the train leaves when the signal turns green, and speed is set by the settings of the signal, "accelerate to".

Still, you can use the mechanism which turns your signal to "clear" to

  • first close all doors
  • and then, with a delay of a few seconds, change the signal state.


Or, if you want a more natural behaviour and don't mind a bit of extra effort,

  • deactivate the acceleration in the signal contact
  • close the doors when the signal changes to "clear", indicating that the path is clear and secure
  • wait a few seconds
  • activate the accelleration in the signal contact
  • wait another second
  • deactivate the acceleration again
    (because it's no longer needed for this train which is already moving and you want it off again for the next one that follows.)
Link to comment
Share on other sites

Just for my 2p worth here, another option is to stop the train at the platform short of the signal, open the doors, wait, then check if the signal is green. If it is, close the doors, and set the train moving. If it isn't then you leave the train at the platform and have the signal changing trigger the event that closes the doors and starts the train.

Of course that does mean that when the signal changes you have to check to see if the train's delay is still running but that's just putting a boolean on the loco or the signal, or even on the platform!

Link to comment
Share on other sites

  • 4 weeks later...

@raf.sonneville, may I suggest one improvement?

When you enter a contact, the EV knows the train that triggered the event.

It's preferable to say "set speed for this train that called" and not "set speed for a train on this contact".
It's not always guaranteed that the vehicle on the contact has a motor. And when it doesn't, your command will fail.

 

381970979_triggervehicle.jpg.402dd65bea588213a0e3ffe4f7787d09.jpg

 

greets
Goetz

Link to comment
Share on other sites

  • 3 months later...

Hello Hein,

the new V8 features user definable text on models.
You'll be able to change text like a displayed destination where a model designer adds this feature to his model.
And a number of designers are currently giving a lot of their time and effort to implement this feature.

You may want to follow the V8 beta test threads in this forum to find out more about this.

Greets
Goetz

Link to comment
Share on other sites

@Goetz that sounds really useful!

@hb.resing In the mean time on V7, the ET420 power car has an animation that changes the destination board between two different values depending on which of the variations is selected.

Another option is to create a sign board by attaching a text label to a rectangle primitive of the right size, position it over the destination board on the vehicle and have an event that makes it invisible or visible. Of course this is a crude and temporary thing, but it will give the desired effect with a little care an attention.

Link to comment
Share on other sites

vor 7 Stunden schrieb Goetz:

Hello Hein,

the new V8 features user definable text on models.
You'll be able to change text like a displayed destination where a model designer adds this feature to his model.
And a number of designers are currently giving a lot of their time and effort to implement this feature.

You may want to follow the V8 beta test threads in this forum to find out more about this.

Greets
Goetz

hi Goetz, 

thanks ,

the train destination indicators have some properties that can be set in the layout , Like "label"   text 

 I was struggeling with the propertys ,objects variables etc in the event screen. I think that it must be possible and not that difficult. 

 probaly it's a matter of using the right names of the properies ,objects ,variables to set a value 

Anyway I will take a look at the  V8 beta thread.

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...