1
0
mirror of https://bitbucket.org/Infinatum/scaffolding.git synced 2024-11-15 06:40:29 +01:00
scaffolding/functions.lua
2015-02-21 15:07:34 +00:00

119 lines
3.2 KiB
Lua

scaffolding_nodenames={"scaffolding:scaffolding","scaffolding:iron_scaffolding"}
minetest.register_on_dignode(function(pos, node)
local i=1
while scaffolding_nodenames[i]~=nil do
if node.name==scaffolding_nodenames[i] then
np={x=pos.x, y=pos.y+1, z=pos.z}
while minetest.env:get_node(np).name==scaffolding_nodenames[i] do
minetest.env:remove_node(np)
minetest.env:add_item(np, scaffolding_nodenames[i])
np={x=np.x, y=np.y+1, z=np.z}
end
end
i=i+1
end
end)
iron_scaffolding_nodenames={"scaffolding:platform","scaffolding:iron_platform"}
minetest.register_on_dignode(function(pos, node)
local i=1
while iron_scaffolding_nodenames[i]~=nil do
if node.name==iron_scaffolding_nodenames[i] then
np={x=pos.x, y=pos.y, z=pos.z+1}
while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do
minetest.env:remove_node(np)
minetest.env:add_item(np, iron_scaffolding_nodenames[i])
np={x=np.x, y=np.y, z=np.z+1}
end
end
i=i+1
end
end)
minetest.register_on_dignode(function(pos, node)
local i=1
while iron_scaffolding_nodenames[i]~=nil do
if node.name==iron_scaffolding_nodenames[i] then
np={x=pos.x, y=pos.y, z=pos.z-1}
while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do
minetest.env:remove_node(np)
minetest.env:add_item(np, iron_scaffolding_nodenames[i])
np={x=np.x, y=np.y, z=np.z-1}
end
end
i=i-1
end
end)
minetest.register_on_dignode(function(pos, node)
local i=1
while iron_scaffolding_nodenames[i]~=nil do
if node.name==iron_scaffolding_nodenames[i] then
np={x=pos.x+1, y=pos.y, z=pos.z}
while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do
minetest.env:remove_node(np)
minetest.env:add_item(np, iron_scaffolding_nodenames[i])
np={x=np.x+1, y=np.y, z=np.z}
end
end
i=i+1
end
end)
minetest.register_on_dignode(function(pos, node)
local i=1
while iron_scaffolding_nodenames[i]~=nil do
if node.name==iron_scaffolding_nodenames[i] then
np={x=pos.x-1, y=pos.y, z=pos.z}
while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do
minetest.env:remove_node(np)
minetest.env:add_item(np, iron_scaffolding_nodenames[i])
np={x=np.x-1, y=np.y, z=np.z}
end
end
i=i-1
end
end)
-- falling nodes go into pocket --
function default.dig_horx(pos, node, digger)
if digger == nil then return end
local np = {x = pos.x + 1, y = pos.y, z = pos.z,}
local nn = minetest.get_node(np)
if nn.name == node.name then
minetest.node_dig(np, nn, digger)
end
end
function default.dig_horx2(pos, node, digger)
if digger == nil then return end
local np = {x = pos.x - 1, y = pos.y, z = pos.z,}
local nn = minetest.get_node(np)
if nn.name == node.name then
minetest.node_dig(np, nn, digger)
end
end
function default.dig_horz(pos, node, digger)
if digger == nil then return end
local np = {x = pos.x, y = pos.y, z = pos.z + 1,}
local nn = minetest.get_node(np)
if nn.name == node.name then
minetest.node_dig(np, nn, digger)
end
end
function default.dig_horz2(pos, node, digger)
if digger == nil then return end
local np = {x = pos.x , y = pos.y, z = pos.z - 1,}
local nn = minetest.get_node(np)
if nn.name == node.name then
minetest.node_dig(np, nn, digger)
end
end