2
0

torch.lua 4.4 KB

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