BUG: Cannot replace rails with fast_replace

Place to get help with not working mods / modding interface.
d3x0r
Filter Inserter
Filter Inserter
Posts: 316
Joined: Sun Jun 04, 2017 8:56 am
Contact:

BUG: Cannot replace rails with fast_replace

Post by d3x0r »

I've been working on extending 'Upgrade Builder and Planner' to support rails (I have several mods that have different rail types)

this code doesn't work (where upgrade='straight-rail' and belt is an existing object in the world that is a different type.

Code: Select all

          new_item = surface.create_entity
          {
            name = upgrade, 
            position = belt.position, 
            force = belt.force, 
            fast_replace = true,
            direction = belt.direction, 
            type = upgrade,
            spill=false
          }
it always returns nil.
I updated the position to be

Code: Select all

            position = {x =belt.position.x+2, y=belt.position.y},  
which offsets it to the right two, and then the above upgrade works... (unles there is already a rail to the right of it)

the new_item created is immediately destroyed, and the correct object is output. All other object types in the upgrade mod with fast_replace (belts, loaders, factories)...

but then all of those I can hand overlay. I also cannot just build one rail type over another.

This also seems to affect blueprint overlay - that I can't use the bot mode which creates a blueprint from existing items, changes the name, and then does build_blueprint().

Did some testing with belts instead; if I remove my personal roboport, mark some belts for deconstruction, and then overlay a new blueprint of belts (basically the same process the lua script is doing) then when I put roboports back on they go out and do the job completely. If I mark standard rail for deconstruction, and then put a new blueprint over the deconstruction the bots will not replace, they will only remove the deconstructed rails.
User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2905
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: BUG: Cannot replace rails with fast_replace

Post by darkfrei »

Can it be rotation, not direction?
Post Reply

Return to “Modding help”