candil.lua 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. local formas = {}
  2. formas["morelanterns_candil_techo"] = {
  3. {-0.0625, -0.4375, 0.0625, 0.0625, -0.1875, 0.125}, -- axis
  4. {-0.0625, -0.5, -0.0625, 0.0625, -0.4375, 0.125}, -- pie
  5. {-0.0625, -0.1875, 0.0625, 0.0625, -0.125, 0.1875}, -- handle
  6. {0.0625, -0.4375, 0, -0.0625, -0.375, -0.0625}, -- knot
  7. };
  8. formas["morelanterns_candil_pared"] = {
  9. {-0.0625, -0.4375, 0.0625, 0.0625, -0.375, 0.3125}, -- axis
  10. {-0.0625, -0.4375, 0, 0.0625, -0.25, 0.0625}, -- pie
  11. {-0.0625, -0.5, 0.3125, 0.0625, -0.375, 0.375}, -- handle
  12. {-0.0625, -0.3125, 0.0625, 0.0625, -0.25, 0.125}, -- knot
  13. };
  14. formas["morelanterns_candil_suelo"] = {
  15. {-0.0625, -0.4375, 0.0625, 0.0625, -0.1875, 0.125}, -- axis
  16. {-0.0625, -0.5, -0.0625, 0.0625, -0.4375, 0.125}, -- pie
  17. {-0.0625, -0.1875, 0.0625, 0.0625, -0.125, 0.1875}, -- handle
  18. {-0.0625, -0.4375, -0.0625, 0.0625, -0.375, 0}, -- knot
  19. };
  20. -- ------------------------------------------------
  21. local function on_flood(pos, oldnode, newnode)
  22. minetest.add_item(pos, ItemStack("morelanterns:candil 1"))
  23. -- Play flame-extinguish sound if liquid is not an 'igniter'
  24. local nodedef = minetest.registered_items[newnode.name]
  25. if not (nodedef and nodedef.groups and
  26. nodedef.groups.igniter and nodedef.groups.igniter > 0) then
  27. minetest.sound_play(
  28. "default_cool_lava",
  29. {pos = pos, max_hear_distance = 16, gain = 0.07},
  30. true
  31. )
  32. end
  33. -- Remove the torch node
  34. return false
  35. end
  36. minetest.register_node("morelanterns:candil", {
  37. description = "Candil",
  38. drawtype = "mesh",
  39. mesh = "candil.obj",
  40. --inventory_image = "default_torch_on_floor.png",
  41. -- wield_image = "default_torch_on_floor.png",
  42. tiles = { "candil_mat.png"
  43. -- name = "default_torch_on_floor_animated.png",
  44. -- animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
  45. },
  46. -- drawtype = "nodebox",
  47. -- node_box = {
  48. -- type = "fixed",
  49. -- fixed = formas["morelanterns_candil_suelo"]
  50. -- },
  51. --node_box = {
  52. -- type = "fixed",
  53. -- wall_top = formas["morelanterns_candil_techo"],
  54. -- wall_bottom = formas["morelanterns_candil_suelo"],
  55. -- wall_side = formas["morelanterns_candil"]
  56. --},
  57. inventory_image = "morelanterns_candil_inv.png",
  58. wield_image = "morelanterns_candil_inv.png",
  59. -- tiles = { "morelanterns_candil.png" },
  60. use_texture_alpha = "clip",
  61. paramtype = "light",
  62. paramtype2 = "wallmounted",
  63. sunlight_propagates = true,
  64. walkable = false,
  65. liquids_pointable = false,
  66. light_source = LIGHT_LEVELS.min,
  67. groups = {choppy=2, dig_immediate=3, flammable=1, attached_node=1, torch=1, lantern=1},
  68. drop = "morelanterns:candil",
  69. --selection_box = {
  70. -- type = "wallmounted",
  71. -- wall_bottom = formas["morelanterns_candil_suelo"]
  72. -- },
  73. sounds = default.node_sound_wood_defaults(),
  74. on_place = function(itemstack, placer, pointed_thing)
  75. local under = pointed_thing.under
  76. local node = minetest.get_node(under)
  77. local def = minetest.registered_nodes[node.name]
  78. if def and def.on_rightclick and
  79. not (placer and placer:is_player() and
  80. placer:get_player_control().sneak) then
  81. -- minetest.chat_send_all("DENTRO IF")
  82. return def.on_rightclick(under, node, placer, itemstack,
  83. pointed_thing) or itemstack
  84. end
  85. -- minetest.chat_send_all("FUERA IF")
  86. local above = pointed_thing.above
  87. local wdir = minetest.dir_to_wallmounted(vector.subtract(under, above))
  88. local fakestack = itemstack
  89. if wdir == 0 then
  90. fakestack:set_name("morelanterns:candil_ceiling")
  91. elseif wdir == 1 then
  92. fakestack:set_name("morelanterns:candil")
  93. else
  94. fakestack:set_name("morelanterns:candil_wall")
  95. end
  96. itemstack = minetest.item_place(fakestack, placer, pointed_thing, wdir)
  97. itemstack:set_name("morelanterns:candil")
  98. return itemstack
  99. end,
  100. floodable = true,
  101. on_flood = on_flood,
  102. on_rotate = false
  103. })
  104. minetest.register_node("morelanterns:candil_wall", {
  105. drawtype = "mesh",
  106. mesh = "candil.obj",
  107. tiles = { "candil_mat.png"
  108. -- name = "default_torch_on_floor_animated.png",
  109. -- animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
  110. },
  111. -- drawtype = "nodebox",
  112. -- node_box = {
  113. -- type = "fixed",
  114. -- fixed = formas["morelanterns_candil_pared"]
  115. --},
  116. --tiles = { "morelanterns_candil.png" },
  117. use_texture_alpha = "clip",
  118. paramtype = "light",
  119. paramtype2 = "wallmounted",
  120. sunlight_propagates = true,
  121. walkable = false,
  122. light_source = LIGHT_LEVELS.low,
  123. groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1, lantern=1},
  124. drop = "morelanterns:candil",
  125. --selection_box = {
  126. -- type = "wallmounted",
  127. -- wall_side = formas["morelanterns_candil_pared"]
  128. -- },
  129. sounds = default.node_sound_wood_defaults(),
  130. floodable = true,
  131. on_flood = on_flood,
  132. on_rotate = false
  133. })
  134. minetest.register_node("morelanterns:candil_ceiling", {
  135. drawtype = "mesh",
  136. mesh = "candil.obj",
  137. tiles = { "candil_mat.png"
  138. -- name = "default_torch_on_floor_animated.png",
  139. -- animation = {type = "vertical_frames", aspect_w = 16, aspect_h = 16, length = 3.3}
  140. },
  141. --drawtype = "nodebox",
  142. --node_box = {
  143. -- type = "fixed",
  144. -- fixed = formas["morelanterns_candil_techo"]
  145. --},
  146. --tiles = { "morelanterns_candil.png" },
  147. use_texture_alpha = "clip",
  148. paramtype = "light",
  149. paramtype2 = "wallmounted",
  150. sunlight_propagates = true,
  151. walkable = false,
  152. light_source = LIGHT_LEVELS.med,
  153. groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1, lantern=1},
  154. drop = "morelanterns:candil",
  155. --selection_box = {
  156. -- type = "wallmounted",
  157. -- wall_top = formas["morelanterns_candil_techo"],
  158. --},
  159. sounds = default.node_sound_wood_defaults(),
  160. floodable = true,
  161. on_flood = on_flood,
  162. on_rotate = false
  163. })
  164. minetest.register_lbm({
  165. name = "morelanterns:3dcandil",
  166. nodenames = {"morelanterns:candil","morelanterns:candil_ceiling","morelanterns:candil_wall"},
  167. action = function(pos, node)
  168. if node.param2 == 0 then
  169. minetest.set_node(pos, {name = "morelanterns:candil_ceiling",
  170. param2 = node.param2})
  171. elseif node.param2 == 1 then
  172. minetest.set_node(pos, {name = "morelanterns:candil",
  173. param2 = node.param2})
  174. else
  175. minetest.set_node(pos, {name = "morelanterns:candil_wall",
  176. param2 = node.param2})
  177. end
  178. end
  179. })
  180. -- registrar crafteos
  181. local register_linterna_craft = function(name, material)
  182. minetest.register_craft({
  183. output = name,
  184. recipe = {{material},
  185. {"torch"},
  186. {"default:glass"}
  187. }
  188. })
  189. end
  190. register_linterna_craft("morelanterns:candil","default:tin_ingot");
  191. -- CRAFT CON ACEITE
  192. local ethereal = minetest.get_modpath("ethereal");
  193. if (ethereal) then
  194. minetest.register_craft({
  195. output="morelanterns:candil",
  196. recipe= {
  197. {"default:tin_ingot"},
  198. {"ethereal:olive_oil"},
  199. {"default:glass"}
  200. }
  201. })
  202. end