Page 1 of 1

[0.13.20] manual_control_stop is never triggered

Posted: Wed Oct 12, 2016 10:54 pm
by ssilk
I found out, that the train_state is not triggered correctly.

The train state manual_control_stop is never triggered. Instead the manual_control is always triggered, when the train runs on manual.

Code example:

Code: Select all

script.on_event(defines.events.on_train_changed_state, function(event)
      log(convertState(event.train))
end

function convertState(train)
       local state = train.state
       if state == defines.train_state.manual_control and train.speed == 0 then
            return defines.train_state.manual_control_stop
       end
      return state
end
Without the if the output is always "9" when the train runs on manual. With the if it is either 8 or 9. Maybe it's already working in 0.14 but I didn't found a bug report about this.

Re: [0.13.20] manual_control_stop is never triggered

Posted: Wed Oct 12, 2016 11:23 pm
by Rseding91
Manual control stop is triggered when the train is driving and you click the "manual" button at which point the train stops.

And yes, it is triggered correctly: http://imgur.com/a/lxA3h

Re: [0.13.20] manual_control_stop is never triggered

Posted: Wed Oct 12, 2016 11:55 pm
by ssilk
Rseding91 wrote:Manual control stop is triggered when the train is driving and you click the "manual" button at which point the train stops.
You mean it was in automatic mode and driving and then you changed to manual mode and wait until the train stops?
Hm. That could make also sense, but for a modder I don't see the use-case. :)

Re: [0.13.20] manual_control_stop is never triggered

Posted: Thu Oct 13, 2016 1:04 am
by Rseding91
ssilk wrote:
Rseding91 wrote:Manual control stop is triggered when the train is driving and you click the "manual" button at which point the train stops.
You mean it was in automatic mode and driving and then you changed to manual mode and wait until the train stops?
Hm. That could make also sense, but for a modder I don't see the use-case. :)
The states existed before the event and have nothing to do with mods. I simply added the event so you could listen to it and do things when the train enters the different states instead of having to constantly listen on_tick.

Re: [0.13.20] manual_control_stop is never triggered

Posted: Thu Oct 13, 2016 11:39 am
by ssilk
Sorry, I did't mean, that the event-functionality isn't useful (something like that would be useful for all kinds of vehicles (just driving forward, backward, stop would be enough)).
It just lacks documentation that the use-cases for the train.state is limited and different of what you would expect.