Hi all:
I just took the first modding tutorial, spent some time reading over the APIs, and studied the events.
I'm trying to make a mod called "Nice Try, Train" that will either halt the train on collision with a player, or have the train completely explode on high speed contact with a player. Kind of a Thor/Hulk situation.
I've found on_damage event, however, some initial testing seems that the event is not called before on_player_died, so I cannot respond and prevent the sudden death.
Can you lend me any tips?
Thanks
How can detect a player collision with a train?
Re: How can detect a player collision with a train?
Hi,
have a look at this mod: viewtopic.php?f=190&t=21725&hilit=Jesus#p136492
This moves the player away from track.
But you are looking for http://lua-api.factorio.com/latest/even ... layer_died
have a look at this mod: viewtopic.php?f=190&t=21725&hilit=Jesus#p136492
This moves the player away from track.
But you are looking for http://lua-api.factorio.com/latest/even ... layer_died
Re: How can detect a player collision with a train?
hmm. looks like i actually cannot prevent the death. per viewtopic.php?f=28&t=48225&p=291267&hil ... nt#p291267 you are unable to cancel events. because of this, the death event is inevitable.
this is too bad, as it would be much more efficient to detect an upcoming death, test if it was caused by train, then cancel it (or explode the train ).
- bobingabout
- Smart Inserter
- Posts: 7352
- Joined: Fri May 09, 2014 1:01 pm
- Contact:
Re: How can detect a player collision with a train?
I've been told that in this event, you should be able to change the player character's health back to a non-zero value to cancel death.cdaringe wrote:ah, on_PRE_player_died! how did i miss that! thanks!
hmm. looks like i actually cannot prevent the death. per viewtopic.php?f=28&t=48225&p=291267&hil ... nt#p291267 you are unable to cancel events. because of this, the death event is inevitable.
this is too bad, as it would be much more efficient to detect an upcoming death, test if it was caused by train, then cancel it (or explode the train ).
Re: How can detect a player collision with a train?
indeed you're correct, @bobingabout. thanks!
https://github.com/cdaringe/nice-try-tr ... ol.lua#L12
https://mods.factorio.com/mod/nice-try-train
https://github.com/cdaringe/nice-try-tr ... ol.lua#L12
https://mods.factorio.com/mod/nice-try-train