I already talked about this in the Mineclone 2 topic, but currently the daylight sensors are broken because they don't change once they are active. However, I forgot to mention this here as well, and in the time in between I improved my solution to this problem. The way to solve the problem is basically the same, but my check if an inverted or normal daylight sensor should switch on and off had a small error, I used the number 13 instead of 14. Anyway, here is my modified code that gets it working again.
Edit the file /path/to/your/minetest/folder/games/mineclone5/ITEMS/REDSTONE/mesecons_solarpanel/init.lua and replace the register_abm functions (there should be 4 of them in groups of 2).
Here is my improved code for the normal daylight sensor:
Code: Select all
minetest.register_abm({
label = "Daylight turns on solar panels",
nodenames = {"mesecons_solarpanel:solar_panel_off"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.get_node_light(pos, nil)
local time = minetest.get_us_time()
if light >= 14 and time > 6000 then
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
mesecon.receptor_on(pos, mesecon.rules.pplate)
--else
-- minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
-- mesecon.receptor_off(pos, mesecon.rules.pplate)
end
end,
})
minetest.register_abm({
label = "Darkness turns off solar panels",
nodenames = {"mesecons_solarpanel:solar_panel_on"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.get_node_light(pos, nil)
local time = minetest.get_us_time()
if light < 14 and time > 18000 then
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
mesecon.receptor_off(pos, mesecon.rules.pplate)
end
end,
})
And the code for the inverted daylightsensor:
Code: Select all
minetest.register_abm({
label = "Darkness turns on inverted solar panels",
nodenames = {"mesecons_solarpanel:solar_panel_inverted_off"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.get_node_light(pos, nil)
local time = minetest.get_us_time()
if light < 14 and time > 18000 then
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_on", param2=node.param2})
mesecon.receptor_on(pos, mesecon.rules.pplate)
end
end,
})
minetest.register_abm({
label = "Daylight turns off inverted solar panels",
nodenames = {"mesecons_solarpanel:solar_panel_inverted_on"},
interval = 1,
chance = 1,
action = function(pos, node, active_object_count, active_object_count_wider)
local light = minetest.get_node_light(pos, nil)
local time = minetest.get_us_time()
if light >= 14 and time > 6000 then
minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_off", param2=node.param2})
mesecon.receptor_off(pos, mesecon.rules.pplate)
end
end,
})
I hope it is not too hard to understand (I am not good at describing things like this...)