Use minetest.env:place_node and minetest.env:dig_node to enable usage of the on_place and on_dig callbacks.

This commit is contained in:
Anthony Zhang 2012-06-21 20:32:48 -04:00
parent 87442f0c31
commit 1e569782f5
2 changed files with 14 additions and 14 deletions

View File

@ -64,7 +64,7 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
local direction=mesecon:get_movestone_direction(pos)
if not direction then
minetest.env:add_node(pos, {name="mesecons_movestones:movestone"})
minetest.env:place_node(pos, {name="mesecons_movestones:movestone"})
self.object:remove()
return
end
@ -75,13 +75,13 @@ minetest.register_entity("mesecons_movestones:movestone_entity", {
if lnode.name ~= "ignore" and lnode.name ~= "air" and lnode.name ~= "default:water" and lnode.name ~= "default:water_flowing" then
local newnode
repeat
minetest.env:remove_node(pos)
minetest.env:dig_node(pos)
pos.x=pos.x+direction.x
pos.y=pos.y+direction.y
pos.z=pos.z+direction.z
newnode = {name=lnode.name}
lnode = minetest.env:get_node(pos)
minetest.env:add_node(pos, newnode)
minetest.env:place_node(pos, newnode)
nodeupdate(pos)
until lnode.name == "ignore" or lnode.name == "air" or lnode.name == "default:water" or lnode.name == "default:water_flowing"
end
@ -113,7 +113,7 @@ mesecon:register_on_signal_on(function (pos, node)
or checknode.name=="ignore"
or checknode.name=="default:water"
or checknode.name=="default:water_flowing"
minetest.env:remove_node(pos)
minetest.env:dig_node(pos)
nodeupdate(pos)
minetest.env:add_entity(pos, "mesecons_movestones:movestone_entity")
end
@ -160,7 +160,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
if not direction then
--or (minetest.env:get_node_or_nil(pos).name ~="air"
--and minetest.env:get_node_or_nil(pos).name ~= nil) then
minetest.env:add_node(pos, {name="mesecons_movestones:sticky_movestone"})
minetest.env:place_node(pos, {name="mesecons_movestones:sticky_movestone"})
self.object:remove()
return
end
@ -176,13 +176,13 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
if lnode.name ~= "ignore" and lnode.name ~= "air" and lnode.name ~= "default:water" and lnode.name ~= "default:water_flowing" then
local newnode
repeat
minetest.env:remove_node(lpos)
minetest.env:dig_node(lpos)
lpos.x=lpos.x+direction.x
lpos.y=lpos.y+direction.y
lpos.z=lpos.z+direction.z
newnode = {name=lnode.name}
lnode = minetest.env:get_node(lpos)
minetest.env:add_node(lpos, newnode)
minetest.env:place_node(lpos, newnode)
nodeupdate(lpos)
until lnode.name == "ignore" or lnode.name == "air" or lnode.name == "default:water" or lnode.name == "default:water_flowing"
end
@ -198,7 +198,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z}
repeat
minetest.env:add_node(oldpos, {name=minetest.env:get_node(lpos2).name})
minetest.env:place_node(oldpos, {name=minetest.env:get_node(lpos2).name})
nodeupdate(oldpos)
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z}
lpos2.x = lpos2.x-direction.x
@ -206,7 +206,7 @@ minetest.register_entity("mesecons_movestones:sticky_movestone_entity", {
lpos2.z = lpos2.z-direction.z
lnode = minetest.env:get_node(lpos2)
until lnode.name=="air" or lnode.name=="ignore" or lnode.name=="default:water" or lnode.name=="default:water_flowing"
minetest.env:remove_node(oldpos)
minetest.env:dig_node(oldpos)
end
})
@ -237,7 +237,7 @@ mesecon:register_on_signal_on(function (pos, node)
or checknode.name=="default:water"
or checknode.name=="default:water_flowing"
minetest.env:remove_node(pos)
minetest.env:dig_node(pos)
nodeupdate(pos)
minetest.env:add_entity(pos, "mesecons_movestones:sticky_movestone_entity")
end

View File

@ -195,13 +195,13 @@ mesecon:register_on_signal_on(function (pos, node)
local thisp= {x=np.x, y=np.y, z=np.z}
local thisnode=minetest.env:get_node(thisp)
local nextnode={}
minetest.env:remove_node(thisp)
minetest.env:dig_node(thisp)
repeat
thisp.x=thisp.x+direction.x
thisp.y=thisp.y+direction.y
thisp.z=thisp.z+direction.z
nextnode=minetest.env:get_node(thisp)
minetest.env:add_node(thisp, {name=thisnode.name})
minetest.env:place_node(thisp, {name=thisnode.name})
nodeupdate(thisp)
thisnode=nextnode
until thisnode.name=="air"
@ -233,8 +233,8 @@ mesecon:register_on_signal_off(function (pos, node)
if thisnode.name~="air" and thisnode.name~="water" and not mesecon:is_mvps_stopper(thisnode.name) then
local newpos={}
local oldpos={}
minetest.env:add_node(np, {name=thisnode.name})
minetest.env:remove_node(thisp)
minetest.env:place_node(np, {name=thisnode.name})
minetest.env:dig_node(thisp)
end
end
end