From c02dce924892a069a692037ed9b278103e50d853 Mon Sep 17 00:00:00 2001 From: PreLeyZero Date: Mon, 30 May 2022 00:42:17 +0200 Subject: [PATCH] bugfix for power outage on KI core --- changelog.txt | 6 ++++++ scripts/electronic/el_ki_script.lua | 21 +++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/changelog.txt b/changelog.txt index 7b2effe..2a39b11 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,9 @@ +--------------------------------------------------------------------------------------------------- +Version: 1.0.25 +Date: ??.??.???? + Bugfixes: + - fixed bug where KI core would still transmit modules when power was cut + --------------------------------------------------------------------------------------------------- Version: 1.0.24 Date: 27.5.2022 diff --git a/scripts/electronic/el_ki_script.lua b/scripts/electronic/el_ki_script.lua index 8802e4b..5439a93 100644 --- a/scripts/electronic/el_ki_script.lua +++ b/scripts/electronic/el_ki_script.lua @@ -419,6 +419,13 @@ function el_ki_core_working() local oldactive = global.ki.core[i].active global.ki.core[i].active = global.ki.core[i].entity.is_crafting() + if global.ki.core[i].active then + if global.ki.core[i].entity.energy < global.ki.core[i].entity.prototype.energy_usage then + global.ki.core[i].active = false + global.ki.dirty = true + end + end + if not oldactive == global.ki.core[i].active then global.ki.dirty = true end @@ -432,6 +439,13 @@ function el_ki_buffer1_working() local oldactive = global.ki.buffer1[i].active global.ki.buffer1[i].active = global.ki.buffer1[i].entity.is_crafting() + if global.ki.buffer1[i].active then + if global.ki.buffer1[i].entity.energy < global.ki.buffer1[i].entity.prototype.energy_usage then + global.ki.buffer1[i].active = false + global.ki.dirty = true + end + end + if not oldactive == global.ki.buffer1[i].active then global.ki.dirty = true end @@ -457,6 +471,13 @@ function el_ki_buffer2_working() local oldactive = global.ki.buffer2[i].active global.ki.buffer2[i].active = global.ki.buffer2[i].entity.is_crafting() + if global.ki.buffer2[i].active then + if global.ki.buffer2[i].entity.energy < global.ki.buffer2[i].entity.prototype.energy_usage then + global.ki.buffer2[i].active = false + global.ki.dirty = true + end + end + if not oldactive == global.ki.buffer2[i].active then global.ki.dirty = true end