forked from mtcontrib/pipeworks
Fix node breaker, use new minetest.swap_node
This commit is contained in:
parent
75db2c5307
commit
5a2d57b485
20
deployer.lua
20
deployer.lua
|
@ -66,33 +66,29 @@ minetest.register_craft({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
local function hacky_swap_node(pos,name)
|
local function swap_node(pos, name)
|
||||||
local node=minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local meta=minetest.get_meta(pos)
|
|
||||||
local meta0=meta:to_table()
|
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
node.name=name
|
node.name = name
|
||||||
minetest.add_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
local meta=minetest.get_meta(pos)
|
|
||||||
meta:from_table(meta0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function delay(x)
|
local function delay(x)
|
||||||
return (function() return x end)
|
return (function() return x end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local deployer_on = function(pos, node)
|
local function deployer_on(pos, node)
|
||||||
if node.name ~= "pipeworks:deployer_off" then
|
if node.name ~= "pipeworks:deployer_off" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
--locate the above and under positions
|
--locate the above and under positions
|
||||||
local dir = minetest.facedir_to_dir(node.param2)
|
local dir = minetest.facedir_to_dir(node.param2)
|
||||||
local pos_under, pos_above = {x=pos.x - dir.x, y=pos.y - dir.y, z=pos.z - dir.z}, {x=pos.x - 2*dir.x, y=pos.y - 2*dir.y, z=pos.z - 2*dir.z}
|
local pos_under, pos_above = {x = pos.x - dir.x, y = pos.y - dir.y, z = pos.z - dir.z}, {x = pos.x - 2*dir.x, y = pos.y - 2*dir.y, z = pos.z - 2*dir.z}
|
||||||
|
|
||||||
hacky_swap_node(pos,"pipeworks:deployer_on")
|
swap_node(pos, "pipeworks:deployer_on")
|
||||||
nodeupdate(pos)
|
nodeupdate(pos)
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
@ -163,7 +159,7 @@ end
|
||||||
|
|
||||||
local deployer_off = function(pos, node)
|
local deployer_off = function(pos, node)
|
||||||
if node.name == "pipeworks:deployer_on" then
|
if node.name == "pipeworks:deployer_on" then
|
||||||
hacky_swap_node(pos,"pipeworks:deployer_off")
|
swap_node(pos, "pipeworks:deployer_off")
|
||||||
nodeupdate(pos)
|
nodeupdate(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,17 +14,13 @@ minetest.register_craft({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
local function hacky_swap_node(pos,name)
|
local function swap_node(pos, name)
|
||||||
local node=minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local meta=minetest.get_meta(pos)
|
|
||||||
local meta0=meta:to_table()
|
|
||||||
if node.name == name then
|
if node.name == name then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
node.name=name
|
node.name = name
|
||||||
minetest.add_node(pos, node)
|
minetest.swap_node(pos, node)
|
||||||
local meta=minetest.get_meta(pos)
|
|
||||||
meta:from_table(meta0)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--define the functions from https://github.com/minetest/minetest/pull/834 while waiting for the devs to notice it
|
--define the functions from https://github.com/minetest/minetest/pull/834 while waiting for the devs to notice it
|
||||||
|
@ -91,7 +87,6 @@ local function break_node (pos, facedir)
|
||||||
|
|
||||||
local vel = minetest.facedir_to_dir(facedir);
|
local vel = minetest.facedir_to_dir(facedir);
|
||||||
local front = {x=pos.x - vel.x, y=pos.y - vel.y, z=pos.z - vel.z}
|
local front = {x=pos.x - vel.x, y=pos.y - vel.y, z=pos.z - vel.z}
|
||||||
local back = {x=pos.x + vel.x, y=pos.y + vel.y, z=pos.z + vel.z}
|
|
||||||
|
|
||||||
local node = minetest.get_node(front)
|
local node = minetest.get_node(front)
|
||||||
if node.name == "air" or node.name == "ignore" then
|
if node.name == "air" or node.name == "ignore" then
|
||||||
|
@ -168,6 +163,11 @@ local function break_node (pos, facedir)
|
||||||
item1:setacceleration({x=0, y=0, z=0})
|
item1:setacceleration({x=0, y=0, z=0})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local oldmetadata = nil
|
||||||
|
if def.after_dig_node then
|
||||||
|
oldmetadata = minetest.get_meta(front):to_table()
|
||||||
|
end
|
||||||
|
|
||||||
minetest.remove_node(front)
|
minetest.remove_node(front)
|
||||||
|
|
||||||
--handle post-digging callback
|
--handle post-digging callback
|
||||||
|
@ -189,15 +189,15 @@ end
|
||||||
|
|
||||||
local node_breaker_on = function(pos, node)
|
local node_breaker_on = function(pos, node)
|
||||||
if node.name == "pipeworks:nodebreaker_off" then
|
if node.name == "pipeworks:nodebreaker_off" then
|
||||||
hacky_swap_node(pos,"pipeworks:nodebreaker_on")
|
swap_node(pos, "pipeworks:nodebreaker_on")
|
||||||
break_node(pos,node.param2)
|
break_node(pos, node.param2)
|
||||||
nodeupdate(pos)
|
nodeupdate(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local node_breaker_off = function(pos, node)
|
local node_breaker_off = function(pos, node)
|
||||||
if node.name == "pipeworks:nodebreaker_on" then
|
if node.name == "pipeworks:nodebreaker_on" then
|
||||||
hacky_swap_node(pos,"pipeworks:nodebreaker_off")
|
swap_node(pos, "pipeworks:nodebreaker_off")
|
||||||
nodeupdate(pos)
|
nodeupdate(pos)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user