Skip to content

Commit

Permalink
0.3.1, for real now: added migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
dustine committed Jun 20, 2017
1 parent 6572c21 commit 3ea6912
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,27 @@ end)
script.on_load(function ()
-- nodes = global.nodes
init_global(true)

local metanodes = {}
function metanodes.__len(_) return counters.nodes end

setmetatable(nodes, metanodes)
if nodes then
local metanodes = {}
function metanodes.__len(_) return counters.nodes end
setmetatable(nodes, metanodes)
end
end)

script.on_configuration_changed(function ()
script.on_configuration_changed(function(event)
set_chargeable_bots()
log(serpent.block(event.mod_changes))
if event.mod_changes["ChargeTransmission"] then
local ct = event.mod_changes["ChargeTransmission"]
if ct.old_version and ct.old_version:match("^0%.1") then
global.ChargeTransmission = nil
init_global() -- Reset internal savedata

local metanodes = {}
function metanodes.__len(_) return counters.nodes end
setmetatable(nodes, metanodes) -- add missing metatable
end
end
end)


Expand Down

0 comments on commit 3ea6912

Please sign in to comment.