(running current version, 0.3.1)
this already happened twice now, even though i haven't even researched armor plating yet.
it sometimes happens when i manually rebuild a destroyed gun turret (vanilla turret), meaning there was a ghost (vanilla turret) entity.
Error while running event vtk-armor-plating::on_built_entity (ID 6)
LuaEntity AP call when Lua Entity was ivalid.
stack traceback:
[]vtk-armor-plating/control.lua:72: in functon 'update_armor_equipment'
[]vtk-armor-plating/control.lua:152: in function <vtk-armor-plating/control.lua:150>
i think you should add "entity_to_armor = nil" in the first line of the function set_entity_to_armor.
gonna try it and reporting back in 1-2 days