Jump to content

local t = layout:getVehiclesOn(signal)


Empfohlene Beiträge

Hello, 

Maybe a more special question, but here we go.

Just to see if I have a good understanding wich t comes out here :

local t = layout:getVehiclesOn(signal)  gives a table  t with the vehicles on that track contact. ( 1 item or none )
local t = layout:getVehiclesOn($("LongTrack")) gives a table t with the vehicles on that track


I want to know if there is a vehicle an the contact of the signal.
In previous tests I used # for the number of items in a table.
  if #t ~= 0 then  ( there is a vehicle on the signal , a wagon or a loc )

So far so good, my problem is solved.

But t is a table, the test
if t ~= {}  an empty table  failed, why  ?

Some help is welcome.

Kind regards,

Herman 

 

 

Link zu diesem Kommentar
Auf anderen Seiten teilen

vor 7 Minuten schrieb Herman:

like a pointer

exactly.
t and {} are two different tables.
You want to know, if both have the same property (i.e. the same number of entries),
but with t == {} you're asking if both are the same table.

 

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