2d.lua 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. -- unlit torch
  2. minetest.register_node("real_torch:torch", {
  3. description = "Unlit Torch",
  4. drawtype = "torchlike",
  5. tiles = {
  6. {name = "real_torch_on_floor.png"},
  7. {name = "real_torch_ceiling.png"},
  8. {name = "real_torch_wall.png"},
  9. },
  10. inventory_image = "real_torch_on_floor.png",
  11. wield_image = "real_torch_on_floor.png",
  12. paramtype = "light",
  13. paramtype2 = "wallmounted",
  14. light_source = 3,
  15. sunlight_propagates = true,
  16. is_ground_content = false,
  17. walkable = false,
  18. selection_box = {
  19. type = "wallmounted",
  20. wall_top = {-0.1, 0.5 - 0.6, -0.1, 0.1, 0.5, 0.1},
  21. wall_bottom = {-0.1, -0.5, -0.1, 0.1, -0.5 + 0.6, 0.1},
  22. wall_side = {-0.5, -0.3, -0.1, -0.5 + 0.3, 0.3, 0.1},
  23. },
  24. groups = utility.dig_groups("item", {attached_node = 1}),
  25. legacy_wallmounted = true,
  26. sounds = default.node_sound_defaults(),
  27. })
  28. -- override default torches to burn out after 8-10 minutes
  29. minetest.override_item("default:torch", {
  30. on_timer = function(pos, elapsed)
  31. local p2 = minetest.get_node(pos).param2
  32. minetest.add_node(pos, {name = "real_torch:torch", param2 = p2})
  33. minetest.sound_play({name="real_torch_burnout", gain = 0.1},
  34. {pos = pos, max_hear_distance = 10})
  35. end,
  36. on_construct = function(pos)
  37. minetest.get_node_timer(pos):start(
  38. math.random(real_torch.min_duration, real_torch.max_duration))
  39. end,
  40. })