2018-06-20 11:53:07 +00:00
|
|
|
|
|
|
|
-- Fluid bar for formspec
|
|
|
|
function ele.formspec.fluid_bar(x, y, fluid_buffer)
|
|
|
|
local texture = "default_water.png"
|
|
|
|
local metric = 0
|
2018-08-06 09:53:00 +00:00
|
|
|
local tooltip = ("tooltip[%d,%d;1,2.5;%s]"):format(x, y, "Empty Buffer")
|
2018-06-20 11:53:07 +00:00
|
|
|
|
|
|
|
if fluid_buffer and fluid_buffer.fluid and fluid_buffer.fluid ~= "" and
|
|
|
|
minetest.registered_nodes[fluid_buffer.fluid] ~= nil then
|
|
|
|
texture = minetest.registered_nodes[fluid_buffer.fluid].tiles[1]
|
|
|
|
if type(texture) == "table" then
|
|
|
|
texture = texture.name
|
|
|
|
end
|
2018-08-06 09:53:00 +00:00
|
|
|
|
|
|
|
local fdesc = fluid_lib.cleanse_node_description(fluid_buffer.fluid)
|
2018-06-20 11:53:07 +00:00
|
|
|
metric = math.floor(100 * fluid_buffer.amount / fluid_buffer.capacity)
|
2018-08-06 09:53:00 +00:00
|
|
|
tooltip = ("tooltip[%d,%d;1,2.5;%s\n%s / %s %s]"):format(x, y, fdesc,
|
|
|
|
ele.helpers.comma_value(fluid_buffer.amount), ele.helpers.comma_value(fluid_buffer.capacity), fluid_lib.unit)
|
2018-06-20 11:53:07 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return "image["..x..","..y..";1,2.8;elepower_gui_barbg.png"..
|
|
|
|
"\\^[lowpart\\:"..metric.."\\:"..texture.."\\\\^[resize\\\\:64x128]"..
|
2018-08-06 09:53:00 +00:00
|
|
|
"image["..x..","..y..";1,2.8;elepower_gui_gauge.png]"..
|
|
|
|
tooltip
|
2018-06-20 11:53:07 +00:00
|
|
|
end
|