Some timers changes

This commit is contained in:
Evert Prants 2018-08-11 18:36:15 +03:00
parent 674703f31e
commit ce47073b69
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
8 changed files with 31 additions and 26 deletions

View File

@ -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))

View File

@ -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))

View File

@ -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))

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -173,9 +173,7 @@ local tubelib_tube = {
end,
}
local mesecons_def = {}
if mc then
mesecons_def = {
local mesecons_def = {
effector = {
action_on = function (pos, node)
local meta = minetest.get_meta(pos)
@ -193,7 +191,6 @@ if mc then
end,
}
}
end
-- Functions

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B