Jump to content

How to pass a keyword to a user event ... how to access a keyword from an unknown vehicle on a track/contact.


Empfohlene Beiträge

Can someone explain how to pass or reference a keyword from a user event.

Do you use a list, table, variable, extended variable ???  .... do you need to know the keyword ahead of time ...

or can you find a keyword from an unknown vehicle on a track/contact .... the track section is short (end of track bumper sort of thing)

Thanks!

 

Link zu diesem Kommentar
Auf anderen Seiten teilen

You define a parameter as part of the user event.
Use the type "text" when you want to pass a word of your chosing as a keyword

keywordparameter1.jpg.e6eb7c9b565c785e166252d763092168.jpg

 

select this parameter via the entry "trigger" where you want to make use of the keyword that you receive when calling the user event:

keywordparameter2.jpg.d44077f73d93f7cd1c4c6e0e24240fbe.jpg

 

and enter the word of your chosing when you call the userevent in response to some other event

keywordparameter3.thumb.jpg.38b2acfceb253743d447b6ef9a7ec2b9.jpg

 

kind regards
Goetz

 

Link zu diesem Kommentar
Auf anderen Seiten teilen

vor 7 Stunden schrieb hmclay:

can you find a keyword from an unknown vehicle on a track/contact ...

I tried and found that I couldn't.

Keywords are for grouping elements. They allow you to affect all objects with the same keyword at once. Like turning all lanterns marked by a keyword on or off.

When you want to destinguish types of vehicles (e.g. passenger, freight, shunt ...), a keyword is the wrong means.
Use a variable instead, because a variable has the word which defines your vehicle type as a content, whereas a keyword is like a variable's name.

Bearbeitet von Goetz
corrections
Link zu diesem Kommentar
Auf anderen Seiten teilen

I think actually there is a way to do this.

First, let me check what you are actually trying to achieve: You have a user defined event that presumably is called when a vehicle hits a track contact, and you want to set a condition based upon a keyword on that vehicle?

In fact @Goetz is not entirely correct. A keyword is either present or absent. This is a binary condition, 1 or 0, that equates exactly to a boolean variable. I frequently use the "Property/Variable Exists" condition to check for the existence of a keyword on an object, and as with all conditions this returns a boolean result, true or false.

What I think you need to do is create a Module boolean variable. Then within your UDE, you set that variable to true (1) or false (0) depending on the condition "If Variable "keyword" exists."

Be warned though: This will only work correctly if it is only possible for it to happen once at a time. If you have the UDE called whenever a vehicle hits one particular track contact, it should be fine. If it is called when a vehicle hits a track contact with keyword, you may get unpredictable results. I that case it might be better to put the boolean variable on the track contact and pass the Object ID of the contact to the ODE as a parameter. The effect should be pretty much the same.

Link zu diesem Kommentar
Auf anderen Seiten teilen

vor 10 Minuten schrieb simonjackson1964:

In fact Goetz is not entirely correct. A keyword is either present or absent.

Please, look again at what he's asking, Simon!

He's attempting to read which keyword the triggering vehicle has.
Not if one specific keyword is present or not.

And then he'd like to pass that keyword on to the user defined event.

Under those circumstances a keyword is the wrong choice and he should use a variable instead. Because he can read (and pass on) the content of that variable. Whereas he cannot read the name of the keywords that the vehicle has assigned. 

hmclay is getting labels and contents of stored information confused.

Bearbeitet von Goetz
spelling
Link zu diesem Kommentar
Auf anderen Seiten teilen

Thanks to both of you for the responses ... they are both helpful with understanding how variables/keywords work.

Goetz , you explained how to correct the current situation. Labels and information ... that says a lot !

simonjackson196, you gave information that helps me further understand how to use keywords ... future situations will benefit from that info.

Thanks to both of you for your help !!!!

Link zu diesem Kommentar
Auf anderen Seiten teilen

Sorry I thought Mr Clay was trying to pass a keyword out of a user defined event. I miss-read. My apologies!

While Goetz's solution is definitely more efficient, if you already have a number of keywords set on a number of vehicles and it would be a lot of trouble to change them, you could feasibly use a nested (or repeated) condition to check for the existence of each keyword in turn and set a variable to the name of the keyword before passing it down...! The choice between nested or repeated would depend upon whether a given vehicle could have more than one of the keywords being tested for, and if it has more than one which should take precedence.

Link zu diesem Kommentar
Auf anderen Seiten teilen

Thanks simonjackson196 ... that's a good point for me to keep in mind. I'm just getting started using keywords and such. Overlooked the use of variables, and as Goetz stated, looking at keywords as a variable was incorrect. Between both of your responses, I have a better understanding.

Thanks much!

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