From 4d30ba4bef28ce3cfb0846f9da338cf164b1780e Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Wed, 21 Aug 2019 21:52:11 +0200 Subject: [PATCH] bugfixes and improvements --- basic_machines/electronic_fab.lua | 14 ++++++--- coal_power_station/power_terminal.lua | 41 +++++++++++++------------- furnace/cooking.lua | 1 + furnace/furnace_top.lua | 7 ++++- power/power.lua | 5 ++-- solar/minicell.lua | 13 ++++---- textures/techage_form_arrow_bg.png | Bin 0 -> 201 bytes textures/techage_form_arrow_fg.png | Bin 0 -> 201 bytes tools/repairkit.lua | 4 +++ 9 files changed, 51 insertions(+), 34 deletions(-) create mode 100644 textures/techage_form_arrow_bg.png create mode 100644 textures/techage_form_arrow_fg.png diff --git a/basic_machines/electronic_fab.lua b/basic_machines/electronic_fab.lua index 0276a00..ddbeb99 100644 --- a/basic_machines/electronic_fab.lua +++ b/basic_machines/electronic_fab.lua @@ -288,21 +288,27 @@ minetest.register_craftitem("techage:wlanchip", { if minetest.global_exists("unified_inventory") then - unified_inventory.register_craft_type("electronic_fab", { - description = S("Electronic Fab"), + unified_inventory.register_craft_type("ta2_electronic_fab", { + description = S("TA2 Ele Fab"), icon = 'techage_filling_ta2.png^techage_appl_electronic_fab.png^techage_frame_ta2.png', width = 2, height = 2, }) + unified_inventory.register_craft_type("ta3_electronic_fab", { + description = S("TA3 Ele Fab"), + icon = 'techage_filling_ta3.png^techage_appl_electronic_fab.png^techage_frame_ta3.png', + width = 2, + height = 2, + }) unified_inventory.register_craft({ output = "techage:vacuum_tube 2", items = {"default:glass", "basic_materials:copper_wire", "basic_materials:plastic_sheet", "techage:usmium_nuggets"}, - type = "electronic_fab", + type = "ta2_electronic_fab", }) unified_inventory.register_craft({ output = "techage:ta4_wlanchip 8", items = {"default:mese_crystal", "default:copper_ingot", "default:gold_ingot", "techage:ta4_silicon_wafer"}, - type = "electronic_fab", + type = "ta3_electronic_fab", }) end diff --git a/coal_power_station/power_terminal.lua b/coal_power_station/power_terminal.lua index 0ed1414..59a6ad6 100644 --- a/coal_power_station/power_terminal.lua +++ b/coal_power_station/power_terminal.lua @@ -28,32 +28,33 @@ local Param2ToDir = { local function formspec(pos) local jpos = minetest.deserialize(M(pos):get_string("junction_pos")) - local ndef = minetest.registered_nodes[minetest.get_node(jpos).name] - if ndef.is_power_available then - local power = ndef.is_power_available(jpos) - if power and power.prim_available then - return "size[5,4]".. - default.gui_bg.. - default.gui_bg_img.. - default.gui_slots.. - "label[1.5,0.0;"..S("Network Data").."]".. - "label[0,0.8;"..S("Generators").." : "..power.prim_available.." ku]".. - "label[0,1.4;"..S("Akkus").." : "..power.sec_available.." ku]".. - "label[0,2.0;"..S("Machines").." : "..power.prim_needed.." ku]".. - "label[0,2.6;"..S("Number nodes").." : "..power.num_nodes.."]".. - "button[1.5,3.3;2,1;update;"..S("Update").."]" + local power = techage.power.power_accounting(jpos, tubelib2.get_mem(jpos)) + if power and power.prim_available then + local alarm = "" + if power.num_nodes > (techage.MAX_NUM_NODES - 50) then + alarm = " (max. "..(techage.MAX_NUM_NODES).." !!!)" end + return "size[5,4]".. + default.gui_bg.. + default.gui_bg_img.. + default.gui_slots.. + "label[1.5,0.0;"..S("Network Data").."]".. + "label[0,0.8;"..S("Generators").." : "..power.prim_available.." ku]".. + "label[0,1.4;"..S("Akkus").." : "..power.sec_available.." ku]".. + "label[0,2.0;"..S("Machines").." : "..power.prim_needed.." ku]".. + "label[0,2.6;"..S("Number nodes").." : "..power.num_nodes..alarm.."]".. + "button[1.5,3.3;2,1;update;"..S("Update").."]" end return "size[5,4]".. default.gui_bg.. default.gui_bg_img.. default.gui_slots.. - "label[1.5,0.0;"..S("Network Data").."]".. - "label[0,0.8;"..S("Generators").." : 0 ku]".. - "label[0,1.4;"..S("Akkus").." : 0 ku]".. - "label[0,2.0;"..S("Machines").." : 0 ku]".. - "label[0,2.6;"..S("Number nodes").." : 0]".. - "button[1.5,3.3;2,1;update;"..S("Update").."]" + "label[1.5,0.0;"..S("Network Data").."]".. + "label[0,0.8;"..S("Generators").." : 0 ku]".. + "label[0,1.4;"..S("Akkus").." : 0 ku]".. + "label[0,2.0;"..S("Machines").." : 0 ku]".. + "label[0,2.6;"..S("Number nodes").." : 0]".. + "button[1.5,3.3;2,1;update;"..S("Update").."]" end diff --git a/furnace/cooking.lua b/furnace/cooking.lua index 8a78c9f..486b5a9 100644 --- a/furnace/cooking.lua +++ b/furnace/cooking.lua @@ -119,6 +119,7 @@ function techage.furnace.smelting(pos, mem, elapsed) elapsed = elapsed - recipe.time end mem.leftover = elapsed + mem.item_percent = math.min(math.floor((mem.leftover * 100.0) / recipe.time), 100) return state end return techage.STANDBY diff --git a/furnace/furnace_top.lua b/furnace/furnace_top.lua index 23c9672..a2d342f 100644 --- a/furnace/furnace_top.lua +++ b/furnace/furnace_top.lua @@ -41,7 +41,8 @@ local function formspec(self, pos, mem) default.gui_bg_img.. default.gui_slots.. "list[context;src;0,0;2,2;]".. - "image[2,0.5;1,1;techage_form_arrow.png]".. + "image[2,0.5;1,1;techage_form_arrow_bg.png^[lowpart:".. + (mem.item_percent or 0)..":techage_form_arrow_fg.png^[transformR270]".. "image_button[2,2;1,1;".. self:get_state_button_image(mem) ..";state_button;]".. "list[context;dst;3,0;2,2;]".. @@ -95,6 +96,10 @@ local function keep_running(pos, elapsed) local mem = tubelib2.get_mem(pos) local crd = CRD(pos) cooking(pos, crd, mem, elapsed) + mem.toggle = not mem.toggle + if mem.toggle then + M(pos):set_string("formspec", formspec(crd.State, pos, mem)) + end return crd.State:is_active(mem) end diff --git a/power/power.lua b/power/power.lua index c8fbe9b..a3d8b6b 100644 --- a/power/power.lua +++ b/power/power.lua @@ -26,7 +26,8 @@ local NumNodes = 0 techage.power = {} -local MAX_NUM_NODES = 100 +local MAX_NUM_NODES = 1000 +techage.MAX_NUM_NODES = MAX_NUM_NODES -- Consumer States local STOPPED = 1 @@ -197,7 +198,7 @@ minetest.register_lbm({ local function pos_already_reached(pos) local key = minetest.hash_node_position(pos) - if not Route[key] then + if not Route[key] and NumNodes < MAX_NUM_NODES then Route[key] = true NumNodes = NumNodes + 1 return false diff --git a/solar/minicell.lua b/solar/minicell.lua index 18d20f1..4aee4be 100644 --- a/solar/minicell.lua +++ b/solar/minicell.lua @@ -34,7 +34,7 @@ local function node_timer(pos, elapsed) local mem = tubelib2.get_mem(pos) mem.capa = mem.capa or 0 pos.y = pos.y + 1 - local light = minetest.get_node_light(pos) + local light = minetest.get_node_light(pos) or 0 pos.y = pos.y - 1 if light >= (minetest.LIGHT_MAX - 1) then @@ -103,6 +103,7 @@ minetest.register_node("techage:ta4_solar_minicell", { techage.power.register_node({"techage:ta4_solar_minicell"}, { power_network = Cable, + conn_sides = {"D"}, }) techage.register_node({"techage:ta4_solar_minicell"}, { @@ -110,13 +111,11 @@ techage.register_node({"techage:ta4_solar_minicell"}, { local mem = tubelib2.get_mem(pos) if topic == "state" then if mem.providing then - if (mem.provided or 0) > 0 then - return "discharging" - else - return "unused" - end - else + return "discharging" + elseif (mem.capa or 0) > 0 then return "charging" + else + return "unused" end else return "unsupported" diff --git a/textures/techage_form_arrow_bg.png b/textures/techage_form_arrow_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..c900eeacf7ccabd9768a82a2372cd2dc5e159061 GIT binary patch literal 201 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaP3?%1DUd;wlEa{HEjtmSN`?>!lvI6;x#X;^) z4C~IxyaaMM3p^r=85p>QL70(Y)*O&_&H$efSD(y6Utiy(q@>@CS(zYhB|(0{3=Yq3 zqyafLo-U3d9M_W*8W`6x7%Vkq^;sLmr8F~aZ3%!lvI6;x#X;^) z4C~IxyaaMM1AIbUeKHFZI~I4Z+JErGvlftwk|4ie28U-i(m*N-JR*x37`TN&n2}-D z9FPSzo-U3d9M_W*8W`6x7%Vkq^;sLmr8F~aZ3%