From 0815c6b485a822458c37de1acbbf72b7c66b68af Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Tue, 31 Mar 2020 21:37:07 +0200 Subject: [PATCH] minicell bugfix --- energy_storage/heatexchanger2.lua | 4 +--- init.lua | 2 +- power/schedule.lua | 1 + solar/minicell.lua | 16 +++++++--------- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/energy_storage/heatexchanger2.lua b/energy_storage/heatexchanger2.lua index 22e70ba..b551fc2 100644 --- a/energy_storage/heatexchanger2.lua +++ b/energy_storage/heatexchanger2.lua @@ -117,10 +117,8 @@ local function after_place_node(pos, placer) return true end local nvm = techage.get_nvm(pos) - local own_num = techage.add_node(pos, "techage:heatexchanger2") - State:node_init(pos, nvm, own_num) + State:node_init(pos, nvm, "") M(pos):set_string("formspec", formspec(State, pos, nvm)) - M(pos):set_string("infotext", S("TA4 Heat Exchanger").." "..own_num) end local function on_receive_fields(pos, formname, fields, player) diff --git a/init.lua b/init.lua index 857172b..98f60bf 100644 --- a/init.lua +++ b/init.lua @@ -186,7 +186,7 @@ else -- Test dofile(MP.."/recipe_checker.lua") dofile(MP.."/.test/sink.lua") - dofile(MP.."/.test/meta_node.lua") + --dofile(MP.."/.test/meta_node.lua") -- Solar dofile(MP.."/solar/minicell.lua") diff --git a/power/schedule.lua b/power/schedule.lua index 03c3982..a7832cf 100644 --- a/power/schedule.lua +++ b/power/schedule.lua @@ -17,6 +17,7 @@ local P2P = minetest.string_to_pos local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end local M = minetest.get_meta local N = function(pos) return minetest.get_node(pos).name end +local HEX = function(val) return string.format("%XH", val) end local power = techage.power local networks = techage.networks diff --git a/solar/minicell.lua b/solar/minicell.lua index a4b72f5..795ba9e 100644 --- a/solar/minicell.lua +++ b/solar/minicell.lua @@ -19,12 +19,7 @@ local S = techage.S local CYCLE_TIME = 2 local PWR_PERF = 1 -local PWR_CAPA = 30 * 20 -- default day - -minetest.after(2, function() - -- calculate the capacity depending on the day duration - PWR_CAPA = math.max(minetest.get_gametime() / minetest.get_day_count() / 2, PWR_CAPA) -end) +local PWR_CAPA = 2400 -- ticks (2s) with 1 ku ==> 80 min = 4 game days local Cable = techage.ElectricCable local power = techage.power @@ -34,15 +29,18 @@ local function node_timer(pos, elapsed) nvm.capa = nvm.capa or 0 pos.y = pos.y + 1 local light = minetest.get_node_light(pos) or 0 + local t = minetest.get_timeofday() pos.y = pos.y - 1 - if light >= (minetest.LIGHT_MAX - 1) then + if t > 0.25 and t < 0.75 then if nvm.providing then power.generator_stop(pos, Cable, 5) nvm.providing = false nvm.provided = 0 end - nvm.capa = math.min(nvm.capa + PWR_PERF * 1.2, PWR_CAPA) + if light >= (minetest.LIGHT_MAX - 1) then + nvm.capa = math.min(nvm.capa + PWR_PERF * 1.2, PWR_CAPA) + end else if nvm.capa > 0 then if not nvm.providing then @@ -88,7 +86,7 @@ local net_def = { ele1 = { sides = {D = 1}, ntype = "gen1", - nominal = PWR_CAPA, + nominal = PWR_PERF, }, }