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
}
I updated the position to be
Code: Select all
position = {x =belt.position.x+2, y=belt.position.y},
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.