Always use minetest.set_node instead of minetest.add_node for consistency

This commit is contained in:
Jeija 2016-02-14 21:00:37 +01:00
parent 809192f353
commit 7865d42834
8 changed files with 19 additions and 19 deletions

View File

@ -2,7 +2,7 @@ function mesecon.move_node(pos, newpos)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local meta = minetest.get_meta(pos):to_table() local meta = minetest.get_meta(pos):to_table()
minetest.remove_node(pos) minetest.remove_node(pos)
minetest.add_node(newpos, node) minetest.set_node(newpos, node)
minetest.get_meta(pos):from_table(meta) minetest.get_meta(pos):from_table(meta)
end end

View File

@ -53,13 +53,13 @@ local vertical_updatepos = function (pos)
local basename = "mesecons_extrawires:vertical_" local basename = "mesecons_extrawires:vertical_"
if above and below then -- above and below: vertical mesecon if above and below then -- above and below: vertical mesecon
minetest.add_node(pos, {name = basename .. namestate}) minetest.set_node(pos, {name = basename .. namestate})
elseif above and not below then -- above only: bottom elseif above and not below then -- above only: bottom
minetest.add_node(pos, {name = basename .. "bottom_" .. namestate}) minetest.set_node(pos, {name = basename .. "bottom_" .. namestate})
elseif not above and below then -- below only: top elseif not above and below then -- below only: top
minetest.add_node(pos, {name = basename .. "top_" .. namestate}) minetest.set_node(pos, {name = basename .. "top_" .. namestate})
else -- no vertical wire above, no vertical wire below: use bottom else -- no vertical wire above, no vertical wire below: use bottom
minetest.add_node(pos, {name = basename .. "bottom_" .. namestate}) minetest.set_node(pos, {name = basename .. "bottom_" .. namestate})
end end
mesecon.update_autoconnect(pos) mesecon.update_autoconnect(pos)
end end

View File

@ -60,7 +60,7 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_off"},
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local waterpos={x=pos.x, y=pos.y+1, z=pos.z} local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
if minetest.get_node(waterpos).name=="default:water_flowing" then if minetest.get_node(waterpos).name=="default:water_flowing" then
minetest.add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"}) minetest.set_node(pos, {name="mesecons_hydroturbine:hydro_turbine_on"})
nodeupdate(pos) nodeupdate(pos)
mesecon.receptor_on(pos) mesecon.receptor_on(pos)
end end
@ -74,7 +74,7 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
action = function(pos, node, active_object_count, active_object_count_wider) action = function(pos, node, active_object_count, active_object_count_wider)
local waterpos={x=pos.x, y=pos.y+1, z=pos.z} local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
if minetest.get_node(waterpos).name~="default:water_flowing" then if minetest.get_node(waterpos).name~="default:water_flowing" then
minetest.add_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"}) minetest.set_node(pos, {name="mesecons_hydroturbine:hydro_turbine_off"})
nodeupdate(pos) nodeupdate(pos)
mesecon.receptor_off(pos) mesecon.receptor_off(pos)
end end

View File

@ -177,7 +177,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
for _, n in ipairs(nodes) do for _, n in ipairs(nodes) do
local np = vector.add(n.pos, movedir) local np = vector.add(n.pos, movedir)
minetest.add_node(np, n.node) minetest.set_node(np, n.node)
minetest.get_meta(np):from_table(n.meta) minetest.get_meta(np):from_table(n.meta)
end end

View File

