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

Place to report issues and suggest improvements to the API documentation.
Xorimuth
Filter Inserter
Filter Inserter
Posts: 700
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

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

Post 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.
My mods
Content: Lunar Landings | Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings
Rseding91
Factorio Staff
Factorio Staff
Posts: 14413
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Documentation Improvement Requests”