Heat exchanger fix

This commit is contained in:
Evert Prants 2019-02-09 11:20:31 +02:00
parent 9c481b6055
commit b12daa099a
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 15 additions and 6 deletions

View File

@ -22,6 +22,7 @@ ele.helpers.register_liquid("lithium", {
liquid_viscosity = 4,
damage_per_second = 1,
alpha = 200,
gas_form = "elepower_dynamics:lithium_gas",
post_effect_color = {a = 103, r = 229, g = 227, b = 196},
groups = {lithium = 1, liquid = 3},
})
@ -39,6 +40,7 @@ bucket.register_liquid("elepower_dynamics:lithium_source", "elepower_dynamics:li
minetest.register_node("elepower_dynamics:steam", {
description = "Steam",
groups = {not_in_creative_inventory = 1, gas = 1},
liquid_form = "default:water_source",
tiles = {"elepower_steam.png"},
})
@ -63,6 +65,7 @@ minetest.register_node("elepower_dynamics:nitrogen", {
minetest.register_node("elepower_dynamics:lithium_gas", {
description = "Lithium Gas",
groups = {not_in_creative_inventory = 1, gas = 1, lithium = 1},
liquid_form = "elepower_dynamics:lithium_source",
tiles = {"elepower_lithium.png"},
})

View File

@ -36,14 +36,20 @@ local function heat_exchanger_timer(pos)
local steam = fluid_lib.get_buffer_data(pos, "steam")
while true do
if heat.amount < 1000 or heat.fluid == "" or not heat_recipes[heat.fluid] then
if heat.fluid == "" or not heat_recipes[heat.fluid] then
break
end
-- Convert a maximum of 1000 buckets of hot fluid per second
local heatper = 1000
if heat.amount < 1000 then
heatper = heat.amount
end
-- See if we have enough hot coolant
if heat.amount >= 1000 and heat.fluid ~= "" then
if heatper > 0 and heat.fluid ~= "" then
local damnt = heat_recipes[heat.fluid]
local water_convert = math.min(water.amount, 1000 * damnt.factor)
local water_convert = math.min(water.amount, heatper * damnt.factor)
if cold.fluid ~= damnt.out and cold.fluid ~= "" then
break
@ -53,10 +59,10 @@ local function heat_exchanger_timer(pos)
water_convert = steam.capacity - steam.amount
end
if water_convert > 0 and cold.amount + 1000 < cold.capacity then
if water_convert > 0 and cold.amount + heatper <= cold.capacity then
-- Conversion
heat.amount = heat.amount - 1000
cold.amount = cold.amount + 1000
heat.amount = heat.amount - heatper
cold.amount = cold.amount + heatper
water.amount = water.amount - water_convert
steam.amount = steam.amount + water_convert