diff --git a/basic_machines/distributor.lua b/basic_machines/distributor.lua index 339dd0a..b5ac378 100644 --- a/basic_machines/distributor.lua +++ b/basic_machines/distributor.lua @@ -357,7 +357,7 @@ local function on_receive_fields(pos, formname, fields, player) end local meta = M(pos) local crd = CRD(pos) - local filter = minetest.deserialize(meta:get_string("filter")) + local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false} if fields.filter1 ~= nil then filter[1] = fields.filter1 == "true" elseif fields.filter2 ~= nil then @@ -385,7 +385,7 @@ end local function change_filter_settings(pos, slot, val) local slots = {["red"] = 1, ["green"] = 2, ["blue"] = 3, ["yellow"] = 4} local meta = M(pos) - local filter = minetest.deserialize(meta:get_string("filter")) + local filter = minetest.deserialize(meta:get_string("filter")) or {false,false,false,false} local num = slots[slot] or 1 if num >= 1 and num <= 4 then filter[num] = val == "on" @@ -402,7 +402,7 @@ end -- techage command to read filter channel status (on/off) local function read_filter_settings(pos, slot) local slots = {["red"] = 1, ["green"] = 2, ["blue"] = 3, ["yellow"] = 4} - local filter = minetest.deserialize(M(pos):get_string("filter")) + local filter = minetest.deserialize(M(pos):get_string("filter")) or {false,false,false,false} return filter[slots[slot]] and "on" or "off" end diff --git a/basic_machines/legacy_nodes.lua b/basic_machines/foreign_nodes.lua similarity index 100% rename from basic_machines/legacy_nodes.lua rename to basic_machines/foreign_nodes.lua diff --git a/basis/legacy.lua b/basis/legacy.lua new file mode 100644 index 0000000..1578262 --- /dev/null +++ b/basis/legacy.lua @@ -0,0 +1,25 @@ +--[[ + + TechAge + ======= + + Copyright (C) 2019-2021 Joachim Stolberg + + AGPL v3 + See LICENSE.txt for more information + + For the transition from v0.26 to v1.0 + +]]-- + +function techage.register_node_for_v1_transition(nodenames, on_node_load) + minetest.register_lbm({ + label = "[TechAge] V1 transition", + name = nodenames[1].."transition", + nodenames = nodenames, + run_at_every_load = false, + action = function(pos, node) + on_node_load(pos, node) + end + }) +end diff --git a/init.lua b/init.lua index 34257bc..f9d85d9 100644 --- a/init.lua +++ b/init.lua @@ -89,6 +89,7 @@ dofile(MP.."/basis/recipe_lib.lua") dofile(MP.."/basis/formspec_update.lua") dofile(MP.."/basis/windturbine_lib.lua") dofile(MP.."/basis/laser_lib.lua") +dofile(MP.."/basis/legacy.lua") -- Main doc dofile(MP.."/doc/manual_DE.lua") @@ -154,7 +155,7 @@ dofile(MP.."/liquids/pipe_wall_entry.lua") dofile(MP.."/basic_machines/consumer.lua") -- consumer base model dofile(MP.."/basic_machines/source.lua") dofile(MP.."/basic_machines/pusher.lua") -dofile(MP.."/basic_machines/legacy_nodes.lua") +dofile(MP.."/basic_machines/foreign_nodes.lua") dofile(MP.."/basic_machines/mods_support.lua") dofile(MP.."/basic_machines/grinder.lua") dofile(MP.."/basic_machines/distributor.lua") diff --git a/lamps/lib.lua b/lamps/lib.lua index 440c728..2d30149 100644 --- a/lamps/lib.lua +++ b/lamps/lib.lua @@ -177,5 +177,8 @@ function techage.register_lamp(basename, ndef_off, ndef_on) minetest.register_node(basename.."_on", ndef_on) power.register_nodes({basename.."_off", basename.."_on"}, Cable, "con") + techage.register_node_for_v1_transition({basename.."_off", basename.."_on"}, function(pos, node) + power.update_network(pos, nil, Cable) + end) end diff --git a/solar/inverter.lua b/solar/inverter.lua index b6e7a86..8d91155 100644 --- a/solar/inverter.lua +++ b/solar/inverter.lua @@ -248,3 +248,7 @@ minetest.register_craft({ {'default:steel_ingot', "techage:baborium_ingot", 'default:steel_ingot'}, }, }) + +techage.register_node_for_v1_transition({"techage:ta4_solar_inverter"}, function(pos, node) + power.update_network(pos, nil, Solar) +end)