@ -5,7 +5,7 @@ minetest.register_node("mesecons_noteblock:noteblock", {
on_punch = function(pos, node) -- change sound when punched on_punch = function(pos, node) -- change sound when punched
node.param2 = (node.param2+1)%12 node.param2 = (node.param2+1)%12
mesecon.noteblock_play(pos, node.param2) mesecon.noteblock_play(pos, node.param2)
minetest.add_node(pos, node) minetest.set_node(pos, node)
end, end,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
mesecons = {effector = { -- play sound when activated mesecons = {effector = { -- play sound when activated

View File

@ -82,8 +82,8 @@ local piston_on = function(pos, node)
local maxpush = mesecon.setting("piston_max_push", 15) local maxpush = mesecon.setting("piston_max_push", 15)
local success, stack, oldstack = mesecon.mvps_push(np, dir, maxpush) local success, stack, oldstack = mesecon.mvps_push(np, dir, maxpush)
if success then if success then
minetest.add_node(pos, {param2 = node.param2, name = pistonspec.onname}) minetest.set_node(pos, {param2 = node.param2, name = pistonspec.onname})
minetest.add_node(np, {param2 = node.param2, name = pistonspec.pusher}) minetest.set_node(np, {param2 = node.param2, name = pistonspec.pusher})
minetest.sound_play("piston_extend", { minetest.sound_play("piston_extend", {
pos = pos, pos = pos,
max_hear_distance = 20, max_hear_distance = 20,
@ -96,7 +96,7 @@ end
local piston_off = function(pos, node) local piston_off = function(pos, node)
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
minetest.add_node(pos, {param2 = node.param2, name = pistonspec.offname}) minetest.set_node(pos, {param2 = node.param2, name = pistonspec.offname})
piston_remove_pusher(pos, node) piston_remove_pusher(pos, node)
if pistonspec.sticky then if pistonspec.sticky then
@ -118,9 +118,9 @@ local piston_orientate = function(pos, placer)
local node = minetest.get_node(pos) local node = minetest.get_node(pos)
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
if pitch > 55 then --looking upwards if pitch > 55 then --looking upwards
minetest.add_node(pos, {name=pistonspec.piston_down}) minetest.set_node(pos, {name=pistonspec.piston_down})
elseif pitch < -55 then --looking downwards elseif pitch < -55 then --looking downwards
minetest.add_node(pos, {name=pistonspec.piston_up}) minetest.set_node(pos, {name=pistonspec.piston_up})
end end
end end

View File

@ -20,13 +20,13 @@ pp_on_timer = function (pos, elapsed)
local two_below = vector.add(pos, vector.new(0, -2, 0)) local two_below = vector.add(pos, vector.new(0, -2, 0))
if objs[1] == nil and node.name == basename .. "_on" then if objs[1] == nil and node.name == basename .. "_on" then
minetest.add_node(pos, {name = basename .. "_off"}) minetest.set_node(pos, {name = basename .. "_off"})
mesecon.receptor_off(pos, mesecon.rules.pplate) mesecon.receptor_off(pos, mesecon.rules.pplate)
elseif node.name == basename .. "_off" then elseif node.name == basename .. "_off" then
for k, obj in pairs(objs) do for k, obj in pairs(objs) do
local objpos = obj:getpos() local objpos = obj:getpos()
if objpos.y > pos.y-1 and objpos.y < pos.y then if objpos.y > pos.y-1 and objpos.y < pos.y then
minetest.add_node(pos, {name = basename .. "_on"}) minetest.set_node(pos, {name = basename .. "_on"})
mesecon.receptor_on(pos, mesecon.rules.pplate ) mesecon.receptor_on(pos, mesecon.rules.pplate )
end end
end end

View File

@ -105,10 +105,10 @@ function mesecon.receiver_place(rcpt_pos)
if string.find(nn.name, "mesecons:wire_") ~= nil then if string.find(nn.name, "mesecons:wire_") ~= nil then
minetest.dig_node(pos) minetest.dig_node(pos)
if mesecon.is_power_on(rcpt_pos) then if mesecon.is_power_on(rcpt_pos) then
minetest.add_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2}) minetest.set_node(pos, {name = "mesecons_receiver:receiver_on", param2 = node.param2})
mesecon.receptor_on(pos, receiver_get_rules(node)) mesecon.receptor_on(pos, receiver_get_rules(node))
else else
minetest.add_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2}) minetest.set_node(pos, {name = "mesecons_receiver:receiver_off", param2 = node.param2})
end end
mesecon.update_autoconnect(pos) mesecon.update_autoconnect(pos)
end end
@ -120,7 +120,7 @@ function mesecon.receiver_remove(rcpt_pos, dugnode)
if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then
minetest.dig_node(pos) minetest.dig_node(pos)
local node = {name = "mesecons:wire_00000000_off"} local node = {name = "mesecons:wire_00000000_off"}
minetest.add_node(pos, node) minetest.set_node(pos, node)
mesecon.update_autoconnect(pos) mesecon.update_autoconnect(pos)
mesecon.on_placenode(pos, node) mesecon.on_placenode(pos, node)
end end