lightstones.lua 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. local rules_all_directions =
  2. {{x=0, y=0, z=-1},
  3. {x=1, y=0, z=0},
  4. {x=-1, y=0, z=0},
  5. {x=0, y=0, z=1},
  6. {x=1, y=1, z=0},
  7. {x=1, y=-1, z=0},
  8. {x=-1, y=1, z=0},
  9. {x=-1, y=-1, z=0},
  10. {x=0, y=1, z=1},
  11. {x=0, y=-1, z=1},
  12. {x=0, y=1, z=-1},
  13. {x=0, y=1, z=0},
  14. {x=0, y=-1, z=0},
  15. {x=0, y=-1, z=-1}}
  16. function meseconductors:lightstone_add(name, color, base_item)
  17. minetest.register_node("meseconductors:lightstone_" .. color .. "_off", {
  18. tiles = {"meseconductors_lightstone_" .. color .. "_off.png"},
  19. groups = {cracky=2, mesecon_effector_off = 1, mesecon = 2},
  20. description=name.." Lightstone",
  21. sounds = default.node_sound_glass_defaults(),
  22. mesecons = {effector = {
  23. rules = rules_all_directions,
  24. action_on = function (pos, node)
  25. minetest.swap_node(pos, {name = "meseconductors:lightstone_" .. color .. "_on", param2 = node.param2})
  26. end,
  27. }}
  28. })
  29. minetest.register_node("meseconductors:lightstone_" .. color .. "_on", {
  30. tiles = {"meseconductors_lightstone_" .. color .. "_on.png"},
  31. groups = {cracky=2,not_in_creative_inventory=1, mesecon = 2},
  32. drop = "meseconductors:lightstone_" .. color .. "_off",
  33. light_source = 13,
  34. sounds = default.node_sound_glass_defaults(),
  35. mesecons = {effector = {
  36. rules = rules_all_directions,
  37. action_off = function (pos, node)
  38. minetest.swap_node(pos, {name = "meseconductors:lightstone_" .. color .. "_off", param2 = node.param2})
  39. end,
  40. }}
  41. })
  42. minetest.register_craft({
  43. output = "meseconductors:lightstone_" .. color .. "_off 2",
  44. recipe = {
  45. {"default:glass",base_item,"default:glass"},
  46. {base_item,"default:torch",base_item},
  47. {"default:glass","meseconductors:lamp_controller","default:glass"}
  48. }
  49. })
  50. end
  51. meseconductors:lightstone_add("Red", "red", "dye:red")
  52. meseconductors:lightstone_add("Green", "green", "dye:green")
  53. meseconductors:lightstone_add("Blue", "blue", "dye:blue")
  54. meseconductors:lightstone_add("Yellow", "yellow", "dye:yellow")
  55. meseconductors:lightstone_add("White", "white", "dye:white")
  56. meseconductors:lightstone_add("Pink", "pink", "dye:pink")
  57. meseconductors:lightstone_add("Cyan", "cyan", "dye:cyan")
  58. meseconductors:lightstone_add("Orange", "orange", "dye:orange")
  59. meseconductors:lightstone_add("Black", "black", "dye:black")