set_driver() and set_passenger() parameters are not optional

robot256
Smart Inserter
Smart Inserter
Posts: 1243
Joined: Sun Mar 17, 2019 1:52 am
Contact:

set_driver() and set_passenger() parameters are not optional

Post by robot256 »

LuaEntity::set_driver() and LuaEntity::set_passenger() both list the parameter with a "?" at the end, implying that the parameter is optional. However, calling either function with 0 parameters will cause a script error.

You must explicitly write "nil" in the argument list in order to use the "eject player" functionality. This should be spelled out clearly because most functions in Lua treat omitted arguments as nil, but I understand the C++ API handles things a little differently. Therefore the "?" should be removed from the parameter list, and the parameter description should read "LuaEntity or PlayerIdentification or nil".
My mods: Multiple Unit Train Control, RGB Pipes, Shipping Containers, Rocket Log, Smart Artillery Wagons.
Maintainer of Auto Deconstruct, Cargo Ships, Vehicle Wagon, Honk, Shortwave.
Bilka
Factorio Staff
Factorio Staff
Posts: 3420
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: set_driver() and set_passenger() parameters are not optional

Post by Bilka »

Thanks, fixed for 2.0.57.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.
Post Reply

Return to “Resolved Requests”