z_mirror/Tapeline

git clone https://git.raiguard.me/z_mirror/Tapeline

Caleb HeuerAdd migration for #43971a28c

revert-47-freeze-fix
1.1 KiB44 linesraw
1local flib_migration = require("__flib__.migration")
2
3local settings = require("scripts.settings")
4local tape = require("scripts.tape")
5local tool = require("scripts.tool")
6
7local versions = {
8  ["3.0.0"] = function()
9    rendering.clear(script.mod_name)
10    for _, surface in pairs(game.surfaces) do
11      for _, box in pairs(surface.find_entities_filtered({ name = "tl-highlight-box" })) do
12        box.destroy()
13      end
14    end
15    storage = {}
16    settings.on_init()
17    tape.on_init()
18    tool.on_init()
19  end,
20  ["3.0.3"] = function()
21    --- @param tbl table<uint, Tape>
22    local function migrate_tapes(tbl)
23      for key, tape_data in pairs(tbl) do
24        if tape_data.player.valid then
25          tape_data.player_index = tape_data.player.index
26        else
27          tbl[key] = nil
28        end
29      end
30    end
31    migrate_tapes(storage.drawing)
32    migrate_tapes(storage.editing)
33    migrate_tapes(storage.tapes)
34  end,
35}
36
37local migrations = {}
38
39--- @param e ConfigurationChangedData
40function migrations.on_configuration_changed(e)
41  flib_migration.on_config_changed(e, versions)
42end
43
44return migrations