torches.lua 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. -- Elf torch
  2. local function on_flood_elf(pos, oldnode, newnode)
  3. minetest.add_item(pos, ItemStack("lottblocks:elf_torch 1"))
  4. return false
  5. end
  6. minetest.register_node("lottblocks:elf_torch", {
  7. description = "Elf Torch",
  8. drawtype = "mesh",
  9. mesh = "default_torch_floor.obj",
  10. inventory_image = "lottblocks_elf_torch_on_floor.png",
  11. wield_image = "lottblocks_elf_torch_on_floor.png",
  12. tiles = {{
  13. name = "lottblocks_elf_torch_on_floor_animated.png",
  14. animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
  15. }},
  16. paramtype = "light",
  17. paramtype2 = "wallmounted",
  18. sunlight_propagates = true,
  19. walkable = false,
  20. liquids_pointable = false,
  21. light_source = 12,
  22. groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1},
  23. drop = "lottblocks:elf_torch",
  24. selection_box = {
  25. type = "wallmounted",
  26. wall_bottom = {-1/8, -1/2, -1/8, 1/8, 2/16, 1/8},
  27. wall_top = {-1/8, -3/16, -1/8, 1/8, 1/2, 1/8},
  28. },
  29. on_place = function(itemstack, placer, pointed_thing)
  30. local under = pointed_thing.under
  31. local node = minetest.get_node(under)
  32. local def = minetest.registered_nodes[node.name]
  33. if def and def.on_rightclick and
  34. not (placer and placer:is_player() and
  35. placer:get_player_control().sneak) then
  36. return def.on_rightclick(under, node, placer, itemstack,
  37. pointed_thing) or itemstack
  38. end
  39. local above = pointed_thing.above
  40. local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
  41. local fakestack = itemstack
  42. if wdir == 0 or wdir == 1 then
  43. fakestack:set_name("lottblocks:elf_torch")
  44. else
  45. fakestack:set_name("lottblocks:elf_torch_wall")
  46. end
  47. itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir)
  48. itemstack:set_name("lottblocks:elf_torch")
  49. return itemstack
  50. end,
  51. floodable = true,
  52. on_flood = on_flood_elf,
  53. })
  54. minetest.register_node("lottblocks:elf_torch_wall", {
  55. drawtype = "mesh",
  56. mesh = "default_torch_wall.obj",
  57. tiles = {{
  58. name = "lottblocks_elf_torch_on_floor_animated.png",
  59. animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
  60. }},
  61. paramtype = "light",
  62. paramtype2 = "wallmounted",
  63. sunlight_propagates = true,
  64. walkable = false,
  65. light_source = 12,
  66. groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
  67. drop = "lottblocks:elf_torch",
  68. selection_box = {
  69. type = "wallmounted",
  70. wall_side = {-1/2, -1/2, -1/8, -5/16, 1/8, 1/8},
  71. },
  72. floodable = true,
  73. on_flood = on_flood_elf,
  74. })
  75. minetest.register_lbm({
  76. name = "lottblocks:elftorch",
  77. nodenames = {"lottblocks:elf_torch"},
  78. action = function(pos, node)
  79. if node.param2 == 0 or node.param2 == 1 then
  80. minetest.set_node(pos, {name = "lottblocks:elf_torch",
  81. param2 = node.param2})
  82. else
  83. minetest.set_node(pos, {name = "lottblocks:elf_torch_wall",
  84. param2 = node.param2})
  85. end
  86. end
  87. })
  88. minetest.register_craft({
  89. output = 'lottblocks:elf_torch 2',
  90. recipe = {
  91. {'lottores:rough_rock_lump'},
  92. {'group:stick'},
  93. }
  94. })
  95. -- Orc torch
  96. local function on_flood_orc(pos, oldnode, newnode)
  97. minetest.add_item(pos, ItemStack("lottblocks:orc_torch 1"))
  98. return false
  99. end
  100. minetest.register_node("lottblocks:orc_torch", {
  101. description = "Orc Torch",
  102. drawtype = "mesh",
  103. mesh = "default_torch_floor.obj",
  104. inventory_image = "lottblocks_orc_torch_on_floor.png",
  105. wield_image = "lottblocks_orc_torch_on_floor.png",
  106. tiles = {{
  107. name = "lottblocks_orc_torch_on_floor_animated.png",
  108. animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
  109. }},
  110. paramtype = "light",
  111. paramtype2 = "wallmounted",
  112. sunlight_propagates = true,
  113. walkable = false,
  114. liquids_pointable = false,
  115. light_source = 12,
  116. groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1},
  117. drop = "lottblocks:orc_torch",
  118. selection_box = {
  119. type = "wallmounted",
  120. wall_bottom = {-1/8, -1/2, -1/8, 1/8, 2/16, 1/8},
  121. wall_top = {-1/8, -3/16, -1/8, 1/8, 1/2, 1/8},
  122. },
  123. on_place = function(itemstack, placer, pointed_thing)
  124. local under = pointed_thing.under
  125. local node = minetest.get_node(under)
  126. local def = minetest.registered_nodes[node.name]
  127. if def and def.on_rightclick and
  128. not (placer and placer:is_player() and
  129. placer:get_player_control().sneak) then
  130. return def.on_rightclick(under, node, placer, itemstack,
  131. pointed_thing) or itemstack
  132. end
  133. local above = pointed_thing.above
  134. local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
  135. local fakestack = itemstack
  136. if wdir == 0 or wdir == 1 then
  137. fakestack:set_name("lottblocks:orc_torch")
  138. else
  139. fakestack:set_name("lottblocks:orc_torch_wall")
  140. end
  141. itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir)
  142. itemstack:set_name("lottblocks:orc_torch")
  143. return itemstack
  144. end,
  145. floodable = true,
  146. on_flood = on_flood_orc,
  147. })
  148. minetest.register_node("lottblocks:orc_torch_wall", {
  149. drawtype = "mesh",
  150. mesh = "default_torch_wall.obj",
  151. tiles = {{
  152. name = "lottblocks_orc_torch_on_floor_animated.png",
  153. animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
  154. }},
  155. paramtype = "light",
  156. paramtype2 = "wallmounted",
  157. sunlight_propagates = true,
  158. walkable = false,
  159. light_source = 12,
  160. groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
  161. drop = "lottblocks:orc_torch",
  162. selection_box = {
  163. type = "wallmounted",
  164. wall_side = {-1/2, -1/2, -1/8, -5/16, 1/8, 1/8},
  165. },
  166. floodable = true,
  167. on_flood = on_flood_orc,
  168. })
  169. minetest.register_lbm({
  170. name = "lottblocks:orctorch",
  171. nodenames = {"lottblocks:orc_torch"},
  172. action = function(pos, node)
  173. if node.param2 == 0 or node.param2 == 1 then
  174. minetest.set_node(pos, {name = "lottblocks:orc_torch",
  175. param2 = node.param2})
  176. else
  177. minetest.set_node(pos, {name = "lottblocks:orc_torch_wall",
  178. param2 = node.param2})
  179. end
  180. end
  181. })
  182. minetest.register_craft({
  183. output = 'lottblocks:orc_torch 2',
  184. recipe = {
  185. {'bones:bone'},
  186. {'group:stick'},
  187. }
  188. })