Modified part of control.lua, doesn't fix all the issues (smart belt dragging (automatic undergrounds) doesn't work properly if building without power coverage) but does prevent items on belts from being deleted.
---- ON TICK ----
script.on_event(defines.events.on_tick, function(event)
if power_entities ~= nil and entities ~= nil and next(power_entities) and next(entities) then
for _ = 1, settings.global["powered-belts-operations-per-tick"].value do
if next(power_entities) ~= nil and next(entities) ~= nil then
if next(power_entities, k) == nil then k,_ = next(power_entities, nil) else k,_ = next(power_entities, k) end
if entities[k] ~= nil and entities[k].valid then
if string.match(entities[k].name, "unpowered-") and power_entities[k].energy > 0 then
local entity_data = {surface = entities[k].surface, name = entities[k].name, position = entities[k].position, force = entities[k].force, direction = entities[k].direction}
if entities[k].type == "underground-belt" then entity_data.belt_to_ground_type = entities[k].belt_to_ground_type end
if entities[k].valid then
entities[k] = entity_data.surface.create_entity{
name = string.sub(entity_data.name, 11),
position = entity_data.position,
force = entity_data.force,
direction = entity_data.direction,
type = entity_data.belt_to_ground_type,
fast_replace = true,
spill = false
}
end
elseif (not string.match(entities[k].name, "unpowered-")) and power_entities[k].energy <= 0 then
local entity_data = {surface = entities[k].surface, name = entities[k].name, position = entities[k].position, force = entities[k].force, direction = entities[k].direction}
if entities[k].type == "underground-belt" then entity_data.belt_to_ground_type = entities[k].belt_to_ground_type end
if entities[k].valid then
entities[k] = entity_data.surface.create_entity{
name = "unpowered-" .. entity_data.name,
position = entity_data.position,
force = entity_data.force,
direction = entity_data.direction,
type = entity_data.belt_to_ground_type,
fast_replace = true,
spill = false
}
end
end
end
end
end
end
end)