From 086594e24c14282a47d72ca91f6b562af2a3a23b Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Tue, 6 Jul 2021 21:37:29 +0200 Subject: [PATCH] Adapt to networks v0.08 --- basic_machines/source.lua | 2 +- coal_power_station/generator.lua | 2 +- energy_storage/heatexchanger2.lua | 2 +- hydrogen/fuelcell.lua | 2 +- init.lua | 3 +++ solar/inverter.lua | 2 +- steam_engine/flywheel.lua | 2 +- ta2_energy_storage/ta2_winch.lua | 2 +- ta3_power/akkubox.lua | 2 +- ta3_power/axle2power.lua | 2 +- ta3_power/power2axle.lua | 2 +- ta3_power/tiny_generator.lua | 2 +- ta4_power/electricmeter.lua | 9 ++++++--- ta4_power/transformer.lua | 2 +- wind_turbine/rotor.lua | 2 +- 15 files changed, 22 insertions(+), 16 deletions(-) diff --git a/basic_machines/source.lua b/basic_machines/source.lua index 2a67c49..14eefa2 100644 --- a/basic_machines/source.lua +++ b/basic_machines/source.lua @@ -175,7 +175,7 @@ local function after_dig_node3(pos, oldnode) techage.del_mem(pos) end -local function get_generator_data(pos, tlib2) +local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) if nvm.running then return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} diff --git a/coal_power_station/generator.lua b/coal_power_station/generator.lua index c8c1733..fc875ef 100644 --- a/coal_power_station/generator.lua +++ b/coal_power_station/generator.lua @@ -127,7 +127,7 @@ local function after_dig_node(pos, oldnode) techage.del_mem(pos) end -local function get_generator_data(pos, tlib2) +local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) if techage.is_running(nvm) then return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} diff --git a/energy_storage/heatexchanger2.lua b/energy_storage/heatexchanger2.lua index 62e4179..eb09337 100644 --- a/energy_storage/heatexchanger2.lua +++ b/energy_storage/heatexchanger2.lua @@ -227,7 +227,7 @@ local function on_receive_fields(pos, formname, fields, player) M(pos):set_string("formspec", formspec(State, pos, nvm)) end -local function get_storage_data(pos, tlib2) +local function get_storage_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) nvm.capa_max = nvm.capa_max or 1 if techage.is_running(nvm) then diff --git a/hydrogen/fuelcell.lua b/hydrogen/fuelcell.lua index 5380052..f30209d 100644 --- a/hydrogen/fuelcell.lua +++ b/hydrogen/fuelcell.lua @@ -164,7 +164,7 @@ local function after_dig_node(pos, oldnode, oldmetadata, digger) Cable:after_dig_node(pos) end -local function get_generator_data(pos, tlib2) +local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) if techage.is_running(nvm) then return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} diff --git a/init.lua b/init.lua index f9d85d9..f8a7b60 100644 --- a/init.lua +++ b/init.lua @@ -36,6 +36,9 @@ elseif minetest.global_exists("lcdlib") and lcdlib.version < 1.0 then elseif minetest.global_exists("safer_lua") and safer_lua.version < 1.0 then minetest.log("error", "[techage] Techage requires safer_lua version 1.0 or newer!") return +elseif minetest.global_exists("networks") and networks.version < 0.08 then + minetest.log("error", "[techage] Techage requires networks version 0.08 or newer!") + return end -- Test MT 5.4 new string mode diff --git a/solar/inverter.lua b/solar/inverter.lua index 8d91155..2d52b76 100644 --- a/solar/inverter.lua +++ b/solar/inverter.lua @@ -158,7 +158,7 @@ local function on_rightclick(pos, node, clicker) M(pos):set_string("formspec", formspec(State, pos, nvm)) end -local function get_generator_data(pos, tlib2) +local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) if techage.is_running(nvm) then return {level = (nvm.load or 0) / nvm.max_power, perf = nvm.max_power, capa = nvm.max_power * 2} diff --git a/steam_engine/flywheel.lua b/steam_engine/flywheel.lua index 4dce526..30b6937 100644 --- a/steam_engine/flywheel.lua +++ b/steam_engine/flywheel.lua @@ -121,7 +121,7 @@ local function after_dig_node(pos, oldnode) techage.del_mem(pos) end -local function get_generator_data(pos, tlib2) +local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) if techage.is_running(nvm) then return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 4} diff --git a/ta2_energy_storage/ta2_winch.lua b/ta2_energy_storage/ta2_winch.lua index d21b2f1..d246a4b 100644 --- a/ta2_energy_storage/ta2_winch.lua +++ b/ta2_energy_storage/ta2_winch.lua @@ -158,7 +158,7 @@ minetest.register_node("techage:ta2_winch", { techage.del_mem(pos) end, - get_storage_data = function(pos, tlib2) + get_storage_data = function(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) nvm.capa = nvm.capa or 1 if nvm.running then diff --git a/ta3_power/akkubox.lua b/ta3_power/akkubox.lua index c4899e5..debf025 100644 --- a/ta3_power/akkubox.lua +++ b/ta3_power/akkubox.lua @@ -87,7 +87,7 @@ local function on_receive_fields(pos, formname, fields, player) M(pos):set_string("formspec", formspec(State, pos, nvm)) end -local function get_storage_data(pos, tlib2) +local function get_storage_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) if nvm.running then return {level = (nvm.capa or 0) / PWR_CAPA, capa = PWR_CAPA} diff --git a/ta3_power/axle2power.lua b/ta3_power/axle2power.lua index 43f5839..4bc252b 100644 --- a/ta3_power/axle2power.lua +++ b/ta3_power/axle2power.lua @@ -72,7 +72,7 @@ local function node_timer_off(pos, elapsed) return true end -local function get_generator_data(pos, tlib2) +local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) if nvm.running then return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} diff --git a/ta3_power/power2axle.lua b/ta3_power/power2axle.lua index bab4f6a..13c7f4a 100644 --- a/ta3_power/power2axle.lua +++ b/ta3_power/power2axle.lua @@ -77,7 +77,7 @@ local function node_timer_off(pos, elapsed) return true end -local function get_generator_data(pos, tlib2) +local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) if nvm.running then return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} diff --git a/ta3_power/tiny_generator.lua b/ta3_power/tiny_generator.lua index 4322b13..8a21e6d 100644 --- a/ta3_power/tiny_generator.lua +++ b/ta3_power/tiny_generator.lua @@ -164,7 +164,7 @@ local function on_rightclick(pos, node, clicker) M(pos):set_string("formspec", formspec(State, pos, nvm)) end -local function get_generator_data(pos, tlib2) +local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) if nvm.running and techage.is_running(nvm) then return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} diff --git a/ta4_power/electricmeter.lua b/ta4_power/electricmeter.lua index bc8abec..8f5b769 100644 --- a/ta4_power/electricmeter.lua +++ b/ta4_power/electricmeter.lua @@ -112,10 +112,13 @@ local function after_dig_node(pos, oldnode, oldmetadata, digger) techage.del_mem(pos) end -local function get_generator_data(pos, tlib2) +local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) - if techage.is_running(nvm) then - return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} + -- check for secondary/generator side + if outdir == M(pos):get_int("outdir") then + if techage.is_running(nvm) then + return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} + end end end diff --git a/ta4_power/transformer.lua b/ta4_power/transformer.lua index 17bac03..bdb587c 100644 --- a/ta4_power/transformer.lua +++ b/ta4_power/transformer.lua @@ -110,7 +110,7 @@ local function after_dig_node(pos, oldnode, oldmetadata, digger) techage.del_mem(pos) end -local function get_generator_data(pos, tlib2) +local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) if techage.is_running(nvm) then return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2} diff --git a/wind_turbine/rotor.lua b/wind_turbine/rotor.lua index cad3c49..0620316 100644 --- a/wind_turbine/rotor.lua +++ b/wind_turbine/rotor.lua @@ -174,7 +174,7 @@ local function on_receive_fields(pos, formname, fields, player) M(pos):set_string("formspec", formspec(State, pos, nvm)) end -local function get_generator_data(pos, tlib2) +local function get_generator_data(pos, outdir, tlib2) local nvm = techage.get_nvm(pos) if techage.is_running(nvm) then return {level = (nvm.load or 0) / PWR_PERF, perf = PWR_PERF, capa = PWR_PERF * 2}