Page 1 of 1

[0.16.16] Player death on vehicle swap

Posted: Tue Jan 16, 2018 1:42 am
by Earendel
Creating a vehicle on top of a player is fine.

Calling .destroy() on a vehicle with a player inside is fine.

Creating a vehicle on top of a vehicle and calling .destroy() is fine.

Creating a vehicle on top of a vehicle with a player inside and calling .destroy() kills the player.

Code: Select all

/c p = game.player s = p.surface v1 = s.create_entity{name="car", position=p.position, force=p.force} v1.set_driver(p) v2 = s.create_entity{name="car", position=p.position, force=p.force} v1.destroy()
Also, if you try to move the driver/passenger into the vehicle that is not being destroyed the player still dies, even though it shouldn't be in that vehicle anymore:

Code: Select all

/c p = game.player s = p.surface v1 = s.create_entity{name="car", position=p.position, force=p.force} v1.set_driver(p) v2 = s.create_entity{name="car", position=p.position, force=p.force} v2.set_driver(p) v1.destroy()

Re: [0.16.16] Player death on vehicle swap

Posted: Tue Jan 16, 2018 5:18 am
by Rseding91
thanks for the report. You need to eject the player first before making the second car or it doesn't work (as you've seen).

Re: [0.16.16] Player death on vehicle swap

Posted: Mon Jan 22, 2018 7:21 pm
by Earendel
Eject the player with v1.set_driver(nil)?
The problem is that's not possible to do in the same tick. If you try and eject the player they still die:

Code: Select all

/c p = game.player s = p.surface v1 = s.create_entity{name="car", position=p.position, force=p.force} v1.set_driver(p) v2 = s.create_entity{name="car", position=p.position, force=p.force} v1.set_driver(nil) v2.set_driver(p) v1.destroy()
It seems like there's a delayed effect in actually ejecting the player.
This is a really big problem if you're trying to swap the vehicle the player is driving.

Re: [0.16.16] Player death on vehicle swap

Posted: Wed Jan 24, 2018 11:48 am
by Earendel
This thread is the 'Not a bug' section now and the problem is a bit different from the title, it's more complicated so maybe I should make a new thread?