Hi again. I have taken an interest in this problem of hard-coded quality, and by taking inspiration from various mods (like Quality Wagons), I have come upon the idea of a script which replaces any higher quality entities of a particular name with a normal variant right when it gets built. Here is an example of what it could look like (in control.lua):
function table_contains_value(table, element)
for key, value in pairs(table) do
if value == element then return true end
end
return false
end
local poles = {"small-electric-pole", "medium-electric-pole", "big-electric-pole"}
local function on_built(event)
local entity = event.entity or event.destination
local surface = entity.surface
if entity.quality.level == 0 then return end
if not table_contains_value(poles, entity.name) then return end
local info = {
name = entity.name,
position = entity.position,
-- quality simply ignored
force = entity.force,
fast_replace = true,
player = entity.last_user,
}
entity.destroy()
surface.create_entity(info)
end
script.on_event({
defines.events.on_built_entity,
defines.events.on_robot_built_entity,
defines.events.on_space_platform_built_entity,
defines.events.script_raised_built,
defines.events.script_raised_revive,
defines.events.on_entity_cloned -- uses event.destination
}, on_built
)
This way, quality won't have to be entirely disabled for the sake of this mod. Performance also seems to be no issue. Hope you find it useful!