summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesecons/services.lua2
-rw-r--r--mesecons/util.lua8
-rw-r--r--mesecons_blinkyplant/init.lua2
-rw-r--r--mesecons_button/init.lua4
-rw-r--r--mesecons_commandblock/init.lua4
-rw-r--r--mesecons_delayer/init.lua20
-rw-r--r--mesecons_detector/init.lua4
-rw-r--r--mesecons_gates/init.lua9
-rw-r--r--mesecons_lamp/init.lua4
-rw-r--r--mesecons_lightstone/init.lua4
-rw-r--r--mesecons_luacontroller/init.lua8
-rw-r--r--mesecons_microcontroller/init.lua3
-rw-r--r--mesecons_switch/init.lua4
-rw-r--r--mesecons_torch/init.lua4
-rw-r--r--mesecons_walllever/init.lua4
15 files changed, 40 insertions, 44 deletions
diff --git a/mesecons/services.lua b/mesecons/services.lua
index a47b5ec..141ac7c 100644
--- a/mesecons/services.lua
+++ b/mesecons/services.lua
@@ -10,7 +10,7 @@ mesecon.on_placenode = function (pos, node)
mesecon:activate(pos, node)
end
elseif mesecon:is_conductor_on(node.name) then
- mesecon:swap_node(pos, mesecon:get_conductor_off(node.name))
+ minetest.swap_node(pos, {name = mesecon:get_conductor_off(node.name)})
elseif mesecon:is_effector_on (node.name) then
mesecon:deactivate(pos, node)
end
diff --git a/mesecons/util.lua b/mesecons/util.lua
index 12d2af1..8413b10 100644
--- a/mesecons/util.lua
+++ b/mesecons/util.lua
@@ -1,11 +1,3 @@
-function mesecon:swap_node(pos, name)
- local node = minetest.env:get_node(pos)
- local data = minetest.env:get_meta(pos):to_table()
- node.name = name
- minetest.env:add_node(pos, node)
- minetest.env:get_meta(pos):from_table(data)
-end
-
function mesecon:move_node(pos, newpos)
local node = minetest.env:get_node(pos)
local meta = minetest.env:get_meta(pos):to_table()
diff --git a/mesecons_blinkyplant/init.lua b/mesecons_blinkyplant/init.lua
index edaa547..a7d8301 100644
--- a/mesecons_blinkyplant/init.lua
+++ b/mesecons_blinkyplant/init.lua
@@ -62,7 +62,7 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
state = mesecon.state.on
}},
on_punch = function(pos, node, puncher)
- mesecon:swap_node(pos, "mesecons_blinkyplant:blinky_plant")
+ minetest.swap_node(pos, {name = "mesecons_blinkyplant:blinky_plant"})
mesecon:receptor_off(pos)
end
})
diff --git a/mesecons_button/init.lua b/mesecons_button/init.lua
index 5480fb0..beca63e 100644
--- a/mesecons_button/init.lua
+++ b/mesecons_button/init.lua
@@ -5,7 +5,7 @@
mesecon.button_turnoff = function (pos)
local node = minetest.env:get_node(pos)
if node.name=="mesecons_button:button_on" then --has not been dug
- mesecon:swap_node(pos, "mesecons_button:button_off")
+ minetest.swap_node(pos, {name = "mesecons_button:button_off", param2=node.param2})
minetest.sound_play("mesecons_button_pop", {pos=pos})
local rules = mesecon.rules.buttonlike_get(node)
mesecon:receptor_off(pos, rules)
@@ -41,7 +41,7 @@ minetest.register_node("mesecons_button:button_off", {
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
description = "Button",
on_punch = function (pos, node)
- mesecon:swap_node(pos, "mesecons_button:button_on")
+ minetest.swap_node(pos, {name = "mesecons_button:button_on", param2=node.param2})
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
minetest.sound_play("mesecons_button_push", {pos=pos})
minetest.after(1, mesecon.button_turnoff, pos)
diff --git a/mesecons_commandblock/init.lua b/mesecons_commandblock/init.lua
index b84e815..69249eb 100644
--- a/mesecons_commandblock/init.lua
+++ b/mesecons_commandblock/init.lua
@@ -144,7 +144,7 @@ local commandblock_action_on = function(pos, node)
return
end
- mesecon:swap_node(pos, "mesecons_commandblock:commandblock_on")
+ minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_on"})
local meta = minetest.env:get_meta(pos)
local command = minetest.chatcommands[meta:get_string("command")]
@@ -166,7 +166,7 @@ end
local commandblock_action_off = function(pos, node)
if node.name == "mesecons_commandblock:commandblock_on" then
- mesecon:swap_node(pos, "mesecons_commandblock:commandblock_off")
+ minetest.swap_node(pos, {name = "mesecons_commandblock:commandblock_off"})
end
end
diff --git a/mesecons_delayer/init.lua b/mesecons_delayer/init.lua
index 24ba293..a03737c 100644
--- a/mesecons_delayer/init.lua
+++ b/mesecons_delayer/init.lua
@@ -30,14 +30,14 @@ end
local delayer_activate = function(pos, node)
local def = minetest.registered_nodes[node.name]
local time = def.delayer_time
- mesecon:swap_node(pos, def.delayer_onstate)
+ minetest.swap_node(pos, {name = def.delayer_onstate, param2=node.param2})
minetest.after(time, delayer_turnon , {pos = pos, node = node})
end
local delayer_deactivate = function(pos, node)
local def = minetest.registered_nodes[node.name]
local time = def.delayer_time
- mesecon:swap_node(pos, def.delayer_offstate)
+ minetest.swap_node(pos, {name = def.delayer_offstate, param2=node.param2})
minetest.after(time, delayer_turnoff, {pos = pos, node = node})
end
@@ -99,13 +99,13 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), {
drop = 'mesecons_delayer:delayer_off_1',
on_punch = function (pos, node)
if node.name=="mesecons_delayer:delayer_off_1" then
- mesecon:swap_node(pos,"mesecons_delayer:delayer_off_2")
+ minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_2", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_off_2" then
- mesecon:swap_node(pos,"mesecons_delayer:delayer_off_3")
+ minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_3", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_off_3" then
- mesecon:swap_node(pos,"mesecons_delayer:delayer_off_4")
+ minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_4", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_off_4" then
- mesecon:swap_node(pos,"mesecons_delayer:delayer_off_1")
+ minetest.swap_node(pos, {name = "mesecons_delayer:delayer_off_1", param2=node.param2})
end
end,
delayer_time = delaytime,
@@ -154,13 +154,13 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
drop = 'mesecons_delayer:delayer_off_1',
on_punch = function (pos, node)
if node.name=="mesecons_delayer:delayer_on_1" then
- mesecon:swap_node(pos,"mesecons_delayer:delayer_on_2")
+ minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_2", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_on_2" then
- mesecon:swap_node(pos,"mesecons_delayer:delayer_on_3")
+ minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_3", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_on_3" then
- mesecon:swap_node(pos,"mesecons_delayer:delayer_on_4")
+ minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_4", param2=node.param2})
elseif node.name=="mesecons_delayer:delayer_on_4" then
- mesecon:swap_node(pos,"mesecons_delayer:delayer_on_1")
+ minetest.swap_node(pos, {name = "mesecons_delayer:delayer_on_1", param2=node.param2})
end
end,
delayer_time = delaytime,
diff --git a/mesecons_detector/init.lua b/mesecons_detector/init.lua
index ece2bc8..2eaa1e0 100644
--- a/mesecons_detector/init.lua
+++ b/mesecons_detector/init.lua
@@ -88,7 +88,7 @@ minetest.register_abm(
chance = 1,
action = function(pos)
if object_detector_scan(pos) then
- mesecon:swap_node(pos, "mesecons_detector:object_detector_on")
+ minetest.swap_node(pos, {name = "mesecons_detector:object_detector_on"})
mesecon:receptor_on(pos)
end
end,
@@ -100,7 +100,7 @@ minetest.register_abm(
chance = 1,
action = function(pos)
if not object_detector_scan(pos) then
- mesecon:swap_node(pos, "mesecons_detector:object_detector_off")
+ minetest.swap_node(pos, {name = "mesecons_detector:object_detector_off"})
mesecon:receptor_off(pos)
end
end,
diff --git a/mesecons_gates/init.lua b/mesecons_gates/init.lua
index 37b046f..de232f1 100644
--- a/mesecons_gates/init.lua
+++ b/mesecons_gates/init.lua
@@ -51,14 +51,15 @@ function set_gate(pos, on)
if yc_overheat(meta) then
pop_gate(pos)
else
+ local node = minetest.get_node(pos)
if on then
- mesecon:swap_node(pos, "mesecons_gates:"..gate.."_on")
+ minetest.swap_node(pos, {name = "mesecons_gates:"..gate.."_on", param2=node.param2})
mesecon:receptor_on(pos,
- gate_get_output_rules(minetest.env:get_node(pos)))
+ gate_get_output_rules(node))
else
- mesecon:swap_node(pos, "mesecons_gates:"..gate.."_off")
+ minetest.swap_node(pos, {name = "mesecons_gates:"..gate.."_off", param2=node.param2})
mesecon:receptor_off(pos,
- gate_get_output_rules(minetest.env:get_node(pos)))
+ gate_get_output_rules(node))
end
end
end
diff --git a/mesecons_lamp/init.lua b/mesecons_lamp/init.lua
index 938fa32..6cdae2d 100644
--- a/mesecons_lamp/init.lua
+++ b/mesecons_lamp/init.lua
@@ -25,7 +25,7 @@ minetest.register_node("mesecons_lamp:lamp_on", {
sounds = default.node_sound_glass_defaults(),
mesecons = {effector = {
action_off = function (pos, node)
- mesecon:swap_node(pos, "mesecons_lamp:lamp_off")
+ minetest.swap_node(pos, {name = "mesecons_lamp:lamp_off", param2 = node.param2})
end
}}
})
@@ -46,7 +46,7 @@ minetest.register_node("mesecons_lamp:lamp_off", {
sounds = default.node_sound_glass_defaults(),
mesecons = {effector = {
action_on = function (pos, node)
- mesecon:swap_node(pos, "mesecons_lamp:lamp_on")
+ minetest.swap_node(pos, {name = "mesecons_lamp:lamp_on", param2 = node.param2})
end
}}
})
diff --git a/mesecons_lightstone/init.lua b/mesecons_lightstone/init.lua
index e208f91..5d47e1b 100644
--- a/mesecons_lightstone/init.lua
+++ b/mesecons_lightstone/init.lua
@@ -6,7 +6,7 @@ function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_on = function (pos, node)
- mesecon:swap_node(pos, "mesecons_lightstone:lightstone_" .. name .. "_on")
+ minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_" .. name .. "_on", param2 = node.param2})
end
}}
})
@@ -18,7 +18,7 @@ function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
sounds = default.node_sound_stone_defaults(),
mesecons = {effector = {
action_off = function (pos, node)
- mesecon:swap_node(pos, "mesecons_lightstone:lightstone_" .. name .. "_off")
+ minetest.swap_node(pos, {name = "mesecons_lightstone:lightstone_" .. name .. "_off", param2 = node.param2})
end
}}
})
diff --git a/mesecons_luacontroller/init.lua b/mesecons_luacontroller/init.lua
index 0884244..2989989 100644
--- a/mesecons_luacontroller/init.lua
+++ b/mesecons_luacontroller/init.lua
@@ -72,7 +72,8 @@ local setport = function (pos, rule, state)
end
local action = function (pos, ports)
- local name = minetest.env:get_node(pos).name
+ local node = minetest.get_node(pos)
+ local name = node.name
local vports = minetest.registered_nodes[name].virtual_portstates
local newname = generate_name(ports)
@@ -80,7 +81,7 @@ local action = function (pos, ports)
local rules_on = {}
local rules_off = {}
- mesecon:swap_node(pos, newname)
+ minetest.swap_node(pos, {name = newname, param2 = node.param2})
if ports.a ~= vports.a then setport(pos, rules.a, ports.a) end
if ports.b ~= vports.b then setport(pos, rules.b, ports.b) end
@@ -285,7 +286,8 @@ local do_overheat = function (pos, meta)
heat(meta)
--minetest.after(0.5, cool, meta)
if overheat(meta) then
- mesecon:swap_node(pos, BASENAME.."_burnt")
+ local node = minetest.get_node(pos)
+ minetest.swap_node(pos, {name = BASENAME.."_burnt", param2 = node.param2})
minetest.env:get_meta(pos):set_string("lc_interrupts", "")
minetest.after(0.2, overheat_off, pos) -- wait for pending operations
return true
diff --git a/mesecons_microcontroller/init.lua b/mesecons_microcontroller/init.lua
index f49d9dc..bd71d32 100644
--- a/mesecons_microcontroller/init.lua
+++ b/mesecons_microcontroller/init.lua
@@ -590,7 +590,8 @@ function yc_action(pos, L) --L-->Lvirtual
..tonumber(L.c and 1 or 0)
..tonumber(L.b and 1 or 0)
..tonumber(L.a and 1 or 0)
- mesecon:swap_node(pos, name)
+ local node = minetest.get_node(pos)
+ minetest.swap_node(pos, {name = name, param2 = node.param2})
yc_action_setports(pos, L, Lv)
end
diff --git a/mesecons_switch/init.lua b/mesecons_switch/init.lua
index ec04f0a..1b7f478 100644
--- a/mesecons_switch/init.lua
+++ b/mesecons_switch/init.lua
@@ -10,7 +10,7 @@ minetest.register_node("mesecons_switch:mesecon_switch_off", {
state = mesecon.state.off
}},
on_punch = function(pos, node)
- mesecon:swap_node(pos, "mesecons_switch:mesecon_switch_on")
+ minetest.swap_node(pos, {name = "mesecons_switch:mesecon_switch_on", param2 = node.param2})
mesecon:receptor_on(pos)
minetest.sound_play("mesecons_switch", {pos=pos})
end
@@ -26,7 +26,7 @@ minetest.register_node("mesecons_switch:mesecon_switch_on", {
state = mesecon.state.on
}},
on_punch = function(pos, node)
- mesecon:swap_node(pos, "mesecons_switch:mesecon_switch_off")
+ minetest.swap_node(pos, {name = "mesecons_switch:mesecon_switch_off", param2 = node.param2})
mesecon:receptor_off(pos)
minetest.sound_play("mesecons_switch", {pos=pos})
end
diff --git a/mesecons_torch/init.lua b/mesecons_torch/init.lua
index 77777db..97a2991 100644
--- a/mesecons_torch/init.lua
+++ b/mesecons_torch/init.lua
@@ -99,11 +99,11 @@ minetest.register_abm({
if is_powered then
if node.name == "mesecons_torch:mesecon_torch_on" then
- mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_off")
+ minetest.swap_node(pos, {name = "mesecons_torch:mesecon_torch_off", param2 = node.param2})
mesecon:receptor_off(pos, torch_get_output_rules(node))
end
elseif node.name == "mesecons_torch:mesecon_torch_off" then
- mesecon:swap_node(pos, "mesecons_torch:mesecon_torch_on")
+ minetest.swap_node(pos, {name = "mesecons_torch:mesecon_torch_on", param2 = node.param2})
mesecon:receptor_on(pos, torch_get_output_rules(node))
end
end
diff --git a/mesecons_walllever/init.lua b/mesecons_walllever/init.lua
index 63fc1c4..a35d9f1 100644
--- a/mesecons_walllever/init.lua
+++ b/mesecons_walllever/init.lua
@@ -32,7 +32,7 @@ minetest.register_node("mesecons_walllever:wall_lever_off", {
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
description="Lever",
on_punch = function (pos, node)
- mesecon:swap_node(pos, "mesecons_walllever:wall_lever_on")
+ minetest.swap_node(pos, {name = "mesecons_walllever:wall_lever_on", param2 = node.param2})
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
minetest.sound_play("mesecons_lever", {pos=pos})
end,
@@ -74,7 +74,7 @@ minetest.register_node("mesecons_walllever:wall_lever_on", {
drop = "mesecons_walllever:wall_lever_off 1",
description="Lever",
on_punch = function (pos, node)
- mesecon:swap_node(pos, "mesecons_walllever:wall_lever_off")
+ minetest.swap_node(pos, {name = "mesecons_walllever:wall_lever_off", param2 = node.param2})
mesecon:receptor_off(pos, mesecon.rules.buttonlike_get(node))
minetest.sound_play("mesecons_lever", {pos=pos})
end,