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
|
local remainder = 0
|
||||||
if count + amount > capacity then
|
if count + amount > capacity then
|
||||||
if overfill then
|
if overfill then
|
||||||
remainder = (count + amount) - capacity
|
remainder = capacity - count
|
||||||
count = capacity
|
count = capacity
|
||||||
else
|
else
|
||||||
return nil
|
return nil
|
||||||
@ -268,7 +268,7 @@ function fluidity.tanks.register_fluid_tank(data)
|
|||||||
local capacity = data.capacity or 64000
|
local capacity = data.capacity or 64000
|
||||||
local tanknode = modname..":"..tankname
|
local tanknode = modname..":"..tankname
|
||||||
|
|
||||||
if not tanknode then
|
if not minetest.registered_nodes[tanknode] then
|
||||||
minetest.register_node(tanknode, {
|
minetest.register_node(tanknode, {
|
||||||
description = tankdesc,
|
description = tankdesc,
|
||||||
drawtype = "glasslike_framed_optional",
|
drawtype = "glasslike_framed_optional",
|
||||||
|
@ -52,13 +52,13 @@ function metal_caster.get_metal_caster_formspec_default()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function metal_caster.get_metal_caster_formspec(data)
|
function metal_caster.get_metal_caster_formspec(data)
|
||||||
local water_percent = data.water_level / metal_caster.max_coolant
|
local water_percent = data.water_fluid_storage / metal_caster.max_coolant
|
||||||
local metal_percent = data.metal_level / metal_caster.max_metal
|
local metal_percent = data.metal_fluid_storage / metal_caster.max_metal
|
||||||
|
|
||||||
local metal_formspec = "label[0.08,3.75;No Molten Metal]"
|
local metal_formspec = "label[0.08,3.75;No Molten Metal]"
|
||||||
|
|
||||||
if data.metal ~= "" then
|
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
|
end
|
||||||
|
|
||||||
return "size[8,8.5]"..
|
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,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,"..(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]"..
|
"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,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,"..(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]"..
|
"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()
|
local inv = meta:get_inventory()
|
||||||
|
|
||||||
-- Current amount of water (coolant) in the block
|
-- 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
|
-- 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
|
-- Current metal used
|
||||||
local metal = meta:get_string("metal")
|
local metal = meta:get_string("metal_fluid")
|
||||||
local metal_type = ""
|
local metal_type = ""
|
||||||
|
|
||||||
local dumping = meta:get_int("dump")
|
local dumping = meta:get_int("dump")
|
||||||
@ -421,32 +421,30 @@ local function caster_node_timer(pos, elapsed)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if refresh then
|
meta:set_int("water_fluid_storage", coolant_count)
|
||||||
meta:set_int("water_level", coolant_count)
|
meta:set_int("metal_fluid_storage", metal_count)
|
||||||
meta:set_int("metal_level", metal_count)
|
meta:set_string("metal_fluid", metal)
|
||||||
meta:set_string("metal", metal)
|
|
||||||
|
|
||||||
local metal_texture = "default_lava.png"
|
local metal_texture = "default_lava.png"
|
||||||
local metal_name = ""
|
local metal_name = ""
|
||||||
|
|
||||||
local infotext = "Metal Caster\n"
|
local infotext = "Metal Caster\n"
|
||||||
infotext = infotext.."Water: "..coolant_count.."/"..metal_caster.max_coolant.." mB \n"
|
infotext = infotext.."Water: "..coolant_count.."/"..metal_caster.max_coolant.." mB \n"
|
||||||
|
|
||||||
if metal ~= "" then
|
if metal ~= "" then
|
||||||
metal_texture = "fluidity_"..fluidity.get_metal_for_fluid(metal)..".png"
|
metal_texture = "fluidity_"..fluidity.get_metal_for_fluid(metal)..".png"
|
||||||
|
|
||||||
local metal_node = minetest.registered_nodes[metal]
|
local metal_node = minetest.registered_nodes[metal]
|
||||||
metal_name = fluidity.fluid_name(metal_node.description)
|
metal_name = fluidity.fluid_name(metal_node.description)
|
||||||
infotext = infotext..metal_name..": "..metal_count.."/"..metal_caster.max_metal.." mB"
|
infotext = infotext..metal_name..": "..metal_count.."/"..metal_caster.max_metal.." mB"
|
||||||
else
|
else
|
||||||
infotext = infotext.."No Molten Metal"
|
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}))
|
|
||||||
end
|
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
|
return refresh
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -463,11 +461,12 @@ local function on_construct(pos)
|
|||||||
inv:set_size('bucket_out', 1)
|
inv:set_size('bucket_out', 1)
|
||||||
|
|
||||||
-- Fluid buffers
|
-- Fluid buffers
|
||||||
meta:set_int('water_level', 0)
|
meta:set_int('water_fluid_storage', 0)
|
||||||
meta:set_int('metal_level', 0)
|
meta:set_int('metal_fluid_storage', 0)
|
||||||
|
|
||||||
-- Metal source block
|
-- Metal source block
|
||||||
meta:set_string('metal', '')
|
meta:set_string('metal_fluid', '')
|
||||||
|
meta:set_string('water_fluid', 'default:water_source')
|
||||||
|
|
||||||
-- Default infotext
|
-- Default infotext
|
||||||
meta:set_string("infotext", "Metal Caster Inactive")
|
meta:set_string("infotext", "Metal Caster Inactive")
|
||||||
@ -548,6 +547,7 @@ minetest.register_node("metal_melter:metal_caster", {
|
|||||||
cracky=2,
|
cracky=2,
|
||||||
tubedevice = 1,
|
tubedevice = 1,
|
||||||
tubedevice_receiver = 1,
|
tubedevice_receiver = 1,
|
||||||
|
fluid_container = 1,
|
||||||
},
|
},
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
is_ground_content = false,
|
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_move = allow_metadata_inventory_move,
|
||||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
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,
|
tube = pipeworks,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -186,13 +186,13 @@ local function melter_node_timer(pos, elapsed)
|
|||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
|
|
||||||
-- Current amount of lava in the block
|
-- 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
|
-- 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
|
-- Current metal used
|
||||||
local metal = meta:get_string("metal")
|
local metal = meta:get_string("metal_fluid")
|
||||||
|
|
||||||
local dumping = meta:get_int("dump")
|
local dumping = meta:get_int("dump")
|
||||||
if dumping and dumping == 1 then
|
if dumping and dumping == 1 then
|
||||||
@ -326,38 +326,36 @@ local function melter_node_timer(pos, elapsed)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Refresh metadata and formspec
|
-- Refresh metadata and formspec
|
||||||
if refresh then
|
meta:set_int("lava_fluid_storage", heat_count)
|
||||||
meta:set_int("lava_level", heat_count)
|
meta:set_int("metal_fluid_storage", metal_count)
|
||||||
meta:set_int("metal_level", metal_count)
|
meta:set_string("metal_fluid", metal)
|
||||||
meta:set_string("metal", metal)
|
|
||||||
|
|
||||||
local metal_texture = "default_lava.png"
|
local metal_texture = "default_lava.png"
|
||||||
local metal_name = ""
|
local metal_name = ""
|
||||||
|
|
||||||
local infotext = "Metal Melter\n"
|
local infotext = "Metal Melter\n"
|
||||||
infotext = infotext.."Lava: "..heat_count.."/"..metal_melter.max_fuel.." mB \n"
|
infotext = infotext.."Lava: "..heat_count.."/"..metal_melter.max_fuel.." mB \n"
|
||||||
|
|
||||||
if metal ~= "" then
|
if metal ~= "" then
|
||||||
metal_texture = "fluidity_"..fluidity.get_metal_for_fluid(metal)..".png"
|
metal_texture = "fluidity_"..fluidity.get_metal_for_fluid(metal)..".png"
|
||||||
|
|
||||||
local metal_node = minetest.registered_nodes[metal]
|
local metal_node = minetest.registered_nodes[metal]
|
||||||
metal_name = fluidity.fluid_name(metal_node.description)
|
metal_name = fluidity.fluid_name(metal_node.description)
|
||||||
infotext = infotext..metal_name..": "..metal_count.."/"..metal_melter.max_metal.." mB"
|
infotext = infotext..metal_name..": "..metal_count.."/"..metal_melter.max_metal.." mB"
|
||||||
else
|
else
|
||||||
infotext = infotext.."No Molten Metal"
|
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}))
|
|
||||||
end
|
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.
|
-- If true, calls for another clock cycle.
|
||||||
return refresh
|
return refresh
|
||||||
end
|
end
|
||||||
@ -374,11 +372,12 @@ local function on_construct(pos)
|
|||||||
inv:set_size('bucket_out', 1)
|
inv:set_size('bucket_out', 1)
|
||||||
|
|
||||||
-- Fluid buffers
|
-- Fluid buffers
|
||||||
meta:set_int('lava_level', 0)
|
meta:set_int('lava_fluid_storage', 0)
|
||||||
meta:set_int('metal_level', 0)
|
meta:set_int('metal_fluid_storage', 0)
|
||||||
|
|
||||||
-- Metal source block
|
-- Metal source block
|
||||||
meta:set_string('metal', '')
|
meta:set_string('metal_fluid', '')
|
||||||
|
meta:set_string('lava_fluid', 'default:lava_source')
|
||||||
|
|
||||||
-- Default infotext
|
-- Default infotext
|
||||||
meta:set_string("infotext", "Metal Melter Inactive")
|
meta:set_string("infotext", "Metal Melter Inactive")
|
||||||
@ -444,6 +443,7 @@ minetest.register_node("metal_melter:metal_melter", {
|
|||||||
cracky = 2,
|
cracky = 2,
|
||||||
tubedevice = 1,
|
tubedevice = 1,
|
||||||
tubedevice_receiver = 1,
|
tubedevice_receiver = 1,
|
||||||
|
fluid_container = 1,
|
||||||
},
|
},
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
is_ground_content = false,
|
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_move = allow_metadata_inventory_move,
|
||||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
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,
|
tube = pipeworks,
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -488,7 +498,8 @@ minetest.register_node("metal_melter:metal_melter_filled", {
|
|||||||
cracky = 2,
|
cracky = 2,
|
||||||
tubedevice = 1,
|
tubedevice = 1,
|
||||||
tubedevice_receiver = 1,
|
tubedevice_receiver = 1,
|
||||||
not_in_creative_inventory = 1
|
not_in_creative_inventory = 1,
|
||||||
|
fluid_container = 1,
|
||||||
},
|
},
|
||||||
legacy_facedir_simple = true,
|
legacy_facedir_simple = true,
|
||||||
is_ground_content = false,
|
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_move = allow_metadata_inventory_move,
|
||||||
allow_metadata_inventory_take = allow_metadata_inventory_take,
|
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,
|
tube = pipeworks,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user