init.lua 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. -- Solar Panel
  2. minetest.register_node("mesecons_solarpanel:solar_panel_on", {
  3. drawtype = "nodebox",
  4. tiles = { "jeija_solar_panel.png", },
  5. inventory_image = "jeija_solar_panel.png",
  6. wield_image = "jeija_solar_panel.png",
  7. paramtype = "light",
  8. paramtype2 = "wallmounted",
  9. walkable = false,
  10. is_ground_content = false,
  11. node_box = {
  12. type = "wallmounted",
  13. wall_bottom = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
  14. wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
  15. wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
  16. },
  17. selection_box = {
  18. type = "wallmounted",
  19. wall_bottom = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
  20. wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
  21. wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
  22. },
  23. drop = "mesecons_solarpanel:solar_panel_off",
  24. groups = {dig_immediate=3, not_in_creative_inventory = 1},
  25. sounds = default.node_sound_glass_defaults(),
  26. mesecons = {receptor = {
  27. state = mesecon.state.on,
  28. rules = mesecon.rules.wallmounted_get,
  29. }},
  30. on_blast = mesecon.on_blastnode,
  31. })
  32. -- Solar Panel
  33. minetest.register_node("mesecons_solarpanel:solar_panel_off", {
  34. drawtype = "nodebox",
  35. tiles = { "jeija_solar_panel.png", },
  36. inventory_image = "jeija_solar_panel.png",
  37. wield_image = "jeija_solar_panel.png",
  38. paramtype = "light",
  39. paramtype2 = "wallmounted",
  40. walkable = false,
  41. is_ground_content = false,
  42. node_box = {
  43. type = "wallmounted",
  44. wall_bottom = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
  45. wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
  46. wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
  47. },
  48. selection_box = {
  49. type = "wallmounted",
  50. wall_bottom = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
  51. wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
  52. wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
  53. },
  54. groups = {dig_immediate=3},
  55. description = "Solar Panel",
  56. sounds = default.node_sound_glass_defaults(),
  57. mesecons = {receptor = {
  58. state = mesecon.state.off,
  59. rules = mesecon.rules.wallmounted_get,
  60. }},
  61. on_blast = mesecon.on_blastnode,
  62. })
  63. minetest.register_craft({
  64. output = "mesecons_solarpanel:solar_panel_off 1",
  65. recipe = {
  66. {"mesecons_materials:silicon", "mesecons_materials:silicon"},
  67. {"mesecons_materials:silicon", "mesecons_materials:silicon"},
  68. }
  69. })
  70. minetest.register_abm(
  71. {nodenames = {"mesecons_solarpanel:solar_panel_off"},
  72. interval = 1,
  73. chance = 1,
  74. action = function(pos, node, active_object_count, active_object_count_wider)
  75. local light = minetest.get_node_light(pos, nil)
  76. if light >= 12 then
  77. node.name = "mesecons_solarpanel:solar_panel_on"
  78. minetest.swap_node(pos, node)
  79. mesecon.receptor_on(pos, mesecon.rules.wallmounted_get(node))
  80. end
  81. end,
  82. })
  83. minetest.register_abm(
  84. {nodenames = {"mesecons_solarpanel:solar_panel_on"},
  85. interval = 1,
  86. chance = 1,
  87. action = function(pos, node, active_object_count, active_object_count_wider)
  88. local light = minetest.get_node_light(pos, nil)
  89. if light < 12 then
  90. node.name = "mesecons_solarpanel:solar_panel_off"
  91. minetest.swap_node(pos, node)
  92. mesecon.receptor_off(pos, mesecon.rules.wallmounted_get(node))
  93. end
  94. end,
  95. })