init.lua 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 = true,
  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. }}
  29. })
  30. -- Solar Panel
  31. minetest.register_node("mesecons_solarpanel:solar_panel_off", {
  32. drawtype = "nodebox",
  33. tiles = { "jeija_solar_panel.png", },
  34. inventory_image = "jeija_solar_panel.png",
  35. wield_image = "jeija_solar_panel.png",
  36. paramtype = "light",
  37. paramtype2 = "wallmounted",
  38. walkable = false,
  39. is_ground_content = true,
  40. node_box = {
  41. type = "wallmounted",
  42. wall_bottom = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
  43. wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
  44. wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
  45. },
  46. selection_box = {
  47. type = "wallmounted",
  48. wall_bottom = { -7/16, -8/16, -7/16, 7/16, -7/16, 7/16 },
  49. wall_top = { -7/16, 7/16, -7/16, 7/16, 8/16, 7/16 },
  50. wall_side = { -8/16, -7/16, -7/16, -7/16, 7/16, 7/16 },
  51. },
  52. groups = {dig_immediate=3},
  53. description="Solar Panel",
  54. sounds = default.node_sound_glass_defaults(),
  55. mesecons = {receptor = {
  56. state = mesecon.state.off
  57. }}
  58. })
  59. minetest.register_craft({
  60. output = "mesecons_solarpanel:solar_panel_off 1",
  61. recipe = {
  62. {"mesecons_materials:silicon", "mesecons_materials:silicon"},
  63. {"mesecons_materials:silicon", "mesecons_materials:silicon"},
  64. }
  65. })
  66. minetest.register_abm(
  67. {nodenames = {"mesecons_solarpanel:solar_panel_off"},
  68. interval = 1,
  69. chance = 1,
  70. action = function(pos, node, active_object_count, active_object_count_wider)
  71. local light = minetest.get_node_light(pos, nil)
  72. if light >= 12 then
  73. minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
  74. mesecon.receptor_on(pos)
  75. end
  76. end,
  77. })
  78. minetest.register_abm(
  79. {nodenames = {"mesecons_solarpanel:solar_panel_on"},
  80. interval = 1,
  81. chance = 1,
  82. action = function(pos, node, active_object_count, active_object_count_wider)
  83. local light = minetest.get_node_light(pos, nil)
  84. if light < 12 then
  85. minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
  86. mesecon.receptor_off(pos)
  87. end
  88. end,
  89. })