Jump to content

Help with learning The EV and Variables Hilfe bei der EV und Variablen Lernen


Empfohlene Beiträge

I am trying to learn as much as I can about using the EV and variables, and find that I do not know as much as I would like.   I am asking members of the community for help.

Here is some of what I do know.

A variable is a container that holds a value.

to reference the value in a variable, you use the $ sign.

there seem to be 3 types if variables,  Object variables that are assigned to an object, and are referenced by the object name (then a dot) and the name of the object variable.

A second type of variable is created by the user in the EV.

The third type is created by MBS and has a _ (Underscore) as the first part of the name.

Variables can be compound, with the second part referencing the first part.  example: _Trigger1._Name  being the value of the name of triggering object1.

am I missing anything so far?   Am I wrong on anything?

 

Ich versuche, so gut ich über die Verwendung der EV und Variablen können zu lernen und feststellen, dass ich nicht so viel wissen wie ich möchte. Ich bin Mitglied der Community um Hilfe zu bitten.

Hier einige was weiß ich.

Eine Variable ist ein Behälterdas einen Wert hält.

den Wert in einer Variablen auf Referenz, verwenden Sie die $ -Zeichen.

scheint es drei Typen zu sein, wenn Variablen, Variablen-Objekt, das einem Objekt zugewiesen sind, und sind von der Objektnamen (dann ein Punkt) und dem Namen des Objektvariable referenziert.

Ein zweiter Typ einer Variable wird von dem Benutzer in dem EV angelegt.

Der dritte Typ ist durch MBS erstellt und hat einen Unterstrich (_) als das erste Teil des Namens.

Variablen können Verbindung mit dem zweiten Teil dem ersten Teil Referenzierung sein. Beispiel: _Trigger1._Name der Wert des Namens zu sein object1 auszulösen.

Bisher bin ich etwas fehlt? Bin ich auf irgendetwas falsch?

Link zu diesem Kommentar
Auf anderen Seiten teilen

Hi Curt, you are close

The $ is used to tell the program that the value following is a name, or pointer, to a different value...

For example if you have variable_1 and Variable_2 and you want to set variable_2 to whatever variable_1 contains
You need to enter the term $Variable_1 to tell the handler to use the entry as a pointer to the actual value, not the literal string "Variable_1" 

example: Variable_1 contains value 10, Variable_2 initially empty
                Setting Value of variable 2 WITHOUT the $  will make Variable two say "Variable_1"
                                                           With the $,  Variable_2 will become the value 10


It does get confusing though if you are using variables to point at other variables and objects.
Mud?


The dot notation is only partly true.
You can in fact create variables with dots in the name either globally or on an object as seen in the attached image. It's not a great idea to do so, but there is nothing to stop you. Bracketing offers the real control.

As you say, the underscore notation is typically used for system variables, but again you can use this notation also. I tend to use this notation for any variables I create on objects dynamically in the event manager to distinguish them from the ones I need to set manually.

Be aware _Trigger1 and _Trigger2 are not really system variables. Those are two variables that are created on the fly as entry conditions for each event. They have no scope or existence outside that particular event. 

In most cases the triggers are pointer to something else, e.g. a track or a switch or whatever else is related to the event. So yes the triggers usually have sub-properties. 

You can use this to your advantage if you set variables in the objects. For example if you add say Position as a variable to a locomotive, and use the train enters track (any locomotive) event, you can set the _Trigger1.Position = $_Trigger2. So now the locomotive that entered the track has a property on it that points at the test track it entered last.

Note this means variables are not limited to being just values. You can set a variable to be another object. (Well.. really the NAME of another object.) I believe you already did this with a camera pointer. However, if you use that feature make sure all your objects that you intend to reference that way have unique names. If you do not, it will always reference the oldest object with that name on your layout.

The bracketing notation takes that whole thing a step further effectively giving you pointers to pointers to pointers .... to a value or object. As is, the bracketing seems kind of pointless. You would think you could use the dot notation on it's own, but, and I am guessing here, because you can have dots in names that was not possible.
 

Screenshot_66.jpg

Bearbeitet von trevor
Link zu diesem Kommentar
Auf anderen Seiten teilen

Greetings all.

It's my understanding that the system generates 2 variables every time a train enters a track,  trigger 1 being the identity of the loco, and trigger 2 being the identity of the track.  (actually trigger 1 has 4 sub variables,  Name, Current speed, Target Speed, and visibility)  does trigger 2 have sub varibles?    does the generation of these two variables happen automatically every time a loco enters a track, or does it take an event in the EV to trigger the generation of the variables?.     It would seem that actually when a loco leaves a track, that the system would generate the same type of variable, and then overwrite them as the loco entered the next track.      Comments?

Bearbeitet von Curt84328
Link zu diesem Kommentar
Auf anderen Seiten teilen

4 hours ago, Curt84328 said:

Greetings all.

It's my understanding that the system generates 2 variables every time a train enters a track,  trigger 1 being the identity of the loco, and trigger 2 being the identity of the track.  (actually trigger 1 has 4 sub variables,  Name, Current speed, Target Speed, and visibility)  does trigger 2 have sub varibles?    does the generation of these two variables happen automatically every time a loco enters a track, or does it take an event in the EV to trigger the generation of the variables?.     It would seem that actually when a loco leaves a track, that the system would generate the same type of variable, and then overwrite them as the loco entered the next track.      Comments?

CURT you can think of it like a function....

Function Train_Enters_Track(_Trigger1 as Locomotive, _Trigger2 as Track_Section)
   If Other Conditions met
       Execute Actions
   End IF
End Function

The two entry conditions to the function are automatically pre-set by the application and only exist for the duration of the function.

And yes, because they are really pointers to the actual objects, they have sub-properties, ... the built in ones, and any variables and pointers that YOU might have attached to those objects.

Bearbeitet von trevor
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...