Jump to content

Empfohlene Beiträge

So, I figured it would be quite clever if an electric train pulls into the station and all the doors slide open. the train waits for a few (scale) minutes  - i.e. ten seconds - then closes the doors and heads off up the track. So I can make the first car in the train (the one driving) open the doors, but I can't figure out the iteration to make it do the rest.

It should be "For every vehicle on a track/contact" or "For every vehicle in a train/group" (Not the exact wording but you know which I mean...)

But  the only animations I can get at are (non-existent) ones fr the track contact that triggers the event.

In fact, I don't seem to be able to reference vehicle animations at all, directly. I had to go into the code editor and fiddle with it to get it to do just the front coach.

Surely this is a bug? Surely the whole point of the two iterations I mention above is to be able to play the animations on every car/wagon in a train?

Link zu diesem Kommentar
Auf anderen Seiten teilen

Hi Simon,

vor 9 Stunden schrieb simonjackson1964:

Surely this is a bug?

surely ain't!

You can iterate over the entire train.

125967716_iteratingoveratrain1.jpg.e70e07192b0a956ce7cc8a6ee4682836.jpg


The train can be identified via the triggering vehicle.

1625835601_iteratingoveratrain2.jpg.6ada6d55b1c78fecb6c223aa3ed75b12.jpg

 

make sure, you change the trigger from "track contact" to "´vehicle"

1218391673_iteratingoveratrain3.jpg.b8828e7f7af9475619d56d715d300c68.jpg

 

 

example layout: D430E4C7-25C2-4C0A-AF64-4F2138B91958

This one is much simpler than my older tram example. The iteration wasn't available yet, when I built the layout with the four tram stops.

 

Please note that in this example, I first check if the vehicle has a door by the name that I want to open. Because the engine has no such door and the code would fail if I tried to open a non-existent door.

Bearbeitet von Goetz
Link zu diesem Kommentar
Auf anderen Seiten teilen

On 3/2/2021 at 9:22 AM, Goetz said:

Hi Simon,

surely ain't!

You can iterate over the entire train.

125967716_iteratingoveratrain1.jpg.e70e07192b0a956ce7cc8a6ee4682836.jpg


The train can be identified via the triggering vehicle.

1625835601_iteratingoveratrain2.jpg.6ada6d55b1c78fecb6c223aa3ed75b12.jpg

 

make sure, you change the trigger from "track contact" to "´vehicle"

1218391673_iteratingoveratrain3.jpg.b8828e7f7af9475619d56d715d300c68.jpg

 

 

example layout: D430E4C7-25C2-4C0A-AF64-4F2138B91958

This one is much simpler than my older tram example. The iteration wasn't available yet, when I built the layout with the four tram stops.

 

Please note that in this example, I first check if the vehicle has a door by the name that I want to open. Because the engine has no such door and the code would fail if I tried to open a non-existent door.

Ah yes, but that is not where the problem lies....

422434618_Animationsbug.thumb.jpg.f09b7e1f7df9a1bbfaa22870a3ee8fa1.jpg

There is no way to get at the vehicle's animations...

 

Bearbeitet von simonjackson1964
remove unwanted image
Link zu diesem Kommentar
Auf anderen Seiten teilen

vor 22 Minuten schrieb simonjackson1964:

There is no way to get at the vehicle's animations...

yes, there is - check my example, please
select the iteration as your object. That's what you iterate over the train for, Simon.

Sorry, you're right.
I just tried. And then I remembered, why I stuck part of the code in a separate, user defined event.

Because I can pass the element from my iteration on to that event. And now it's a trigger, which I can use as a target for my animation call.

Am I making sense? Or should I try for a better explanation?

Bearbeitet von Goetz
Link zu diesem Kommentar
Auf anderen Seiten teilen

@Goetz

Have you tried to put the "Play Animation" action in the iteration? It will only allow "Track Contact"

In fact try accessing any vehicle animation from any event?

1618289825_NoTrigger.thumb.jpg.2eb2f2c3eb7a839ac6190327976b1010.jpg

Note the absence of a "trigger" option. If you want a vehicle to play one of it's animations when it triggers an event you have to name it explicitly! Which rather defeats the object of those iterations.

I did manage to get the first set of doors to open by doing this:

941362713_Firstcaronly.thumb.jpg.f24eec3bfd1193786a3325e68e4f2af8.jpg

But it's only opening the doors on the first car. (The variable "Doors right" is an object level boolean on each car because it's an E.M.U. with the trailing drive unit facing backwards - plus I wasn't certain which way round the centre cars were either.)

Link zu diesem Kommentar
Auf anderen Seiten teilen

Your Lua code is flawed

for i, Iter in ipairs(t) do

i and Iter generate two local variables and in ipairs fills them with the key and the value of one element in table t

You don't need the key of the cell. 
But you need it's value, because that is your waggon. Your vehicle

which is why the next lines should have iter in place of vehicle.

Or - better - change the line from above into

