torch.lua 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. local function on_flood(pos, oldnode, newnode)
  2. minetest.add_item(pos, ItemStack("etherium_stuff:torch 1"))
  3. -- Play flame-extinguish sound if liquid is not an 'igniter'
  4. local nodedef = minetest.registered_items[newnode.name]
  5. if not (nodedef and nodedef.groups and
  6. nodedef.groups.igniter and nodedef.groups.igniter > 0) then
  7. minetest.sound_play(
  8. "default_cool_lava",
  9. {pos = pos, max_hear_distance = 16, gain = 0.1}
  10. )
  11. end
  12. -- Remove the torch node
  13. return false
  14. end
  15. minetest.register_node("etherium_stuff:torch", {
  16. description = "Etherium Torch",
  17. drawtype = "mesh",
  18. mesh = "torch_floor.obj",
  19. inventory_image = "etherium_torch_on_floor.png",
  20. wield_image = "etherium_torch_on_floor.png",
  21. tiles = {{
  22. name = "etherium_torch_on_floor_animated.png",
  23. animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
  24. }},
  25. paramtype = "light",
  26. paramtype2 = "wallmounted",
  27. sunlight_propagates = true,
  28. walkable = false,
  29. liquids_pointable = false,
  30. light_source = default.LIGHT_MAX - 1,
  31. groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1},
  32. drop = "etherium_stuff:torch",
  33. selection_box = {
  34. type = "wallmounted",
  35. wall_bottom = {-1/8, -1/2, -1/8, 1/8, 2/16, 1/8},
  36. },
  37. sounds = default.node_sound_wood_defaults(),
  38. on_place = function(itemstack, placer, pointed_thing)
  39. local under = pointed_thing.under
  40. local node = minetest.get_node(under)
  41. local def = minetest.registered_nodes[node.name]
  42. if def and def.on_rightclick and
  43. not (placer and placer:is_player() and
  44. placer:get_player_control().sneak) then
  45. return def.on_rightclick(under, node, placer, itemstack,
  46. pointed_thing) or itemstack
  47. end
  48. local above = pointed_thing.above
  49. local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
  50. local fakestack = itemstack
  51. if wdir == 0 then
  52. fakestack:set_name("etherium_stuff:torch_ceiling")
  53. elseif wdir == 1 then
  54. fakestack:set_name("etherium_stuff:torch")
  55. else
  56. fakestack:set_name("etherium_stuff:torch_wall")
  57. end
  58. itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir)
  59. itemstack:set_name("etherium_stuff:torch")
  60. return itemstack
  61. end,
  62. floodable = true,
  63. on_flood = on_flood,
  64. on_rotate = false
  65. })
  66. minetest.register_node("etherium_stuff:torch_wall", {
  67. drawtype = "mesh",
  68. mesh = "torch_wall.obj",
  69. tiles = {{
  70. name = "etherium_torch_on_floor_animated.png",
  71. animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
  72. }},
  73. paramtype = "light",
  74. paramtype2 = "wallmounted",
  75. sunlight_propagates = true,
  76. walkable = false,
  77. light_source = default.LIGHT_MAX - 1,
  78. groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
  79. drop = "etherium_stuff:torch",
  80. selection_box = {
  81. type = "wallmounted",
  82. wall_side = {-1/2, -1/2, -1/8, -1/8, 1/8, 1/8},
  83. },
  84. sounds = default.node_sound_wood_defaults(),
  85. floodable = true,
  86. on_flood = on_flood,
  87. on_rotate = false
  88. })
  89. minetest.register_node("etherium_stuff:torch_ceiling", {
  90. drawtype = "mesh",
  91. mesh = "torch_ceiling.obj",
  92. tiles = {{
  93. name = "etherium_torch_on_floor_animated.png",
  94. animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
  95. }},
  96. paramtype = "light",
  97. paramtype2 = "wallmounted",
  98. sunlight_propagates = true,
  99. walkable = false,
  100. light_source = default.LIGHT_MAX - 1,
  101. groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
  102. drop = "etherium_stuff:torch",
  103. selection_box = {
  104. type = "wallmounted",
  105. wall_top = {-1/8, -1/16, -5/16, 1/8, 1/2, 1/8},
  106. },
  107. sounds = default.node_sound_wood_defaults(),
  108. floodable = true,
  109. on_flood = on_flood,
  110. on_rotate = false
  111. })
  112. minetest.register_lbm({
  113. name = "etherium_stuff:3dtorch",
  114. nodenames = {"etherium_stuff:torch", "torches:floor", "torches:wall"},
  115. action = function(pos, node)
  116. if node.param2 == 0 then
  117. minetest.set_node(pos, {name = "etherium_stuff:torch_ceiling",
  118. param2 = node.param2})
  119. elseif node.param2 == 1 then
  120. minetest.set_node(pos, {name = "etherium_stuff:torch",
  121. param2 = node.param2})
  122. else
  123. minetest.set_node(pos, {name = "etherium_stuff:torch_wall",
  124. param2 = node.param2})
  125. end
  126. end
  127. })