2018-07-22 01:03:17 +02:00
|
|
|
-- Formspec helpers
|
2018-06-18 09:09:43 +02:00
|
|
|
|
|
|
|
ele.formspec = {}
|
|
|
|
|
2018-07-22 01:03:17 +02:00
|
|
|
function ele.formspec.create_bar(x, y, metric, color, small)
|
2018-07-22 12:34:42 +02:00
|
|
|
if not metric or type(metric) ~= "number" or metric < 0 then metric = 0 end
|
2018-07-22 01:03:17 +02:00
|
|
|
|
|
|
|
local width = 1
|
|
|
|
local gauge = "image[0,0;1,2.8;elepower_gui_gauge.png]"
|
|
|
|
|
|
|
|
-- Smaller width bar
|
|
|
|
if small then
|
|
|
|
width = 0.25
|
|
|
|
gauge = ""
|
|
|
|
end
|
|
|
|
|
|
|
|
return "image["..x..","..y..";"..width..",2.8;elepower_gui_barbg.png"..
|
|
|
|
"\\^[lowpart\\:"..metric.."\\:elepower_gui_bar.png\\\\^[multiply\\\\:"..color.."]"..
|
|
|
|
gauge
|
|
|
|
end
|
|
|
|
|
2018-06-18 09:09:43 +02:00
|
|
|
function ele.formspec.power_meter(pw_percent)
|
2018-07-22 01:03:17 +02:00
|
|
|
return ele.formspec.create_bar(0, 0, pw_percent, "#00a1ff")
|
2018-06-18 09:09:43 +02:00
|
|
|
end
|