Concept Code:
Code: Select all
ReplaceEntities = function()
modSettingValue = OBTAINED
newLampEntityName = "bob" .. modSettingValue
find and remove all entities at specific locations not called "bob-2" of type "lamp"
if "bob-2" lamp entity not found at location add it
end
script.on_init -> ReplaceEntities
script.on_configuration_changed -> ReplaceEntities
What does happen is that I end up with 2 new entities added of type "bob"...modSettingValue. It feels like the game state isn't quite syncing between the 2 events occuring at map load, but I suspect I have got a coding approach error somewhere?
Full code attached. I end up with 2 "hiddenlight-" entities for both my existing turret and power pole entities on loading a map that didn't have the mod before. Any newly placed turrets or power poles only get 1 "hiddenlight" added.

