Jump to content

Empfohlene Beiträge

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

sort.thumb.jpg.36310834517cc1d7697e54d5b66da6f2.jpg

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 von Curt84328
Geschrieben (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 von Timba
Geschrieben

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

Geschrieben

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?

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

curt.thumb.JPG.80aa6aae0fff48f61c01bfad31dc8fe0.JPG

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)

Curt2.thumb.JPG.661b90b218a45ffcafe0ad61c210dbb2.JPG

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.

382096081_Curt3.thumb.JPG.01a409a58437944ee4c57e9b84c0f0a2.JPG

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 von metallix
Geschrieben (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.

1411573621_listoftables.thumb.jpg.7073b0fa53f3c3d0321d9d251bbdc1c4.jpg

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:

1254526862_iteratingoveralist.thumb.jpg.b7be288fd1251a7ce234bc4f94c39d31.jpg

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 von Goetz

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