41 lines
1.7 KiB
Lua
41 lines
1.7 KiB
Lua
|
--[[ Nodestacking function by https://github.com/minetest-mods/gloopblocks ]]
|
||
|
|
||
|
local nodes={"scaffolding:reinforced_iron_scaffolding",
|
||
|
"scaffolding:iron_scaffolding",
|
||
|
"scaffolding:scaffolding",
|
||
|
"scaffolding:reinforced_scaffolding"
|
||
|
}
|
||
|
|
||
|
for i = 1, 4 do
|
||
|
local nodes = nodes[i]
|
||
|
minetest.override_item(nodes, {
|
||
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||
|
if itemstack and itemstack:get_name() == node.name then
|
||
|
for i = 1,19 do
|
||
|
if minetest.get_node({x=pos.x,z=pos.z}).name == nodes and scafffound ~= 0 and scafffound ~= 1 then
|
||
|
local scafffound = 1
|
||
|
return itemstack
|
||
|
else
|
||
|
break
|
||
|
end
|
||
|
end
|
||
|
for i = 1,19 do
|
||
|
if minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name == "air" and scaffworked ~= 1 and scaffworked ~= 0 then
|
||
|
minetest.set_node({x=pos.x,y=pos.y+i,z=pos.z}, {name=nodes})
|
||
|
local scaffworked = 1
|
||
|
return ItemStack(tostring(itemstack:get_name().." "..tostring(itemstack:get_count()-1)))
|
||
|
elseif minetest.get_node({x=pos.x,y=pos.y+i,z=pos.z}).name == nodes then
|
||
|
else
|
||
|
local scaffworked = 0
|
||
|
end
|
||
|
end
|
||
|
if scaffworked == 1 then
|
||
|
return ItemStack(tostring(itemstack:get_name().." "..tostring(itemstack:get_count()-1)))
|
||
|
else
|
||
|
return itemstack
|
||
|
end
|
||
|
else return itemstack end
|
||
|
end,
|
||
|
})
|
||
|
end
|