Skip to content

Commit cadaa4b

Browse files
committed
update old indicators when config changes
1 parent 155fee5 commit cadaa4b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Diff for: control.lua

+24
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,38 @@ local function checkForDataMigration(old_data_version, new_data_version)
475475
end
476476
end
477477

478+
local function updateIndicators(old_draw_terminal_indicator, new_draw_terminal_indicator)
479+
if global.terminal_belts then
480+
if old_draw_terminal_indicator ~= new_draw_terminal_indicator then
481+
if new_draw_terminal_indicator then
482+
-- add indicators to existing termbelts
483+
for y,row in pairs(global.terminal_belts) do
484+
for x,belt in pairs(row) do
485+
belt.indicator = create_indicator(belt.entity)
486+
end
487+
end
488+
else
489+
-- remove existing indicators
490+
for y,row in pairs(global.terminal_belts) do
491+
for x,belt in pairs(row) do
492+
belt.indicator = nil
493+
end
494+
end
495+
end
496+
end
497+
end
498+
end
499+
478500
local function onLoad()
479501
-- The only reason to have version/data_version is to trigger migrations, so do that here.
480502
checkForMigration(global.version, mod_version)
481503
checkForDataMigration(global.data_version, mod_data_version)
504+
updateIndicators(global.draw_terminal_indicator, draw_terminal_indicator)
482505

483506
-- After these lines, we can no longer check for migration.
484507
global.version=mod_version
485508
global.data_version=mod_data_version
509+
global.draw_terminal_indicator=draw_terminal_indicator
486510

487511
if global.terminal_belts==nil then
488512
refreshData()

0 commit comments

Comments
 (0)