replacing Flamethrower Turret pipe disconnect help

Place to get help with not working mods / modding interface.
User avatar
Fishbus
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Sep 28, 2024 8:20 pm
Contact:

replacing Flamethrower Turret pipe disconnect help

Post 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!
Pi-C
Smart Inserter
Smart Inserter
Posts: 1734
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: replacing Flamethrower Turret pipe disconnect help

Post 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.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
User avatar
Fishbus
Manual Inserter
Manual Inserter
Posts: 4
Joined: Sat Sep 28, 2024 8:20 pm
Contact:

Re: replacing Flamethrower Turret pipe disconnect help

Post 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!
Post Reply

Return to “Modding help”