init.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. local screwdriver_exists = minetest.global_exists("screwdriver")
  2. local function insulated_wire_get_rules(node)
  3. local rules = {{x = 1, y = 0, z = 0},
  4. {x =-1, y = 0, z = 0}}
  5. if node.param2 == 1 or node.param2 == 3 then
  6. return mesecon.rotate_rules_right(rules)
  7. end
  8. return rules
  9. end
  10. minetest.register_node("mesecons_insulated:insulated_on", {
  11. drawtype = "nodebox",
  12. description = "Straight Insulated Mesecon",
  13. tiles = {
  14. "jeija_insulated_wire_sides_on.png",
  15. "jeija_insulated_wire_sides_on.png",
  16. "jeija_insulated_wire_ends_on.png",
  17. "jeija_insulated_wire_ends_on.png",
  18. "jeija_insulated_wire_sides_on.png",
  19. "jeija_insulated_wire_sides_on.png"
  20. },
  21. paramtype = "light",
  22. paramtype2 = "facedir",
  23. is_ground_content = false,
  24. walkable = false,
  25. sunlight_propagates = true,
  26. selection_box = {
  27. type = "fixed",
  28. fixed = { -16/32, -16/32, -7/32, 16/32, -12/32, 7/32 }
  29. },
  30. node_box = {
  31. type = "fixed",
  32. -- ±0.001 is to prevent z-fighting
  33. fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
  34. },
  35. groups = {dig_immediate = 3, not_in_creative_inventory = 1},
  36. drop = "mesecons_insulated:insulated_off",
  37. sounds = default.node_sound_defaults(),
  38. mesecons = {conductor = {
  39. state = mesecon.state.on,
  40. offstate = "mesecons_insulated:insulated_off",
  41. rules = insulated_wire_get_rules
  42. }},
  43. on_blast = mesecon.on_blastnode,
  44. on_rotate = screwdriver_exists and screwdriver.rotate_simple,
  45. })
  46. minetest.register_node("mesecons_insulated:insulated_off", {
  47. drawtype = "nodebox",
  48. description = "Straight Insulated Mesecon",
  49. tiles = {
  50. "jeija_insulated_wire_sides_off.png",
  51. "jeija_insulated_wire_sides_off.png",
  52. "jeija_insulated_wire_ends_off.png",
  53. "jeija_insulated_wire_ends_off.png",
  54. "jeija_insulated_wire_sides_off.png",
  55. "jeija_insulated_wire_sides_off.png"
  56. },
  57. paramtype = "light",
  58. paramtype2 = "facedir",
  59. is_ground_content = false,
  60. walkable = false,
  61. sunlight_propagates = true,
  62. selection_box = {
  63. type = "fixed",
  64. fixed = { -16/32, -16/32, -7/32, 16/32, -12/32, 7/32 }
  65. },
  66. node_box = {
  67. type = "fixed",
  68. -- ±0.001 is to prevent z-fighting
  69. fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 }
  70. },
  71. groups = {dig_immediate = 3},
  72. sounds = default.node_sound_defaults(),
  73. mesecons = {conductor = {
  74. state = mesecon.state.off,
  75. onstate = "mesecons_insulated:insulated_on",
  76. rules = insulated_wire_get_rules
  77. }},
  78. on_blast = mesecon.on_blastnode,
  79. on_rotate = screwdriver_exists and screwdriver.rotate_simple,
  80. })
  81. minetest.register_craft({
  82. output = "mesecons_insulated:insulated_off 3",
  83. recipe = {
  84. {"mesecons_materials:fiber", "mesecons_materials:fiber", "mesecons_materials:fiber"},
  85. {"mesecons:wire_00000000_off", "mesecons:wire_00000000_off", "mesecons:wire_00000000_off"},
  86. {"mesecons_materials:fiber", "mesecons_materials:fiber", "mesecons_materials:fiber"},
  87. }
  88. })