crossover.lua 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. local function crossover_get_rules(node)
  2. return {
  3. {--first wire
  4. {x=-1,y=0,z=0},
  5. {x=1,y=0,z=0},
  6. },
  7. {--second wire
  8. {x=0,y=0,z=-1},
  9. {x=0,y=0,z=1},
  10. },
  11. }
  12. end
  13. local crossover_states = {
  14. "mesecons_extrawires:crossover_off",
  15. "mesecons_extrawires:crossover_01",
  16. "mesecons_extrawires:crossover_10",
  17. "mesecons_extrawires:crossover_on",
  18. }
  19. minetest.register_node("mesecons_extrawires:crossover_off", {
  20. description = "Insulated Mesecon Crossover",
  21. drawtype = "mesh",
  22. mesh = "mesecons_extrawires_crossover.b3d",
  23. tiles = {
  24. "jeija_insulated_wire_ends_off.png",
  25. "jeija_insulated_wire_sides_off.png",
  26. "jeija_insulated_wire_sides_off.png",
  27. "jeija_insulated_wire_ends_off.png"
  28. },
  29. paramtype = "light",
  30. is_ground_content = false,
  31. walkable = false,
  32. stack_max = 99,
  33. selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
  34. groups = {dig_immediate=3, mesecon=3},
  35. mesecons = {
  36. conductor = {
  37. states = crossover_states,
  38. rules = crossover_get_rules(),
  39. }
  40. },
  41. on_blast = mesecon.on_blastnode,
  42. })
  43. minetest.register_node("mesecons_extrawires:crossover_01", {
  44. description = "You hacker you!",
  45. drop = "mesecons_extrawires:crossover_off",
  46. drawtype = "mesh",
  47. mesh = "mesecons_extrawires_crossover.b3d",
  48. tiles = {
  49. "jeija_insulated_wire_ends_on.png",
  50. "jeija_insulated_wire_sides_on.png",
  51. "jeija_insulated_wire_sides_off.png",
  52. "jeija_insulated_wire_ends_off.png"
  53. },
  54. paramtype = "light",
  55. is_ground_content = false,
  56. walkable = false,
  57. stack_max = 99,
  58. selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
  59. groups = {dig_immediate=3, mesecon=3, not_in_creative_inventory=1},
  60. mesecons = {
  61. conductor = {
  62. states = crossover_states,
  63. rules = crossover_get_rules(),
  64. }
  65. },
  66. on_blast = mesecon.on_blastnode,
  67. })
  68. minetest.register_node("mesecons_extrawires:crossover_10", {
  69. description = "You hacker you!",
  70. drop = "mesecons_extrawires:crossover_off",
  71. drawtype = "mesh",
  72. mesh = "mesecons_extrawires_crossover.b3d",
  73. tiles = {
  74. "jeija_insulated_wire_ends_off.png",
  75. "jeija_insulated_wire_sides_off.png",
  76. "jeija_insulated_wire_sides_on.png",
  77. "jeija_insulated_wire_ends_on.png"
  78. },
  79. paramtype = "light",
  80. is_ground_content = false,
  81. walkable = false,
  82. stack_max = 99,
  83. selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
  84. groups = {dig_immediate=3, mesecon=3, not_in_creative_inventory=1},
  85. mesecons = {
  86. conductor = {
  87. states = crossover_states,
  88. rules = crossover_get_rules(),
  89. }
  90. },
  91. on_blast = mesecon.on_blastnode,
  92. })
  93. minetest.register_node("mesecons_extrawires:crossover_on", {
  94. description = "You hacker you!",
  95. drop = "mesecons_extrawires:crossover_off",
  96. drawtype = "mesh",
  97. mesh = "mesecons_extrawires_crossover.b3d",
  98. tiles = {
  99. "jeija_insulated_wire_ends_on.png",
  100. "jeija_insulated_wire_sides_on.png",
  101. "jeija_insulated_wire_sides_on.png",
  102. "jeija_insulated_wire_ends_on.png"
  103. },
  104. paramtype = "light",
  105. is_ground_content = false,
  106. walkable = false,
  107. stack_max = 99,
  108. selection_box = {type="fixed", fixed={-16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001}},
  109. groups = {dig_immediate=3, mesecon=3, not_in_creative_inventory=1},
  110. mesecons = {
  111. conductor = {
  112. states = crossover_states,
  113. rules = crossover_get_rules(),
  114. }
  115. },
  116. on_blast = mesecon.on_blastnode,
  117. })
  118. minetest.register_craft({
  119. type = "shapeless",
  120. output = "mesecons_extrawires:crossover_off",
  121. recipe = {
  122. "mesecons_insulated:insulated_off",
  123. "mesecons_insulated:insulated_off",
  124. },
  125. })
  126. minetest.register_craft({
  127. type = "shapeless",
  128. output = "mesecons_insulated:insulated_off 2",
  129. recipe = {
  130. "mesecons_extrawires:crossover_off",
  131. },
  132. })