From ce47073b69ba79637d2d5b17393fadeaf2acf51e Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Sat, 11 Aug 2018 18:36:15 +0300 Subject: [PATCH] Some timers changes --- elepower_farming/nodes/harvester.lua | 4 +- elepower_farming/nodes/planter.lua | 3 +- elepower_farming/nodes/spawner.lua | 4 +- .../machines/bases/generator.lua | 1 + elepower_machines/machines/lava_cooler.lua | 4 +- elepower_papi/formspec.lua | 4 +- elepower_papi/machine.lua | 37 ++++++++---------- .../textures/elepower_gui_mese_mask.png | Bin 0 -> 240 bytes 8 files changed, 31 insertions(+), 26 deletions(-) create mode 100644 elepower_papi/textures/elepower_gui_mese_mask.png diff --git a/elepower_farming/nodes/harvester.lua b/elepower_farming/nodes/harvester.lua index 75894f5..d84e20c 100644 --- a/elepower_farming/nodes/harvester.lua +++ b/elepower_farming/nodes/harvester.lua @@ -113,6 +113,8 @@ local function on_timer(pos, elapsed) local is_enabled = ele.helpers.state_enabled(meta, pos, state) local active = "Idle" + local power = {capacity = capacity, storage = storage, usage = 0} + if storage > usage and sludge.amount + SLUDGE_PRODUCED < sludge.capacity and is_enabled then if work == HARVESTER_TICK then local harvested = {} @@ -136,6 +138,7 @@ local function on_timer(pos, elapsed) active = "Active" refresh = true + power.usage = usage ele.helpers.swap_node(pos, "elepower_farming:harvester_active") else if not is_enabled then @@ -145,7 +148,6 @@ local function on_timer(pos, elapsed) ele.helpers.swap_node(pos, "elepower_farming:harvester") end - local power = {capacity = capacity, storage = storage, usage = usage} local work_percent = math.floor((work / HARVESTER_TICK)*100) meta:set_string("formspec", get_formspec(work_percent, power, sludge, state)) diff --git a/elepower_farming/nodes/planter.lua b/elepower_farming/nodes/planter.lua index 72ca97a..dbadd12 100644 --- a/elepower_farming/nodes/planter.lua +++ b/elepower_farming/nodes/planter.lua @@ -234,6 +234,7 @@ local function on_timer(pos, elapsed) local state = meta:get_int("state") local is_enabled = ele.helpers.state_enabled(meta, pos, state) + local power = {capacity = capacity, storage = storage, usage = 0} local active = "Idle" if storage > usage and is_enabled then @@ -256,11 +257,11 @@ local function on_timer(pos, elapsed) active = "Active" refresh = true + power.usage = usage elseif not is_enabled then active = "Off" end - local power = {capacity = capacity, storage = storage, usage = usage} local work_percent = math.floor((work / PLANTER_TICK)*100) meta:set_string("formspec", get_formspec(work_percent, power, state)) diff --git a/elepower_farming/nodes/spawner.lua b/elepower_farming/nodes/spawner.lua index fb1412b..da21f1e 100644 --- a/elepower_farming/nodes/spawner.lua +++ b/elepower_farming/nodes/spawner.lua @@ -126,6 +126,8 @@ local function on_timer(pos, elapsed) local mob_desc = "None" local active = "Active" + local power = {capacity = capacity, storage = storage, usage = 0} + if storage > usage and not egg_slot:is_empty() and ele.helpers.get_item_group(egg_name, "spawn_egg") and is_enabled then local mob_name = egg_name:gsub("_set", "") @@ -147,6 +149,7 @@ local function on_timer(pos, elapsed) refresh = true mob_desc = minetest.registered_items[mob_name].description + power.usage = usage elseif not is_enabled then active = "Off" else @@ -157,7 +160,6 @@ local function on_timer(pos, elapsed) meta:set_string("infotext", ("Powered Mob Spawner %s\nMob: %s\n%s"):format( active, mob_desc, ele.capacity_text(capacity, storage))) - local power = {capacity = capacity, storage = storage, usage = usage} local work_percent = math.floor((work / SPAWNER_TICK)*100) meta:set_string("formspec", get_formspec(work_percent, power, state)) diff --git a/elepower_machines/machines/bases/generator.lua b/elepower_machines/machines/bases/generator.lua index da1dc0c..bb5d349 100644 --- a/elepower_machines/machines/bases/generator.lua +++ b/elepower_machines/machines/bases/generator.lua @@ -65,6 +65,7 @@ function elepm.register_fuel_generator(nodename, nodedef) storage = storage + generation pow_buffer.storage = storage + pow_buffer.usage = generation meta:set_int("storage", storage) burn_time = burn_time - 1 diff --git a/elepower_machines/machines/lava_cooler.lua b/elepower_machines/machines/lava_cooler.lua index 2b66bef..e881e75 100644 --- a/elepower_machines/machines/lava_cooler.lua +++ b/elepower_machines/machines/lava_cooler.lua @@ -72,6 +72,8 @@ local function lava_cooler_timer(pos, elapsed) local state = meta:get_int("state") local is_enabled = ele.helpers.state_enabled(meta, pos, state) + local power = {capacity = capacity, storage = storage, usage = 0} + if storage > usage and is_enabled then if coolant_buffer.amount >= 1000 and hot_buffer.amount >= 1000 then if time >= TIME then @@ -98,6 +100,7 @@ local function lava_cooler_timer(pos, elapsed) else time = time + 1 storage = storage - usage + power.usage = usage refresh = true end else @@ -110,7 +113,6 @@ local function lava_cooler_timer(pos, elapsed) active = "Idle" end - local power = {capacity = capacity, storage = storage} local timer = math.floor(100 * time / TIME) meta:set_int("src_time", time) diff --git a/elepower_papi/formspec.lua b/elepower_papi/formspec.lua index 3f8d6dc..bc2bd3c 100644 --- a/elepower_papi/formspec.lua +++ b/elepower_papi/formspec.lua @@ -4,8 +4,8 @@ ele.formspec = {} ele.formspec.gui_switcher_icons = { [0] = "elepower_gui_check.png", "elepower_gui_cancel.png", - "mesecons_wire_on.png", - "mesecons_wire_off.png", + "mesecons_wire_on.png^elepower_gui_mese_mask.png^\\[makealpha\\:255,0,0", + "mesecons_wire_off.png^elepower_gui_mese_mask.png^\\[makealpha\\:255,0,0", } function ele.formspec.state_switcher(x, y, state) diff --git a/elepower_papi/machine.lua b/elepower_papi/machine.lua index f59c194..b9a58a3 100644 --- a/elepower_papi/machine.lua +++ b/elepower_papi/machine.lua @@ -173,27 +173,24 @@ local tubelib_tube = { end, } -local mesecons_def = {} -if mc then - mesecons_def = { - effector = { - action_on = function (pos, node) - local meta = minetest.get_meta(pos) - meta:set_int("signal_interrupt", 1) - end, - action_off = function (pos, node) - local meta = minetest.get_meta(pos) - meta:set_int("signal_interrupt", 0) - end, - action_change = function (pos, node) - local t = minetest.get_node_timer(pos) - if not t:is_started() then - t:start(1.0) - end - end, - } +local mesecons_def = { + effector = { + action_on = function (pos, node) + local meta = minetest.get_meta(pos) + meta:set_int("signal_interrupt", 1) + end, + action_off = function (pos, node) + local meta = minetest.get_meta(pos) + meta:set_int("signal_interrupt", 0) + end, + action_change = function (pos, node) + local t = minetest.get_node_timer(pos) + if not t:is_started() then + t:start(1.0) + end + end, } -end +} -- Functions diff --git a/elepower_papi/textures/elepower_gui_mese_mask.png b/elepower_papi/textures/elepower_gui_mese_mask.png new file mode 100644 index 0000000000000000000000000000000000000000..d45b43f9f8a16265c1e494ee614c7f634bd9bf33 GIT binary patch literal 240 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)2&&u)5(ej@)Wnk16ovB4 zk_-iRPv3y>Mm}+%q6kkH#}JFtXD3?=F(`64AKv|c?$%8=A3ne2;pyZdvr$!-w~NQ* zWF7aMhh8n`p82$_d%NPiZyNveX9sQMq^>zL-If3ObYkPx4bqB2oxe&>%rw^89jY^X b-e