From 9a83fab1b6d730e460c0e793dec996013bf7b86b Mon Sep 17 00:00:00 2001 From: chmodsayshello Date: Mon, 20 Dec 2021 16:54:49 +0000 Subject: [PATCH] Edited version of the daylightsensorfix This is the edited version of my fix for the daylightsensor --- .../REDSTONE/mesecons_solarpanel/init.lua | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua index b256d87e..ebffd4a5 100644 --- a/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_solarpanel/init.lua @@ -96,8 +96,8 @@ minetest.register_abm({ chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local light = minetest.get_node_light(pos, nil) - - if light >= 12 and minetest.get_timeofday() > 0.2 and minetest.get_timeofday() < 0.8 then + local time = minetest.get_timeofday()*24000 + if light >= minetest.LIGHT_MAX and time > 6000 and time < 18000 then minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2}) mesecon.receptor_on(pos, mesecon.rules.pplate) end @@ -111,10 +111,16 @@ minetest.register_abm({ 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_timeofday()*24000 - if light < 12 then + if light <= minetest.LIGHT_MAX and time > 18000 then minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2}) mesecon.receptor_off(pos, mesecon.rules.pplate) + else + if light <= minetest.LIGHT_MAX and time < 6000 then + minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2}) + mesecon.receptor_off(pos, mesecon.rules.pplate) + end end end, }) @@ -203,10 +209,16 @@ minetest.register_abm({ chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) local light = minetest.get_node_light(pos, nil) - - if light < 12 then + local time = minetest.get_timeofday()*24000 + + if light < minetest.LIGHT_MAX 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) + else + if light <= minetest.LIGHT_MAX and time < 6000 then + minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_on", param2=node.param2}) + mesecon.receptor_on(pos, mesecon.rules.pplate) + end end end, }) @@ -218,8 +230,9 @@ minetest.register_abm({ 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_timeofday()*24000 - if light >= 12 and minetest.get_timeofday() > 0.8 and minetest.get_timeofday() < 0.2 then + if light >= minetest.LIGHT_MAX and time > 6000 and time < 18000 then minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_off", param2=node.param2}) mesecon.receptor_off(pos, mesecon.rules.pplate) end