corner.lua 2.5 KB

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