for i, vehicle in pairs(t) do

 

I agree that the graphical EV doesn't cover everything. Which is why it's a godsend, that you can switch to Lua where needed.

 

Bearbeitet von Goetz
Link zu diesem Kommentar
Auf anderen Seiten teilen

25 minutes ago, Goetz said:

yes, there is - check my example, please
select the iteration as your object. That's what you iterate over the train for, Simon.

Sorry, you're right.
I just tried. And then I remembered, why I stuck part of the code in a separate, user defined event.

Because I can pass the element from my iteration on to that event. And now it's a trigger, which I can use as a target for my animation call.

Am I making sense? Or should I try for a better explanation?

Thank you.

Right, so I have managed to create the user defined event, and call it from the iteration... But it is still only opening the doors on the first car.

7 minutes ago, Goetz said:

Your Lua code is flawed


for i, Iter in ipairs(t) do

i and Iter generate two local variables and in ipairs fills them with the key and the value of one element in table t

You don't need the key of the cell. 
But you need it's value, because that is your waggon. Your vehicle

which is why the next lines should have iter in place of vehicle.

Or - better - change the line from above into


for i, vehicle in pairs(t) do

 

I agree that the graphical EV doesn't cover everything. Which is why it's a godsend, that you can switch to Lua where needed.

 

That explains that. I had a feeling it was something like it, but I wasn't sure of the syntax. I think I will try that first.

 

Link zu diesem Kommentar
Auf anderen Seiten teilen

:D:D:D:D:D:D:D:D:D:D

IT WORKED

Thanks.

By the way in case anyone is wondering, the other event, "Blank advance signal", is there to solve a random issue I was puzzling over concerning German signals.

British light signals use the amber light as an advance signal to give the state of the next signal - if it is lit the next one is red if two ambers are lit (on busy mainlines only) the next one is single amber and the one after is red.

The German pre-signal (diagonal amber and green lights for anyone else not German) will show green if the next signal is green, will show yellow if the next one is red and will show green and yellow if the next one is green and yellow. But this leads to an anomaly. If the main signal the advance signal is attached to is red, but the signal it is repeating is green, you would have a green signal on the same pole as a red one.

A bit of research found the answer:

"When a distant signal and a main signal are mounted at one post, the main signal is on the upper
position. If that main signal shows "stop", the distant signal is dark"

- German Signal Aspects and Lineside Signs - DriveHQ

So that's what that does - if a signal with a keyword "Distant signal attached" goes to HP0, it calls the animation that turns off the distant, and vice versa.

Link zu diesem Kommentar
Auf anderen Seiten teilen

29 minutes ago, Goetz said:

you have your German signals sussed, Simon (y)

 

Took me a while and a lot of research... :D I'm still not completely sure what HP2 is for... It indicates that the train should proceed at 40kph (25mph) or other speed as indicated. If there is a sharp bend or hazard ahead, surely that would be the track speed... The only use I can think is for turn-outs (points/switches), when set to curve? Which effectively makes it the same as the British junction signal...

Link zu diesem Kommentar
Auf anderen Seiten teilen

The final product:

518641295_Outerevent.thumb.jpg.f7eceac3260dff8e242700b11fa66de7.jpg1699501203_Innerevent.thumb.jpg.bdb5facc8a213671b56b4017b66889ca.jpg

The second parameter on the User Defined Event is so I can use the same event to open and close the doors.

I went back to the graphical EV because I couldn't get the second deferral to work in Lua. The train left while closing the doors or closed them the left while opening them again... I know it was a bug in my syntax, but I can't be bothered to fix it, because I realised what I was doing wrong in the graphical version, fixed it and it works! (It should be obvious but one of each pair of animations is forward and one is backward).

Posting this because I like celebrating my success, but also because there might be someone with a similar issue, and they might see this and think "Oooooh!"

First time using a user defined event, and I think I've got the hang of how they work and how useful they can be, too!

Link zu diesem Kommentar
Auf anderen Seiten teilen

vor 1 Stunde schrieb simonjackson1964:

The only use I can think is for turn-outs (points/switches), when set to curve?

That is precisely what the HP2 setting is for. Great guess.

 

vor 28 Minuten schrieb simonjackson1964:

First time using a user defined event, and I think I've got the hang of how they work

neat! (y)

Link zu diesem Kommentar
Auf anderen Seiten teilen

To quote one of my childhood heroes:

7e350e166290403c93cb84162bbad2ca.jpg.7824ec022da8e3e82535c7c40472e690.jpg

I have successfully changed the destination boards on both ends and the two middle drive cars of 6-car EMUs. I hat to use the hasEngine() function that the set vehicle speed action uses to make sure that I only attempted the change on the drive cars and not the two centre pantograph cars that don't have the destination board.

But it works!

Link zu diesem Kommentar
Auf anderen Seiten teilen

Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren

Du musst ein Benutzerkonto besitzen, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen.

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde dich hier an.

Jetzt anmelden
×
×
  • Neu erstellen...