Curt84328 Geschrieben 17. Februar 2020 Geschrieben 17. Februar 2020 (bearbeitet) I am new to V5. and not sure how the new EV works. I have a switch tree that I want to control by Locomotive name. Ich bin neu bei V5 und bin mir nicht sicher, wie die neue EV funktioniert. Ich habe einen Weichenbaum, den ich über den Loknamen steuern möchte. I want to read the Locomotive name as it enters the green track, and then set the switches based on the locomotive name. There will be 7 locomotives, and the switch settings will vary. based on the locomotive names. Is it possible to use a table with the locomotive names and have the switch settings in the table, then set the switches based on the values in the table? Ich möchte den Namen der Lokomotive lesen, wenn sie in das grüne Gleis einfährt, und dann die Weichen auf der Grundlage des Loknamens stellen. Es wird 7 Lokomotiven geben, und die Weichenstellungen werden je nach Loknamen variieren. Ist es möglich, eine Tabelle mit dem Loknamen und die Weichenstellungen in der Tabelle haben und dann die Weichen auf der Grundlage der Werte in der Tabelle einstellen? Übersetzt mit www.DeepL.com/Translator (kostenlose Version) Bearbeitet 17. Februar 2020 von Curt84328
Timba Geschrieben 17. Februar 2020 Geschrieben 17. Februar 2020 (bearbeitet) Hi Curt, yes, this is possible. I am using exactly that for the entry or departure in my stations. Depending on where the train comes from and which station track the train will use the programm will find the correct switches by an algorithm. This is a small snippet of the table: {{$("A-K01"), 0}, {$("A-K04"), 1}, {$("A-K06"), 1}, {$("A-W04"), 0}, {$("A-W05"), 0}} And this is how it is processed: a = AEinf[kurs] for i, v in ipairs(a) do a[i][1].state = a[i][2] end Depending on where the train comes from and where it will go the variable "kurs" ist calculated, the correct line of the table will go to variable "a" (containing all switches needed and their wanted state) and finally the loop that does the actual work. Hope it helps. Regards Timba Bearbeitet 17. Februar 2020 von Timba
metallix Geschrieben 18. Februar 2020 Geschrieben 18. Februar 2020 Hi Curt I thought I show you a way of doing this by using graphic interface rather then Lua script, since you stated you just started in V5. It works like this: each loco caries a unique variable and for each loco there is a user defined event that contains the settings for the switches for the loco to arrive on it's"home" track. Instead of having a triggering track i used a track contact to trigger the event for doing the switching. In this event a dedicated condition is asking each triggering loco what variable it caries. According to that variable the user defined event gets activated to switch the path for that loco. There are possibly other ways of doing this but here is at least a starting point for you, in case you can't do script. A way of learning script is clicking in an conventional action on the <> button. This will convert the existing conventional entry into Lua, allowing to study and even modify it. For returning to the conventional entry just click on that button to the very left of the script mode button. Sorting.mbp Cheers Tom
Curt84328 Geschrieben 18. Februar 2020 Autor Geschrieben 18. Februar 2020 OK, Just to clarify, Your event list has 6 parts, you have placed triggers at the stop points on each track, and given each stop point the keyword Stop on track. That I have been able to replicate. Each Locomotive has a text key that defines the route for that locomotive (Track) and a text value (Track2) IN the EV there is an event that when trigger vehicle triggers the track contact, it sets the speed for the trigger vehicle to 0. (this does not seem to interact with other events, it just stops vehicles?) You also have some User Defined tracks that define the switch settings for a specific route (or track)? finally there is a trigger that checks the track value, and sets the route based on the track value? does that seem right?
metallix Geschrieben 19. Februar 2020 Geschrieben 19. Februar 2020 (bearbeitet) Hi Curt Yep, you covered it....I will explain it a bit Each loco has an object variable (OV) that stipulates it's destined track. On entering the track contact (TC) ahead of the station this TC reads the OV of a loco and when the content matches one of the conditions the according user defined event is executed. (So if you want to introduce another loco, it will need an OV, otherwise it will just run into the station and follow the switches as they have been set previously) Each track, in the station has a TC where the loco's get told to stop. All these TC's are addressed with one single event in the EM via use of a keyword. There is also now an option to place a comment in the EM, likewise as to place actions. I have added some comments to this demo . The demo also contains a modified action that now just identifies the loco's and then set the switches accordingly. You can activate/deactivate events by right clicking on the event and then clicking on Active. An active event will lose the tick in front of Active and of course change the font setting to italic.... Cheers Tom Bearbeitet 19. Februar 2020 von metallix
Goetz Geschrieben 20. Februar 2020 Geschrieben 20. Februar 2020 (bearbeitet) Hello @Curt84328 Picking up from Timba's suggestion, I'd like to show you my approach, which is very similar: For each destination, I store a list of tables. Each table holds one switch and it's setting. Except for the nametags "switch point" and "setting", this is exactly like Timba's first line of code. And the EV representation of his little script looks like this: That's all - one single, simple entry covering all possible destinations. I recorded a short video, explaining how it works: and here's the layout from that video: route setting via table.mbp Bearbeitet 20. Februar 2020 von Goetz
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