forked from minetest-mods/mesecons
Always use minetest.set_node instead of minetest.add_node for consistency
This commit is contained in:
parent
809192f353
commit
7865d42834
@ -2,7 +2,7 @@ function mesecon.move_node(pos, newpos)
|
||||
local node = minetest.get_node(pos)
|
||||
local meta = minetest.get_meta(pos):to_table()
|
||||
minetest.remove_node(pos)
|
||||
minetest.add_node(newpos, node)
|
||||
minetest.set_node(newpos, node)
|
||||
minetest.get_meta(pos):from_table(meta)
|
||||
end
|
||||
|
||||
|
@ -53,13 +53,13 @@ local vertical_updatepos = function (pos)
|
||||
|
||||
local basename = "mesecons_extrawires:vertical_"
|
||||
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
|
||||
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
|
||||
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
|
||||
minetest.add_node(pos, {name = basename .. "bottom_" .. namestate})
|
||||
minetest.set_node(pos, {name = basename .. "bottom_" .. namestate})
|
||||
end
|
||||
mesecon.update_autoconnect(pos)
|
||||
end
|
||||
|
@ -60,7 +60,7 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_off"},
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
|
||||
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)
|
||||
mesecon.receptor_on(pos)
|
||||
end
|
||||
@ -74,7 +74,7 @@ nodenames = {"mesecons_hydroturbine:hydro_turbine_on"},
|
||||
action = function(pos, node, active_object_count, active_object_count_wider)
|
||||
local waterpos={x=pos.x, y=pos.y+1, z=pos.z}
|
||||
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)
|
||||
mesecon.receptor_off(pos)
|
||||
end
|
||||
|
@ -177,7 +177,7 @@ function mesecon.mvps_push_or_pull(pos, stackdir, movedir, maximum, all_pull_sti
|
||||
for _, n in ipairs(nodes) do
|
||||
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)
|
||||
end
|
||||
|
||||
|
@ -5,7 +5,7 @@ minetest.register_node("mesecons_noteblock:noteblock", {
|
||||
on_punch = function(pos, node) -- change sound when punched
|
||||
node.param2 = (node.param2+1)%12
|
||||
mesecon.noteblock_play(pos, node.param2)
|
||||
minetest.add_node(pos, node)
|
||||
minetest.set_node(pos, node)
|
||||
end,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
mesecons = {effector = { -- play sound when activated
|
||||
|
@ -82,8 +82,8 @@ local piston_on = function(pos, node)
|
||||
local maxpush = mesecon.setting("piston_max_push", 15)
|
||||
local success, stack, oldstack = mesecon.mvps_push(np, dir, maxpush)
|
||||
if success then
|
||||
minetest.add_node(pos, {param2 = node.param2, name = pistonspec.onname})
|
||||
minetest.add_node(np, {param2 = node.param2, name = pistonspec.pusher})
|
||||
minetest.set_node(pos, {param2 = node.param2, name = pistonspec.onname})
|
||||
minetest.set_node(np, {param2 = node.param2, name = pistonspec.pusher})
|
||||
minetest.sound_play("piston_extend", {
|
||||
pos = pos,
|
||||
max_hear_distance = 20,
|
||||
@ -96,7 +96,7 @@ end
|
||||
|
||||
local piston_off = function(pos, node)
|
||||
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)
|
||||
|
||||
if pistonspec.sticky then
|
||||
@ -118,9 +118,9 @@ local piston_orientate = function(pos, placer)
|
||||
local node = minetest.get_node(pos)
|
||||
local pistonspec = minetest.registered_nodes[node.name].mesecons_piston
|
||||
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
|
||||
minetest.add_node(pos, {name=pistonspec.piston_up})
|
||||
minetest.set_node(pos, {name=pistonspec.piston_up})
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -20,13 +20,13 @@ pp_on_timer = function (pos, elapsed)
|
||||
local two_below = vector.add(pos, vector.new(0, -2, 0))
|
||||
|
||||
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)
|
||||
elseif node.name == basename .. "_off" then
|
||||
for k, obj in pairs(objs) do
|
||||
local objpos = obj:getpos()
|
||||
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 )
|
||||
end
|
||||
end
|
||||
|
@ -105,10 +105,10 @@ function mesecon.receiver_place(rcpt_pos)
|
||||
if string.find(nn.name, "mesecons:wire_") ~= nil then
|
||||
minetest.dig_node(pos)
|
||||
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))
|
||||
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
|
||||
mesecon.update_autoconnect(pos)
|
||||
end
|
||||
@ -120,7 +120,7 @@ function mesecon.receiver_remove(rcpt_pos, dugnode)
|
||||
if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then
|
||||
minetest.dig_node(pos)
|
||||
local node = {name = "mesecons:wire_00000000_off"}
|
||||
minetest.add_node(pos, node)
|
||||
minetest.set_node(pos, node)
|
||||
mesecon.update_autoconnect(pos)
|
||||
mesecon.on_placenode(pos, node)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user