forked from acidjazz/drmon
-
Notifications
You must be signed in to change notification settings - Fork 2
/
bat.lua
44 lines (38 loc) · 1.12 KB
/
bat.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
local pylon = "back"
local monitor = "left"
function format_int(number)
if number == nil then number = 0 end
local i, j, minus, int, fraction = tostring(number):find('([-]?)(%d+)([.]?%d*)')
int = int:reverse():gsub("(%d%d%d)", "%1,")
return minus .. int:reverse():gsub("^,", "") .. fraction
end
function update()
while true do
bat = peripheral.wrap(pylon)
mon = peripheral.wrap(monitor)
max = bat.getMaxEnergyStored()
current = bat.getEnergyStored()
rate = bat.getTransferPerTick()
mon.setBackgroundColor(colors.black)
mon.setTextColor(colors.green)
mon.setCursorPos(2,4)
mon.write("Max Capacity: ")
mon.setTextColor(colors.white)
mon.setCursorPos(2,5)
mon.write(format_int(max))
mon.setTextColor(colors.green)
mon.setCursorPos(2,6)
mon.write("Capacity: ")
mon.setTextColor(colors.white)
mon.setCursorPos(2,7)
mon.write(format_int(current))
mon.setTextColor(colors.green)
mon.setCursorPos(2,8)
mon.write("Rate Change: ")
mon.setTextColor(colors.white)
mon.setCursorPos(2,9)
mon.write(format_int(rate))
sleep(1)
end
end
update()