Advertisement
Guest User

Untitled

a guest
Oct 29th, 2014
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1.  
  2. minetest.register_node("default:sponge", {
  3. description = "Sponge",
  4. drawtype = "normal",
  5. tiles = {"default_sponge.png"},
  6. paramtype = 'light',
  7. walkable = true,
  8. pointable = true,
  9. diggable = true,
  10. buildable_to = false,
  11. stack_max = 64,
  12. groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3,flammable=3},
  13. on_place = function(itemstack, placer, pointed_thing)
  14. local pn = placer:get_player_name()
  15. if pointed_thing.type ~= "node" then
  16. return itemstack
  17. end
  18. if minetest.is_protected(pointed_thing.above, pn) then
  19. return itemstack
  20. end
  21. local change = false
  22. local on_water = false
  23. local pos = pointed_thing.above
  24. -- verifier si il est dans l'eau ou a cotée
  25. if string.find(minetest.env:get_node(pointed_thing.above).name, "water_source")
  26. or string.find(minetest.env:get_node(pointed_thing.above).name, "water_flowing") then
  27. on_water = true
  28. end
  29. for i=-1,1 do
  30. p = {x=pos.x+i, y=pos.y, z=pos.z}
  31. n = minetest.env:get_node(p)
  32. -- On verifie si il y a de l'eau
  33. if (n.name=="default:water_flowing") or (n.name == "default:water_source") then
  34. on_water = true
  35. end
  36. end
  37. for i=-1,1 do
  38. p = {x=pos.x, y=pos.y+i, z=pos.z}
  39. n = minetest.env:get_node(p)
  40. -- On verifie si il y a de l'eau
  41. if (n.name=="default:water_flowing") or (n.name == "default:water_source") then
  42. on_water = true
  43. end
  44. end
  45. for i=-1,1 do
  46. p = {x=pos.x, y=pos.y, z=pos.z+i}
  47. n = minetest.env:get_node(p)
  48. -- On verifie si il y a de l'eau
  49. if (n.name=="default:water_flowing") or (n.name == "default:water_source") then
  50. on_water = true
  51. end
  52. end
  53.  
  54. if on_water == true then
  55. for i=-3,3 do
  56. for j=-3,3 do
  57. for k=-3,3 do
  58. p = {x=pos.x+i, y=pos.y+j, z=pos.z+k}
  59. n = minetest.env:get_node(p)
  60. -- On Supprime l'eau
  61. if (n.name=="default:water_flowing") or (n.name == "default:water_source")then
  62. minetest.env:add_node(p, {name="air"})
  63. change = true
  64. end
  65. end
  66. end
  67. end
  68. end
  69. p = {x=pos.x, y=pos.y, z=pos.z}
  70. n = minetest.env:get_node(p)
  71. if change == true then
  72. minetest.env:add_node(pointed_thing.above, {name = "default:sponge_wet"})
  73. else
  74. minetest.env:add_node(pointed_thing.above, {name = "default:sponge"})
  75. end
  76. return itemstack
  77.  
  78. end
  79. })
  80.  
  81. minetest.register_node("default:sponge_wet", {
  82. description = "Wet Sponge",
  83. drawtype = "normal",
  84. tiles = {"default_sponge_wet.png"},
  85. paramtype = 'light',
  86. walkable = true,
  87. pointable = true,
  88. diggable = true,
  89. buildable_to = false,
  90. stack_max = 64,
  91. groups = {snappy=2,choppy=2,oddly_breakable_by_hand=3},
  92. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement