Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- induction = peripheral.wrap("back")
- function rnd (val, dec)
- local X = math.pow(10, dec)
- return math.floor(val * X) / X
- end
- function pwr (val, dec)
- local pre = ''
- local suf = ''
- local is_neg = false
- if val < 0 then
- pre = '-'
- is_neg = true
- val = -val
- end
- val = mekanismEnergyHelper.joulesToFE(val)
- if val > 1000 then
- suf = 'k'
- val = val / 1000
- end
- if val > 1000 then
- suf = 'M'
- val = val / 1000
- end
- if val > 1000 then
- suf = 'G'
- val = val / 1000
- end
- if val > 1000 then
- suf = 'T'
- val = val / 1000
- end
- return pre .. rnd(val, dec or 1) .. suf
- end
- function broadcastBattery()
- while true do
- messageToSend = "Battery "
- messageToSend = messageToSend .. induction.getEnergyFilledPercentage() * 100 .. "% "
- messageToSend = messageToSend .. "In: " .. pwr(induction.getLastInput()) .. " Out: " .. pwr(induction.getLastOutput())
- rednet.broadcast(messageToSend, "battery")
- sleep(20)
- end
- end
- broadcastBattery()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement