mirror of
https://gitlab.icynet.eu/evert/melterns.git
synced 2024-11-28 01:43:46 +01:00
New fluid storage method, tank fix
This commit is contained in:
parent
b1340e953e
commit
5f5c172a15
@ -86,7 +86,7 @@ function fluidity.tanks.fill_tank_at(pos, fluid, amount, overfill)
|
||||
local remainder = 0
|
||||
if count + amount > capacity then
|
||||
if overfill then
|
||||
remainder = (count + amount) - capacity
|
||||
remainder = capacity - count
|
||||
count = capacity
|
||||
else
|
||||
return nil
|
||||
@ -268,7 +268,7 @@ function fluidity.tanks.register_fluid_tank(data)
|
||||
local capacity = data.capacity or 64000
|
||||
local tanknode = modname..":"..tankname
|
||||
|
||||
if not tanknode then
|
||||
if not minetest.registered_nodes[tanknode] then
|
||||
minetest.register_node(tanknode, {
|
||||
description = tankdesc,
|
||||
drawtype = "glasslike_framed_optional",
|
||||
|
@ -52,13 +52,13 @@ function metal_caster.get_metal_caster_formspec_default()
|
||||
end
|
||||
|
||||
function metal_caster.get_metal_caster_formspec(data)
|
||||
local water_percent = data.water_level / metal_caster.max_coolant
|
||||
local metal_percent = data.metal_level / metal_caster.max_metal
|
||||
local water_percent = data.water_fluid_storage / metal_caster.max_coolant
|
||||
local metal_percent = data.metal_fluid_storage / metal_caster.max_metal
|
||||
|
||||
local metal_formspec = "label[0.08,3.75;No Molten Metal]"
|
||||
|
||||
if data.metal ~= "" then
|
||||
metal_formspec = "label[0.08,3.75;"..data.metal..": "..data.metal_level.."/"..metal_caster.max_metal.." mB]"
|
||||
metal_formspec = "label[0.08,3.75;"..data.metal..": "..data.metal_fluid_storage.."/"..metal_caster.max_metal.." mB]"
|
||||
end
|
||||
|
||||
return "size[8,8.5]"..
|
||||
@ -72,7 +72,7 @@ function metal_caster.get_metal_caster_formspec(data)
|
||||
"image[0.08,0;1.4,2.8;melter_gui_barbg.png]"..
|
||||
"image[0.08,"..(2.44 - water_percent * 2.44)..";1.4,"..(water_percent * 2.8)..";default_water.png]"..
|
||||
"image[0.08,0;1.4,2.8;melter_gui_gauge.png]"..
|
||||
"label[0.08,3.4;Water: "..data.water_level.."/"..metal_caster.max_coolant.." mB]"..
|
||||
"label[0.08,3.4;Water: "..data.water_fluid_storage.."/"..metal_caster.max_coolant.." mB]"..
|
||||
"image[6.68,0;1.4,2.8;melter_gui_barbg.png]"..
|
||||
"image[6.68,"..(2.44 - metal_percent * 2.44)..";1.4,"..(metal_percent * 2.8)..";"..data.metal_texture.."]"..
|
||||
"image[6.68,0;1.4,2.8;melter_gui_gauge.png]"..
|
||||
@ -243,13 +243,13 @@ local function caster_node_timer(pos, elapsed)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
-- Current amount of water (coolant) in the block
|
||||
local coolant_count = meta:get_int("water_level")
|
||||
local coolant_count = meta:get_int("water_fluid_storage")
|
||||
|
||||
-- Current amount of metal in the block
|
||||
local metal_count = meta:get_int("metal_level")
|
||||
local metal_count = meta:get_int("metal_fluid_storage")
|
||||
|
||||
-- Current metal used
|
||||
local metal = meta:get_string("metal")
|
||||
local metal = meta:get_string("metal_fluid")
|
||||
local metal_type = ""
|
||||
|
||||
local dumping = meta:get_int("dump")
|
||||
@ -421,32 +421,30 @@ local function caster_node_timer(pos, elapsed)
|
||||
end
|
||||
end
|
||||
|
||||
if refresh then
|
||||
meta:set_int("water_level", coolant_count)
|
||||
meta:set_int("metal_level", metal_count)
|
||||
meta:set_string("metal", metal)
|
||||
meta:set_int("water_fluid_storage", coolant_count)
|
||||
meta:set_int("metal_fluid_storage", metal_count)
|
||||
meta:set_string("metal_fluid", metal)
|
||||
|
||||
local metal_texture = "default_lava.png"
|
||||
local metal_name = ""
|
||||
local metal_texture = "default_lava.png"
|
||||
local metal_name = ""
|
||||
|
||||
local infotext = "Metal Caster\n"
|
||||
infotext = infotext.."Water: "..coolant_count.."/"..metal_caster.max_coolant.." mB \n"
|
||||
local infotext = "Metal Caster\n"
|
||||
infotext = infotext.."Water: "..coolant_count.."/"..metal_caster.max_coolant.." mB \n"
|
||||
|
||||
if metal ~= "" then
|
||||
metal_texture = "fluidity_"..fluidity.get_metal_for_fluid(metal)..".png"
|
||||
if metal ~= "" then
|
||||
metal_texture = "fluidity_"..fluidity.get_metal_for_fluid(metal)..".png"
|
||||
|
||||
local metal_node = minetest.registered_nodes[metal]
|
||||
metal_name = fluidity.fluid_name(metal_node.description)
|
||||
infotext = infotext..metal_name..": "..metal_count.."/"..metal_caster.max_metal.." mB"
|
||||
else
|
||||
infotext = infotext.."No Molten Metal"
|
||||
end
|
||||
|
||||
meta:set_string("infotext", infotext)
|
||||
meta:set_string("formspec", metal_caster.get_metal_caster_formspec(
|
||||
{water_level=coolant_count, metal_level=metal_count, metal_texture=metal_texture, metal=metal_name}))
|
||||
local metal_node = minetest.registered_nodes[metal]
|
||||
metal_name = fluidity.fluid_name(metal_node.description)
|
||||
infotext = infotext..metal_name..": "..metal_count.."/"..metal_caster.max_metal.." mB"
|
||||
else
|
||||
infotext = infotext.."No Molten Metal"
|
||||
end
|
||||
|
||||
meta:set_string("infotext", infotext)
|
||||
meta:set_string("formspec", metal_caster.get_metal_caster_formspec(
|
||||
{water_fluid_storage=coolant_count, metal_fluid_storage=metal_count, metal_texture=metal_texture, metal=metal_name}))
|
||||
|
||||
return refresh
|
||||
end
|
||||
|
||||
@ -463,11 +461,12 @@ local function on_construct(pos)
|
||||
inv:set_size('bucket_out', 1)
|
||||
|
||||
-- Fluid buffers
|
||||
meta:set_int('water_level', 0)
|
||||
meta:set_int('metal_level', 0)
|
||||
meta:set_int('water_fluid_storage', 0)
|
||||
meta:set_int('metal_fluid_storage', 0)
|
||||
|
||||
-- Metal source block
|
||||
meta:set_string('metal', '')
|
||||
meta:set_string('metal_fluid', '')
|
||||
meta:set_string('water_fluid', 'default:water_source')
|
||||
|
||||
-- Default infotext
|
||||
meta:set_string("infotext", "Metal Caster Inactive")
|
||||
@ -548,6 +547,7 @@ minetest.register_node("metal_melter:metal_caster", {
|
||||
cracky=2,
|
||||
tubedevice = 1,
|
||||
tubedevice_receiver = 1,
|
||||
fluid_container = 1,
|
||||
},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
@ -582,6 +582,17 @@ minetest.register_node("metal_melter:metal_caster", {
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
|
||||
fluid_buffers = {
|
||||
water = {
|
||||
capacity = metal_caster.max_coolant,
|
||||
accepts = {"default:water_source"}
|
||||
},
|
||||
metal = {
|
||||
capacity = metal_caster.max_metal,
|
||||
accepts = "group:molten_metal",
|
||||
}
|
||||
},
|
||||
|
||||
tube = pipeworks,
|
||||
})
|
||||
|
||||
|
@ -186,13 +186,13 @@ local function melter_node_timer(pos, elapsed)
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
-- Current amount of lava in the block
|
||||
local heat_count = meta:get_int("lava_level")
|
||||
local heat_count = meta:get_int("lava_fluid_storage")
|
||||
|
||||
-- Current amount of metal in the block
|
||||
local metal_count = meta:get_int("metal_level")
|
||||
local metal_count = meta:get_int("metal_fluid_storage")
|
||||
|
||||
-- Current metal used
|
||||
local metal = meta:get_string("metal")
|
||||
local metal = meta:get_string("metal_fluid")
|
||||
|
||||
local dumping = meta:get_int("dump")
|
||||
if dumping and dumping == 1 then
|
||||
@ -326,38 +326,36 @@ local function melter_node_timer(pos, elapsed)
|
||||
end
|
||||
|
||||
-- Refresh metadata and formspec
|
||||
if refresh then
|
||||
meta:set_int("lava_level", heat_count)
|
||||
meta:set_int("metal_level", metal_count)
|
||||
meta:set_string("metal", metal)
|
||||
meta:set_int("lava_fluid_storage", heat_count)
|
||||
meta:set_int("metal_fluid_storage", metal_count)
|
||||
meta:set_string("metal_fluid", metal)
|
||||
|
||||
local metal_texture = "default_lava.png"
|
||||
local metal_name = ""
|
||||
local metal_texture = "default_lava.png"
|
||||
local metal_name = ""
|
||||
|
||||
local infotext = "Metal Melter\n"
|
||||
infotext = infotext.."Lava: "..heat_count.."/"..metal_melter.max_fuel.." mB \n"
|
||||
local infotext = "Metal Melter\n"
|
||||
infotext = infotext.."Lava: "..heat_count.."/"..metal_melter.max_fuel.." mB \n"
|
||||
|
||||
if metal ~= "" then
|
||||
metal_texture = "fluidity_"..fluidity.get_metal_for_fluid(metal)..".png"
|
||||
if metal ~= "" then
|
||||
metal_texture = "fluidity_"..fluidity.get_metal_for_fluid(metal)..".png"
|
||||
|
||||
local metal_node = minetest.registered_nodes[metal]
|
||||
metal_name = fluidity.fluid_name(metal_node.description)
|
||||
infotext = infotext..metal_name..": "..metal_count.."/"..metal_melter.max_metal.." mB"
|
||||
else
|
||||
infotext = infotext.."No Molten Metal"
|
||||
end
|
||||
|
||||
if heat_count > 144 then
|
||||
swap_node(pos, "metal_melter:metal_melter_filled")
|
||||
else
|
||||
swap_node(pos, "metal_melter:metal_melter")
|
||||
end
|
||||
|
||||
meta:set_string("infotext", infotext)
|
||||
meta:set_string("formspec", metal_melter.get_metal_melter_formspec(
|
||||
{lava_level=heat_count, metal_level=metal_count, metal_texture=metal_texture, metal=metal_name}))
|
||||
local metal_node = minetest.registered_nodes[metal]
|
||||
metal_name = fluidity.fluid_name(metal_node.description)
|
||||
infotext = infotext..metal_name..": "..metal_count.."/"..metal_melter.max_metal.." mB"
|
||||
else
|
||||
infotext = infotext.."No Molten Metal"
|
||||
end
|
||||
|
||||
if heat_count > 144 then
|
||||
swap_node(pos, "metal_melter:metal_melter_filled")
|
||||
else
|
||||
swap_node(pos, "metal_melter:metal_melter")
|
||||
end
|
||||
|
||||
meta:set_string("infotext", infotext)
|
||||
meta:set_string("formspec", metal_melter.get_metal_melter_formspec(
|
||||
{lava_level=heat_count, metal_level=metal_count, metal_texture=metal_texture, metal=metal_name}))
|
||||
|
||||
-- If true, calls for another clock cycle.
|
||||
return refresh
|
||||
end
|
||||
@ -374,11 +372,12 @@ local function on_construct(pos)
|
||||
inv:set_size('bucket_out', 1)
|
||||
|
||||
-- Fluid buffers
|
||||
meta:set_int('lava_level', 0)
|
||||
meta:set_int('metal_level', 0)
|
||||
meta:set_int('lava_fluid_storage', 0)
|
||||
meta:set_int('metal_fluid_storage', 0)
|
||||
|
||||
-- Metal source block
|
||||
meta:set_string('metal', '')
|
||||
meta:set_string('metal_fluid', '')
|
||||
meta:set_string('lava_fluid', 'default:lava_source')
|
||||
|
||||
-- Default infotext
|
||||
meta:set_string("infotext", "Metal Melter Inactive")
|
||||
@ -444,6 +443,7 @@ minetest.register_node("metal_melter:metal_melter", {
|
||||
cracky = 2,
|
||||
tubedevice = 1,
|
||||
tubedevice_receiver = 1,
|
||||
fluid_container = 1,
|
||||
},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
@ -474,6 +474,16 @@ minetest.register_node("metal_melter:metal_melter", {
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
|
||||
fluid_buffers = {
|
||||
lava = {
|
||||
capacity = metal_melter.max_fuel,
|
||||
accepts = {"default:lava_source"}
|
||||
},
|
||||
metal = {
|
||||
capacity = metal_melter.max_metal
|
||||
}
|
||||
},
|
||||
|
||||
tube = pipeworks,
|
||||
})
|
||||
|
||||
@ -488,7 +498,8 @@ minetest.register_node("metal_melter:metal_melter_filled", {
|
||||
cracky = 2,
|
||||
tubedevice = 1,
|
||||
tubedevice_receiver = 1,
|
||||
not_in_creative_inventory = 1
|
||||
not_in_creative_inventory = 1,
|
||||
fluid_container = 1,
|
||||
},
|
||||
legacy_facedir_simple = true,
|
||||
is_ground_content = false,
|
||||
@ -512,6 +523,16 @@ minetest.register_node("metal_melter:metal_melter_filled", {
|
||||
allow_metadata_inventory_move = allow_metadata_inventory_move,
|
||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
|
||||
fluid_buffers = {
|
||||
lava = {
|
||||
capacity = metal_melter.max_fuel,
|
||||
accepts = {"default:lava_source"}
|
||||
},
|
||||
metal = {
|
||||
capacity = metal_melter.max_metal
|
||||
}
|
||||
},
|
||||
|
||||
tube = pipeworks,
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user