functions.lua 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. local scaffolding_nodenames={"scaffolding:scaffolding","scaffolding:iron_scaffolding"}
  2. minetest.register_on_dignode(function(pos, node)
  3. local i=1
  4. while scaffolding_nodenames[i]~=nil do
  5. if node.name==scaffolding_nodenames[i] then
  6. local np={x=pos.x, y=pos.y+1, z=pos.z}
  7. while minetest.env:get_node(np).name==scaffolding_nodenames[i] do
  8. minetest.env:remove_node(np)
  9. minetest.env:add_item(np, scaffolding_nodenames[i])
  10. np={x=np.x, y=np.y+1, z=np.z}
  11. end
  12. end
  13. i=i+1
  14. end
  15. end)
  16. local iron_scaffolding_nodenames={"scaffolding:platform","scaffolding:iron_platform"}
  17. minetest.register_on_dignode(function(pos, node)
  18. local i=1
  19. while iron_scaffolding_nodenames[i]~=nil do
  20. if node.name==iron_scaffolding_nodenames[i] then
  21. local np={x=pos.x, y=pos.y, z=pos.z+1}
  22. while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do
  23. minetest.env:remove_node(np)
  24. minetest.env:add_item(np, iron_scaffolding_nodenames[i])
  25. np={x=np.x, y=np.y, z=np.z+1}
  26. end
  27. end
  28. i=i+1
  29. end
  30. end)
  31. minetest.register_on_dignode(function(pos, node)
  32. local i=1
  33. while iron_scaffolding_nodenames[i]~=nil do
  34. if node.name==iron_scaffolding_nodenames[i] then
  35. local np={x=pos.x, y=pos.y, z=pos.z-1}
  36. while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do
  37. minetest.env:remove_node(np)
  38. minetest.env:add_item(np, iron_scaffolding_nodenames[i])
  39. np={x=np.x, y=np.y, z=np.z-1}
  40. end
  41. end
  42. i=i-1
  43. end
  44. end)
  45. minetest.register_on_dignode(function(pos, node)
  46. local i=1
  47. while iron_scaffolding_nodenames[i]~=nil do
  48. if node.name==iron_scaffolding_nodenames[i] then
  49. local np={x=pos.x+1, y=pos.y, z=pos.z}
  50. while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do
  51. minetest.env:remove_node(np)
  52. minetest.env:add_item(np, iron_scaffolding_nodenames[i])
  53. np={x=np.x+1, y=np.y, z=np.z}
  54. end
  55. end
  56. i=i+1
  57. end
  58. end)
  59. minetest.register_on_dignode(function(pos, node)
  60. local i=1
  61. while iron_scaffolding_nodenames[i]~=nil do
  62. if node.name==iron_scaffolding_nodenames[i] then
  63. local np={x=pos.x-1, y=pos.y, z=pos.z}
  64. while minetest.env:get_node(np).name==iron_scaffolding_nodenames[i] do
  65. minetest.env:remove_node(np)
  66. minetest.env:add_item(np, iron_scaffolding_nodenames[i])
  67. np={x=np.x-1, y=np.y, z=np.z}
  68. end
  69. end
  70. i=i-1
  71. end
  72. end)
  73. -- falling nodes go into pocket --
  74. function scaffolding.dig_horx(pos, node, digger)
  75. if digger == nil then return end
  76. local np = {x = pos.x + 1, y = pos.y, z = pos.z,}
  77. local nn = minetest.get_node(np)
  78. if nn.name == node.name then
  79. minetest.node_dig(np, nn, digger)
  80. end
  81. end
  82. function scaffolding.dig_horx2(pos, node, digger)
  83. if digger == nil then return end
  84. local np = {x = pos.x - 1, y = pos.y, z = pos.z,}
  85. local nn = minetest.get_node(np)
  86. if nn.name == node.name then
  87. minetest.node_dig(np, nn, digger)
  88. end
  89. end
  90. function scaffolding.dig_horz(pos, node, digger)
  91. if digger == nil then return end
  92. local np = {x = pos.x, y = pos.y, z = pos.z + 1,}
  93. local nn = minetest.get_node(np)
  94. if nn.name == node.name then
  95. minetest.node_dig(np, nn, digger)
  96. end
  97. end
  98. function scaffolding.dig_horz2(pos, node, digger)
  99. if digger == nil then return end
  100. local np = {x = pos.x , y = pos.y, z = pos.z - 1,}
  101. local nn = minetest.get_node(np)
  102. if nn.name == node.name then
  103. minetest.node_dig(np, nn, digger)
  104. end
  105. end