simonjackson1964 Geschrieben 2. März 2021 Geschrieben 2. März 2021 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?
Curt84328 Geschrieben 2. März 2021 Geschrieben 2. März 2021 First, give each car with doors that you want to open a keyword trigger: For each car with keyword Play animation forward timer timer expires Play animation reverse set vehicle speed for locomotive.
BahnLand Geschrieben 2. März 2021 Geschrieben 2. März 2021 (bearbeitet) Hello @simonjackson1964, for example, see here and here! Especially, start the mbp-file which is attached to the 2nd referred comment. Many greetings BahnLand Bearbeitet 2. März 2021 von BahnLand
Goetz Geschrieben 2. März 2021 Geschrieben 2. März 2021 (bearbeitet) Hi Simon, vor 9 Stunden schrieb simonjackson1964: Surely this is a bug? surely ain't! You can iterate over the entire train. The train can be identified via the triggering vehicle. make sure, you change the trigger from "track contact" to "´vehicle" 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 2. März 2021 von Goetz
Atrus Geschrieben 3. März 2021 Geschrieben 3. März 2021 So so, sehr interessant. Thank's a lot ! LG Atrus
simonjackson1964 Geschrieben 3. März 2021 Autor Geschrieben 3. März 2021 (bearbeitet) On 3/2/2021 at 9:22 AM, Goetz said: Hi Simon, surely ain't! You can iterate over the entire train. The train can be identified via the triggering vehicle. make sure, you change the trigger from "track contact" to "´vehicle" 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.... There is no way to get at the vehicle's animations... Bearbeitet 3. März 2021 von simonjackson1964 remove unwanted image
Goetz Geschrieben 3. März 2021 Geschrieben 3. März 2021 (bearbeitet) 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 3. März 2021 von Goetz
simonjackson1964 Geschrieben 3. März 2021 Autor Geschrieben 3. März 2021 @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? 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: 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.)
Goetz Geschrieben 3. März 2021 Geschrieben 3. März 2021 (bearbeitet) 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 3. März 2021 von Goetz
simonjackson1964 Geschrieben 3. März 2021 Autor Geschrieben 3. März 2021 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.
Goetz Geschrieben 3. März 2021 Geschrieben 3. März 2021 vor 2 Minuten schrieb simonjackson1964: I think I will try that first. and keep asking ... i'm glad to help, when I can. Don't mind, if I sound stubborn at times, please.
simonjackson1964 Geschrieben 3. März 2021 Autor Geschrieben 3. März 2021 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.
simonjackson1964 Geschrieben 3. März 2021 Autor Geschrieben 3. März 2021 29 minutes ago, Goetz said: you have your German signals sussed, Simon Took me a while and a lot of research... 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...
simonjackson1964 Geschrieben 3. März 2021 Autor Geschrieben 3. März 2021 The final product: 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!
Goetz Geschrieben 3. März 2021 Geschrieben 3. März 2021 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!
simonjackson1964 Geschrieben 4. März 2021 Autor Geschrieben 4. März 2021 To quote one of my childhood heroes: 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!
Empfohlene Beiträge
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 erstellenAnmelden
Du hast bereits ein Benutzerkonto? Melde dich hier an.
Jetzt anmelden