2d.lua 1.4 KB

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