Jump to content

Empfohlene Beiträge

Geschrieben

Thinking I'm doing something incorrectly using variables with Trains/Cars.

See if I can explain ....

1.) I assign a variable to a Vehicles named Vehicle Type which is "TEXT"

2.) Lets say I assign Vehicle Type as a place to go at a junction ... for example "Yard", "Dock", "Warehouse"

3.) Vehicle gets to a "Contact" just before the Junction and an event using Vehicle on Track/Conctact True False ... do this, that or the other .... normal stuff.

OK what's my problem ... seems to work sometimes/sometimes not. So I run the F12 monitor. Some of the events give an error of empty variable.  Some events do not.

NOTE: Many Vehicles ... not all vehicles were assigned a "Vehicle Type", only the ones I wanted to go to a specific location.

So I started to use the condition "If Variable Exists" ... Then under True, I determine what the Vehicle Type is and act accordingly.

Sometimes that works, sometimes that generates an error and I remove the "If Variable Exist" ... and that Event works without error.

I'm doing something wrong I suspect ... don't have a clue what.

Hope I explained this well enough  !!!

Any Ideas ????

Geschrieben
vor 5 Minuten schrieb hmclay:

I started to use the condition "If Variable Exists" ... Then under True, I determine what the Vehicle Type is and act accordingly.

Sometimes that works, sometimes that generates an error

What's the error message in this particular case, hmclay?
It may hold that clue you're looking for. Without knowing what error you get when checking if the variable exists, it's difficult to guess what's going wrong.

Geschrieben (bearbeitet)

Not sure of error message, but is using "If Variable Exist", then checking for what TEXT is assigned the correct method.

I'm assuming that if a vehicle is not assigned a variable, and a check is made, that creates an error of "null" value, rather than just skip over that statement. So that is why I started to use the If Variable exist check. Why would that not work ... but in some some events, removing it does, even on cars without a Variable assigned.

In one event I need the If Variable Exists, in another it does not work ?????

What is the correct method of checking for an assigned Vehicle Variable,  ?  

Since I was getting inconsistent results, I thought using the Objects name may be a better option. Then assigning that name to every vehicle needing directed. 

Any thoughts ?

Bearbeitet von hmclay
RED highlight
Geschrieben
vor einer Stunde schrieb hmclay:

I'm assuming that if a vehicle is not assigned a variable, and a check is made, that creates an error of "null" value

Sorry, but your assumption is wrong.

The check if a variable exists looks like this (when converted to Lua):

if object["VariableName"] ~= nil then
  -- do something with the variable
end

The sole purpose of this check is to avoid the "nil value" error and only use the variable when it has content.

 

vor einer Stunde schrieb hmclay:

Why would that not work ... but in some some events, removing it does

If only I could see what you actually did.
Because whatever caused the error, it wasn't the check. It was something else. Like placing the command in the wrong field of the condition (the bottom half) or negating the check or god knows what!

Here is how it should look in graphical form:

vehiclerouteconditions.jpg.6eab68967c06634583eb30ead3babdf6.jpg

I hope this helps?
Goetz

Geschrieben (bearbeitet)
vor 7 Stunden schrieb hmclay:

Is The attach valid technique

I doubt it very much, Howard

to clarify: Your condition (as is) assumes that the variable "Vehicle Type" in the triggering vehicle holds an object. It then looks for another variable by the name of "Truck - W10" in that object, assuming that that variable holds another vehicle. And then it checks if that other vehicle is on the track that your triggering vehicle just left. 

I'm quite certain that this is far from what you actually want to achieve.

Bearbeitet von Goetz
Ergänzungen
Geschrieben

Thought this may be a problem. I'm not using this action ( Vehicle is Located on Track/Contact) correctly. Most likely my core problem concerning this topic.

Thanks, I'll use the method(s) you provided.

Howard

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