tjunction.lua 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. local tjunction_nodebox = {
  2. type = "fixed",
  3. fixed = {{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
  4. { -3/32, -17/32, -16/32+0.001, 3/32, -13/32, -3/32},}
  5. }
  6. local tjunction_selectionbox = {
  7. type = "fixed",
  8. fixed = { -16/32-0.001, -18/32, -16/32, 16/32+0.001, -12/32, 7/32 },
  9. }
  10. local tjunction_get_rules = function (node)
  11. local rules =
  12. {{x = 0, y = 0, z = 1},
  13. {x = 1, y = 0, z = 0},
  14. {x = 0, y = 0, z = -1}}
  15. for i = 0, node.param2 do
  16. rules = mesecon.rotate_rules_left(rules)
  17. end
  18. return rules
  19. end
  20. minetest.register_node("mesecons_extrawires:tjunction_on", {
  21. drawtype = "nodebox",
  22. tiles = {
  23. "jeija_insulated_wire_tjunction_tb_on.png",
  24. "jeija_insulated_wire_tjunction_tb_on.png^[transformR180",
  25. "jeija_insulated_wire_ends_on.png",
  26. "jeija_insulated_wire_ends_on.png",
  27. "jeija_insulated_wire_sides_on.png",
  28. "jeija_insulated_wire_ends_on.png"
  29. },
  30. paramtype = "light",
  31. paramtype2 = "facedir",
  32. walkable = false,
  33. sunlight_propagates = true,
  34. selection_box = tjunction_selectionbox,
  35. node_box = tjunction_nodebox,
  36. groups = {dig_immediate = 3, not_in_creative_inventory = 1},
  37. drop = "mesecons_extrawires:tjunction_off",
  38. mesecons = {conductor =
  39. {
  40. state = mesecon.state.on,
  41. rules = tjunction_get_rules,
  42. offstate = "mesecons_extrawires:tjunction_off"
  43. }}
  44. })
  45. minetest.register_node("mesecons_extrawires:tjunction_off", {
  46. drawtype = "nodebox",
  47. description = "T-junction",
  48. tiles = {
  49. "jeija_insulated_wire_tjunction_tb_off.png",
  50. "jeija_insulated_wire_tjunction_tb_off.png^[transformR180",
  51. "jeija_insulated_wire_ends_off.png",
  52. "jeija_insulated_wire_ends_off.png",
  53. "jeija_insulated_wire_sides_off.png",
  54. "jeija_insulated_wire_ends_off.png"
  55. },
  56. paramtype = "light",
  57. paramtype2 = "facedir",
  58. walkable = false,
  59. sunlight_propagates = true,
  60. selection_box = tjunction_selectionbox,
  61. node_box = tjunction_nodebox,
  62. groups = {dig_immediate = 3},
  63. mesecons = {conductor =
  64. {
  65. state = mesecon.state.off,
  66. rules = tjunction_get_rules,
  67. onstate = "mesecons_extrawires:tjunction_on"
  68. }}
  69. })
  70. minetest.register_craft({
  71. output = "mesecons_extrawires:tjunction_off 3",
  72. recipe = {
  73. {"", "", ""},
  74. {"mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off"},
  75. {"", "mesecons_insulated:insulated_off", ""},
  76. }
  77. })