hmclay Geschrieben 16. April 2023 Geschrieben 16. April 2023 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!
Goetz Geschrieben 16. April 2023 Geschrieben 16. April 2023 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 select this parameter via the entry "trigger" where you want to make use of the keyword that you receive when calling the user event: and enter the word of your chosing when you call the userevent in response to some other event kind regards Goetz
Goetz Geschrieben 16. April 2023 Geschrieben 16. April 2023 (bearbeitet) 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 16. April 2023 von Goetz corrections
simonjackson1964 Geschrieben 16. April 2023 Geschrieben 16. April 2023 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.
Goetz Geschrieben 16. April 2023 Geschrieben 16. April 2023 (bearbeitet) 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 16. April 2023 von Goetz spelling
hmclay Geschrieben 17. April 2023 Autor Geschrieben 17. April 2023 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 !!!!
simonjackson1964 Geschrieben 17. April 2023 Geschrieben 17. April 2023 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.
hmclay Geschrieben 17. April 2023 Autor Geschrieben 17. April 2023 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!
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