forked from Mirrorlandia_minetest/mesecons
Use minetest.swap_node() instead of mesecons' version, Minor code changes
here and there to facilitate this.
This commit is contained in:
parent
669e3d0880
commit
f46bc329de
@ -10,7 +10,7 @@ mesecon.on_placenode = function (pos, node)
|
|||||||
mesecon:activate(pos, node)
|
mesecon:activate(pos, node)
|
||||||
end
|
end
|
||||||
elseif mesecon:is_conductor_on(node.name) then
|
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
|
elseif mesecon:is_effector_on (node.name) then
|
||||||
mesecon:deactivate(pos, node)
|
mesecon:deactivate(pos, node)
|
||||||
end
|
end
|
||||||
|
@ -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)
|
function mesecon:move_node(pos, newpos)
|
||||||
local node = minetest.env:get_node(pos)
|
local node = minetest.env:get_node(pos)
|
||||||
local meta = minetest.env:get_meta(pos):to_table()
|
local meta = minetest.env:get_meta(pos):to_table()
|
||||||
|
@ -62,7 +62,7 @@ minetest.register_node("mesecons_blinkyplant:blinky_plant_on", {
|
|||||||
state = mesecon.state.on
|
state = mesecon.state.on
|
||||||
}},
|
}},
|
||||||
on_punch = function(pos, node, puncher)
|
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)
|
mesecon:receptor_off(pos)
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
mesecon.button_turnoff = function (pos)
|
mesecon.button_turnoff = function (pos)
|
||||||
local node = minetest.env:get_node(pos)
|
local node = minetest.env:get_node(pos)
|
||||||
if node.name=="mesecons_button:button_on" then --has not been dug
|
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})
|
minetest.sound_play("mesecons_button_pop", {pos=pos})
|
||||||
local rules = mesecon.rules.buttonlike_get(node)
|
local rules = mesecon.rules.buttonlike_get(node)
|
||||||
mesecon:receptor_off(pos, rules)
|
mesecon:receptor_off(pos, rules)
|
||||||
@ -41,7 +41,7 @@ minetest.register_node("mesecons_button:button_off", {
|
|||||||
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
|
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
|
||||||
description = "Button",
|
description = "Button",
|
||||||
on_punch = function (pos, node)
|
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))
|
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
minetest.sound_play("mesecons_button_push", {pos=pos})
|
minetest.sound_play("mesecons_button_push", {pos=pos})
|
||||||
minetest.after(1, mesecon.button_turnoff, pos)
|
minetest.after(1, mesecon.button_turnoff, pos)
|
||||||
|
@ -144,7 +144,7 @@ local commandblock_action_on = function(pos, node)
|
|||||||
return
|
return
|
||||||
end
|
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 meta = minetest.env:get_meta(pos)
|
||||||
local command = minetest.chatcommands[meta:get_string("command")]
|
local command = minetest.chatcommands[meta:get_string("command")]
|
||||||
@ -166,7 +166,7 @@ end
|
|||||||
|
|
||||||
local commandblock_action_off = function(pos, node)
|
local commandblock_action_off = function(pos, node)
|
||||||
if node.name == "mesecons_commandblock:commandblock_on" then
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,14 +30,14 @@ end
|
|||||||
local delayer_activate = function(pos, node)
|
local delayer_activate = function(pos, node)
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
local time = def.delayer_time
|
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})
|
minetest.after(time, delayer_turnon , {pos = pos, node = node})
|
||||||
end
|
end
|
||||||
|
|
||||||
local delayer_deactivate = function(pos, node)
|
local delayer_deactivate = function(pos, node)
|
||||||
local def = minetest.registered_nodes[node.name]
|
local def = minetest.registered_nodes[node.name]
|
||||||
local time = def.delayer_time
|
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})
|
minetest.after(time, delayer_turnoff, {pos = pos, node = node})
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -99,13 +99,13 @@ minetest.register_node("mesecons_delayer:delayer_off_"..tostring(i), {
|
|||||||
drop = 'mesecons_delayer:delayer_off_1',
|
drop = 'mesecons_delayer:delayer_off_1',
|
||||||
on_punch = function (pos, node)
|
on_punch = function (pos, node)
|
||||||
if node.name=="mesecons_delayer:delayer_off_1" then
|
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
|
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
|
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
|
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
|
||||||
end,
|
end,
|
||||||
delayer_time = delaytime,
|
delayer_time = delaytime,
|
||||||
@ -154,13 +154,13 @@ minetest.register_node("mesecons_delayer:delayer_on_"..tostring(i), {
|
|||||||
drop = 'mesecons_delayer:delayer_off_1',
|
drop = 'mesecons_delayer:delayer_off_1',
|
||||||
on_punch = function (pos, node)
|
on_punch = function (pos, node)
|
||||||
if node.name=="mesecons_delayer:delayer_on_1" then
|
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
|
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
|
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
|
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
|
||||||
end,
|
end,
|
||||||
delayer_time = delaytime,
|
delayer_time = delaytime,
|
||||||
|
@ -88,7 +88,7 @@ minetest.register_abm(
|
|||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
if object_detector_scan(pos) then
|
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)
|
mesecon:receptor_on(pos)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -100,7 +100,7 @@ minetest.register_abm(
|
|||||||
chance = 1,
|
chance = 1,
|
||||||
action = function(pos)
|
action = function(pos)
|
||||||
if not object_detector_scan(pos) then
|
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)
|
mesecon:receptor_off(pos)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -51,14 +51,15 @@ function set_gate(pos, on)
|
|||||||
if yc_overheat(meta) then
|
if yc_overheat(meta) then
|
||||||
pop_gate(pos)
|
pop_gate(pos)
|
||||||
else
|
else
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
if on then
|
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,
|
mesecon:receptor_on(pos,
|
||||||
gate_get_output_rules(minetest.env:get_node(pos)))
|
gate_get_output_rules(node))
|
||||||
else
|
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,
|
mesecon:receptor_off(pos,
|
||||||
gate_get_output_rules(minetest.env:get_node(pos)))
|
gate_get_output_rules(node))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -25,7 +25,7 @@ minetest.register_node("mesecons_lamp:lamp_on", {
|
|||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
mesecons = {effector = {
|
mesecons = {effector = {
|
||||||
action_off = function (pos, node)
|
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
|
end
|
||||||
}}
|
}}
|
||||||
})
|
})
|
||||||
@ -46,7 +46,7 @@ minetest.register_node("mesecons_lamp:lamp_off", {
|
|||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
mesecons = {effector = {
|
mesecons = {effector = {
|
||||||
action_on = function (pos, node)
|
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
|
end
|
||||||
}}
|
}}
|
||||||
})
|
})
|
||||||
|
@ -6,7 +6,7 @@ function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
|
|||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
mesecons = {effector = {
|
mesecons = {effector = {
|
||||||
action_on = function (pos, node)
|
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
|
end
|
||||||
}}
|
}}
|
||||||
})
|
})
|
||||||
@ -18,7 +18,7 @@ function mesecon:lightstone_add(name, base_item, texture_off, texture_on)
|
|||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
mesecons = {effector = {
|
mesecons = {effector = {
|
||||||
action_off = function (pos, node)
|
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
|
end
|
||||||
}}
|
}}
|
||||||
})
|
})
|
||||||
|
@ -72,7 +72,8 @@ local setport = function (pos, rule, state)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local action = function (pos, ports)
|
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 vports = minetest.registered_nodes[name].virtual_portstates
|
||||||
local newname = generate_name(ports)
|
local newname = generate_name(ports)
|
||||||
|
|
||||||
@ -80,7 +81,7 @@ local action = function (pos, ports)
|
|||||||
local rules_on = {}
|
local rules_on = {}
|
||||||
local rules_off = {}
|
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.a ~= vports.a then setport(pos, rules.a, ports.a) end
|
||||||
if ports.b ~= vports.b then setport(pos, rules.b, ports.b) 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)
|
heat(meta)
|
||||||
--minetest.after(0.5, cool, meta)
|
--minetest.after(0.5, cool, meta)
|
||||||
if overheat(meta) then
|
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.env:get_meta(pos):set_string("lc_interrupts", "")
|
||||||
minetest.after(0.2, overheat_off, pos) -- wait for pending operations
|
minetest.after(0.2, overheat_off, pos) -- wait for pending operations
|
||||||
return true
|
return true
|
||||||
|
@ -590,7 +590,8 @@ function yc_action(pos, L) --L-->Lvirtual
|
|||||||
..tonumber(L.c and 1 or 0)
|
..tonumber(L.c and 1 or 0)
|
||||||
..tonumber(L.b and 1 or 0)
|
..tonumber(L.b and 1 or 0)
|
||||||
..tonumber(L.a 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)
|
yc_action_setports(pos, L, Lv)
|
||||||
end
|
end
|
||||||
|
@ -10,7 +10,7 @@ minetest.register_node("mesecons_switch:mesecon_switch_off", {
|
|||||||
state = mesecon.state.off
|
state = mesecon.state.off
|
||||||
}},
|
}},
|
||||||
on_punch = function(pos, node)
|
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)
|
mesecon:receptor_on(pos)
|
||||||
minetest.sound_play("mesecons_switch", {pos=pos})
|
minetest.sound_play("mesecons_switch", {pos=pos})
|
||||||
end
|
end
|
||||||
@ -26,7 +26,7 @@ minetest.register_node("mesecons_switch:mesecon_switch_on", {
|
|||||||
state = mesecon.state.on
|
state = mesecon.state.on
|
||||||
}},
|
}},
|
||||||
on_punch = function(pos, node)
|
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)
|
mesecon:receptor_off(pos)
|
||||||
minetest.sound_play("mesecons_switch", {pos=pos})
|
minetest.sound_play("mesecons_switch", {pos=pos})
|
||||||
end
|
end
|
||||||
|
@ -99,11 +99,11 @@ minetest.register_abm({
|
|||||||
|
|
||||||
if is_powered then
|
if is_powered then
|
||||||
if node.name == "mesecons_torch:mesecon_torch_on" 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))
|
mesecon:receptor_off(pos, torch_get_output_rules(node))
|
||||||
end
|
end
|
||||||
elseif node.name == "mesecons_torch:mesecon_torch_off" then
|
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))
|
mesecon:receptor_on(pos, torch_get_output_rules(node))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -32,7 +32,7 @@ minetest.register_node("mesecons_walllever:wall_lever_off", {
|
|||||||
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
|
groups = {dig_immediate=2, mesecon_needs_receiver = 1},
|
||||||
description="Lever",
|
description="Lever",
|
||||||
on_punch = function (pos, node)
|
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))
|
mesecon:receptor_on(pos, mesecon.rules.buttonlike_get(node))
|
||||||
minetest.sound_play("mesecons_lever", {pos=pos})
|
minetest.sound_play("mesecons_lever", {pos=pos})
|
||||||
end,
|
end,
|
||||||
@ -74,7 +74,7 @@ minetest.register_node("mesecons_walllever:wall_lever_on", {
|
|||||||
drop = "mesecons_walllever:wall_lever_off 1",
|
drop = "mesecons_walllever:wall_lever_off 1",
|
||||||
description="Lever",
|
description="Lever",
|
||||||
on_punch = function (pos, node)
|
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))
|
mesecon:receptor_off(pos, mesecon.rules.buttonlike_get(node))
|
||||||
minetest.sound_play("mesecons_lever", {pos=pos})
|
minetest.sound_play("mesecons_lever", {pos=pos})
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user