Skip to content

Commit

Permalink
Add migration script to clear out legacy sign data - Ref: jpanther#71
Browse files Browse the repository at this point in the history
  • Loading branch information
jpanther committed May 30, 2018
1 parent 030aa47 commit 31d3f86
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,6 @@ DECT.INCOMPATIBLE.MODS = {
},
}

DECT.DEBUG = false

return DECT
25 changes: 25 additions & 0 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,31 @@ local function on_load(data)
notification({"dect-notify.cmd-no-orphaned-signs", {"dect-notify.dectorio"}})
end
end)

if DECT.DEBUG then
-- Special debug command to remove all signs and reset global sign data
commands.add_command("dect-debug-reset-signs", "Destroy all signs and reset sign data", function()
-- Find and remove all signs on all surfaces
for _, surface in pairs(game.surfaces) do
local signs = surface.find_entities_filtered{name={"dect-sign-wood", "dect-sign-steel"}}
for _, sign in pairs(signs) do
sign.destroy()
end
end
-- Find and remove any sign icons
for _, sign in pairs(global.signs) do
for _, object in pairs(sign.objects) do
object.destroy()
end
end
-- Clear out any global sign data
global.signs = {}
for _, player in pairs(game.players) do
global.sign_last_built[player.index] = nil
global.sign_gui[player.index] = nil
end
end)
end
end

-- Fire events!
Expand Down
11 changes: 11 additions & 0 deletions migrations/0.8.9.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
for _, surface in pairs(game.surfaces) do
local signs = surface.find_entities_filtered{name={"dect-sign-wood", "dect-sign-steel"}}
for _, sign in pairs(signs) do
if sign.minable == false then
sign.destroy()
end
end
end

global.sign_last_built = {}
global.sign_gui = {}

0 comments on commit 31d3f86

Please sign in to comment.