[kovarex] [0.15.33] Self-replacable entity revive in on_put_item
Posted: Thu Aug 31, 2017 4:46 pm
Symptom:
If an entity that is fast-replacable by itself (i.e. inserters, belts, mining drills) is .revive()'d in defines.events.on_put_item in a different rotation, then during the following fast replace the entity loses it's circuit network cables.
Background:
I was trying to write a small script that properly preserves entity settings (circuit conditions/connections, recipe, rotation, etcpp) when the player "manually revives" a ghost by building the same structure on top of a ghost.
1) Build e.g two inserters/belts and connect them with a circuit cable
2) Make a blueprint of them and place those two ghosts somewhere
3) Build an inserter on top of one of the ghosts but revive the ghost in on_put_item (e.g. using above code). Take care to hold the inserter on the cursor in a different rotation than the ghost.
4) The ghost is revived and immediately fast-replaced by itself, losing it's circuit connection but keeping circuit settings
Addendum
Everything works fine btw if you build the inserter in the same direction as the ghost, as then it can not fast-replace itself. Things that are not self-replacable are not affected either because the actual build event just fails.
Expected Behavior
Ideally the fast-replacing would be canceld so that rotation can be preserved as well ... fine, i just want it to keep the cables. Unless this whole functionality has already been secretly integrated into 0.16 .
If an entity that is fast-replacable by itself (i.e. inserters, belts, mining drills) is .revive()'d in defines.events.on_put_item in a different rotation, then during the following fast replace the entity loses it's circuit network cables.
Background:
I was trying to write a small script that properly preserves entity settings (circuit conditions/connections, recipe, rotation, etcpp) when the player "manually revives" a ghost by building the same structure on top of a ghost.
Code
Reproduction:1) Build e.g two inserters/belts and connect them with a circuit cable
2) Make a blueprint of them and place those two ghosts somewhere
3) Build an inserter on top of one of the ghosts but revive the ghost in on_put_item (e.g. using above code). Take care to hold the inserter on the cursor in a different rotation than the ghost.
4) The ghost is revived and immediately fast-replaced by itself, losing it's circuit connection but keeping circuit settings
Addendum
Everything works fine btw if you build the inserter in the same direction as the ghost, as then it can not fast-replace itself. Things that are not self-replacable are not affected either because the actual build event just fails.
Expected Behavior
Ideally the fast-replacing would be canceld so that rotation can be preserved as well ... fine, i just want it to keep the cables. Unless this whole functionality has already been secretly integrated into 0.16 .