Moon Logic deprecated

by mk-fg

Adds Lua-programmable circuit network combinator. Based on Sandboxed LuaCombinator and LuaCombinator2 mods. Probably won't work in multiplayer games.

Content
2 years ago
1.0 - 1.1
4.97K
Circuit network

b [bug] No ghost is left after the entity is destroyed

4 months ago
(updated 4 months ago)

A bigger wave of biters just hit me and they destroyed a bunch of things, including a couple Moon Logic combinators. Every entity they destroyed left a ghost so it was easy to rebuild them, except the Moon Logic combinators. There was no ghost for those. They just disappeared.

To test the issue further, I then purposefully shot a Moon Logic combinator to death (by holding key "C") to see if it leaves a ghost.. and the answer is no. It didn't leave a ghost. (To make sure this is really a bug with the Moon Logic combinator, I did the same test with a piece of stone wall, an arithmetic combinator, and an Inventory Sensor (this latter one is an entity from a mod called "Inventory Sensor") just to make sure, and they all left ghosts, so the Moon Logic combinator seems to be the odd one out.)

I find this an impactful Quality of Life issue because if someone has an outpost that relies on a couple Moon Logic combinator that get destroyed then one will have a hard time restoring both the code and also the red & green wire connections from memory.

Does this bug reproduce for anyone else?
Do you have an idea of what might be causing it and how could it be fixed?
(I'm not familiar with Factorio's modding API at all but if someone has a couple pointers on what might be causing this bug I might consider submitting a pull request :) )

FYI:
I'm on factorio version 1.1.109 (build 62320, win64) and using the following mods:
Inventory Sensor
LTN - Logistic Train Network
LTN/Cybersyn - TCS Refuel Compatibility Mod
Moon Logic
Picker Dollies
Quick Item Search
Teleport Shortcuts & Hotkeys
Train Control Signals
Train Schedule Helper

4 months ago
(updated 4 months ago)

Yeah, thanks for reporinting.
Don't think I remember implementing or testing it, or ever had those combinator destroyed by biters, and guess not many other people had either.

control.lua has local function on_destroyed(ev) mlc_remove(ev.entity.unit_number) end which destroys the entity, and cleans-up all internal info associated with this particular mlc, including invisible constant combinators used for outputs and invisible wires to those.

I think right fix might be to only remove invisible entities (via out_wire_clear_mlc part of that mlc_remove), so that e.g. invisible wires won't need to be reconnected, and not remove internal data or destroy the main (visible) combinator, and let factorio do the latter, which I think should leave the ghost behind.
Ghost should probably keep same entity.unit_number (corresponding to "uid" value used to track mlc's), and reviving it will be same as building such mlc entity from blueprint, i.e. already handled by on_built hook.

So yeah, should probably be easy to fix, just need to confirm that leftover ghost has same unit_number (if not, internal data should just be reassigned to new one instead of removed in mlc_remove) and do such basic testing afterwards.
Don't have factorio installed atm, but probably will get to it eventually.

New response