Page 1 of 1

[1.1.74] LuaEntity::set_driver fails if the character is in a vehicle that it cannot exit

Posted: Mon Dec 12, 2022 4:16 pm
by Xorimuth
To reproduce, use AAI Ironclad mod.

- Place car and boat
- Enter boat, drive into lake
- Hover cursor over car
- Run `/c game.player.selected.set_driver(game.player.character)` --> nothing happens
- Run `/c game.player.vehicle.set_driver(nil) game.player.selected.set_driver(game.player.character)` --> this workaround works, now you are driving the car

There's an easy workaround, but it feels rather unintuitive. If it is decided that it is working as intended, then it should be added to the set_driver docs.

Re: [1.1.74] LuaEntity::set_driver fails if the character is in a vehicle that it cannot exit

Posted: Tue Dec 19, 2023 4:30 pm
by Rseding91
Thanks for the report. I don't want to change this behavior because from the game side there's no simple way to say it's correct and that it will actually work.

By ejecting a player from a vehicle it will fire the player driving state changed event which a mod could easily put the player back in another vehicle. If that happened the original event would need to either keep trying forever or abort the attempt to put it into the new vehicle.

So by just saying "the player must not be in a vehicle to use this" it drastically simplifies what we need to do.

I'll move this to documentation requests.