Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

number of trailer

Valued Contributor
Valued Contributor

see as the picture  a tugger  train system ,how get the trailer  number of the tractor 47B45464-4BD9-40d7-9C51-6DF7CD54502C.png

1 REPLY 1

Re: number of trailer

Phenom
Phenom

Hi @fox 

 

Do you wanna get the number of wagons of your tractor? If so, you can use a sensor with this code:

 

tractor.PNGGetting the number of wagons

 

sensorWindow.PNG

 

param SensorID: integer, Front: boolean

var rearWagon, currWagon : object
var numWagons : integer := 0

if @.isTractor
	
	currWagon := @
	rearWagon := currWagon.getRearWagon
	while rearWagon /= Void
		numWagons += 1
		currWagon := rearWagon
		rearWagon := currWagon.getRearWagon
	end
        print to_str("This tractor has ", numWagons, " wagons.")

end
Best Regards,
Paulo Araujo

Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.