Page 1 of 1

replacing Flamethrower Turret pipe disconnect help

Posted: Sat Sep 28, 2024 8:55 pm
by Fishbus
Hey,

I have a script in my mod that replaces turrets, which is working fine for anything except turrets with pipes - like flamethrower turrets.

Simply put, when the script replaces the turret (with essentially the same thing with some improved stats - using a table.deepcopy of the original turret) the pipes disconnect and do not reconnect automatically.

I have tried to use surface.create_entity with both "target=thisturrettoreplace" and "fast_replace=true" without anything better happening.

the specific line of code that does the replacement:

Code: Select all

-- Create a new turret.
local newTurret = turret.surface.create_entity{position=turret.position, name=newName, force = turret.force, direction=turret.direction, target=turret , fast_replace=true}
Any help would be appreciated, cheers!

Re: replacing Flamethrower Turret pipe disconnect help

Posted: Sun Sep 29, 2024 6:41 am
by Pi-C
Not quite sure this is what you're looking for, but in Water Turret I have to exchange turrets on the fly depending on what time of fluid they are connected to. You may want to check out the file __WaterTurret__/swap_turrets.lua, perhaps that will get you started.

Re: replacing Flamethrower Turret pipe disconnect help

Posted: Thu Oct 17, 2024 6:46 pm
by Fishbus
Just a follow up,

Looking at your method, the distinction is removing the prototype before placing the new one.

Still seems odd it can't 'fast replace' it, but no worries, it works now. Cheers!