Page 1 of 1

Train 'riding state'

Posted: Sat Jul 22, 2017 11:15 pm
by d3x0r
It would be super useful (to me) if trains could have their acceleration state similar to riding_state. Especially when it thinks its decelerating.

Code: Select all

riding_state [Read-Write]
    Current riding state of this car or the vehicle this player is riding in.

    It is a table with two fields:

        acceleration :: defines.riding.acceleration
        direction :: defines.riding.direction

Code: Select all

riding
    acceleration
       defines.riding.acceleration.nothing	
       defines.riding.acceleration.accelerating	
       defines.riding.acceleration.braking	
       defines.riding.acceleration.reversing	
    direction
       defines.riding.direction.left	
       defines.riding.direction.straight	
       defines.riding.direction.right

Re: Train 'riding state'

Posted: Sun Jul 23, 2017 3:22 am
by Rseding91
I'm not sure what you're asking for. The locomotive already supports riding state?

Re: Train 'riding state'

Posted: Sun Jul 23, 2017 4:23 am
by d3x0r
Rseding91 wrote:I'm not sure what you're asking for. The locomotive already supports riding state?
ya but not without a player...
the train itself accelerates/decelerates without player input.
(hmm maybe I was looking at the wrong thing and I need to look at the movers)
going back; I was looking at movers since it shoudl be a LuaEntity property(?)
error2.png
error2.png (67.86 KiB) Viewed 1907 times

Code: Select all

	local frontLoco = train.locomotives.front_movers[1];
	if not frontLoco then
		frontLoco = train.locomotives.back_movers[1];
	end
-- either of these lines as 408 results in the above error.
	log( "riding  State:".. tostring(frontLoco.riding_state )); 
	log( "riding  State:".. tostring(train.riding_state )); 

Re: Train 'riding state'

Posted: Tue Oct 02, 2018 10:27 pm
by Rseding91
There is no riding state when there isn't a player in the train. The train accelerates and decelerates as it deems necessary but doesn't change any state while it does it. It's always "on-the-path" - driving to it's destination and so on.

You can listen to the train state events to tell when they change.