Page 1 of 1

[Lou][2.0.41] Issues with scripting and remote driving

Posted: Fri Mar 21, 2025 7:54 pm
by Gorfiend7
Ran into a couple issues with remote driving using a script/mod, where you can be driving a vehicle but have your camera on a different surface, or cause a vehicle to be stuck with a "ghost" remote driver (similar to this previous report).


First issue setup: Place a tank on Nauvis, and go to another planet (say, Fulgora).
Run this in the console:

Code: Select all

/c local tank = game.surfaces["nauvis"].find_entities_filtered({name = "tank"})[1] tank.set_driver(game.player)
You will be driving the tank, but your camera will still be on Fulgora. If you get out of the tank, you will get out on Fulgora.


Second issue setup: Place a tank and a spidertron on Nauvis.
Run this:

Code: Select all

/c local tank = game.surfaces["nauvis"].find_entities_filtered({name = "tank"})[1]
game.player.set_controller({type = defines.controllers.remote, surface=tank.surface})
tank.set_driver(game.player)
Switch to map view (press tab)
Run this:

Code: Select all

/c local spider = game.surfaces["nauvis"].find_entities_filtered({name = "spidertron"})[1]
game.player.set_controller({type = defines.controllers.remote, surface=spider.surface})
spider.set_driver(game.player)
The tank is now in the broken state again - it shows the green "Drive Remotely" button, but clicking it fails and pops up the "Vehicle already has a driver" message.
It works properly without the "Switch to map view" step, letting you directly swap between remote driving the two vehicles. The "surface" parameter to set_controller is also important - leaving that out allows it to work properly.

Re: [Lou][2.0.41] Issues with scripting and remote driving

Posted: Mon Jun 02, 2025 2:24 pm
by Lou
Thank you for the report. Since 2.0.55:
- calling set_driver in cases which would cause character to change surfaces is not supported and should throw an error.
- in other cases your controller position and surface should be updated to correspond with the driven vehicle