Page 1 of 1

Option to not raise on_driving_state_changed

Posted: Sun Oct 13, 2019 11:06 am
by Pi-C
The destroy() method has these options
destroy(opts) → boolean

Destroys the entity.

Parameters
opts (optional): Table with the following fields:

do_cliff_correction :: boolean (optional): If neighbouring cliffs should be corrected. Defaults to false.
raise_destroy :: boolean (optional): If true; defines.events.script_raised_destroy will be called.
I'd like to have something like raise_destroy for set_driver() and set_passenger(), so that they don't raise the on_driving_state_changed event.

Reason: In this mod, I want to move vehicles with driver/passenger between surfaces. As only players can be moved with teleport(), I need to clone the vehicle to the new surface and then place driver/passenger inside it. Technically, they change the driving state because they leave one vehicle and enter another one. However, from the player's perspective, they would remain in the same vehicle, so not raising the event would mean not running (unnecessarily) a lot of code.

Re: Option to not raise on_driving_state_changed

Posted: Wed Oct 16, 2019 1:29 am
by boskid
FactorioBot wrote: Tue Oct 15, 2019 8:19 pm Scripting
  • Added support to teleport car entity types between surfaces.
For now i will throw this request to Won't Implement because ability to teleport cars should solve your underlying issue.

Re: Option to not raise on_driving_state_changed

Posted: Wed Oct 16, 2019 4:36 am
by Pi-C
boskid wrote: Wed Oct 16, 2019 1:29 am
FactorioBot wrote: Tue Oct 15, 2019 8:19 pm Scripting
  • Added support to teleport car entity types between surfaces.
For now i will throw this request to Won't Implement because ability to teleport cars should solve your underlying issue.
Ooops, didn't see the announcement yet. Nice thing to wake up to! If cross-surface teleporting really works now, it would indeed solve the problem and simplify my code significantly. I'll try it out later, thanks! :-)