Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local screen = self.CreateLink("screen")
- local bats = {}
- for i = 1, 10 do
- bats[i] = self.CreateLink("battery" .. tostring(i))
- end
- function ProgressBar(x, y, w, perc)
- local extra = w * perc
- local fg = string.rep(" ", extra)
- local bg = string.rep(" ", w)
- screen.Draw(bg, x, y, Color(0, 0, 0, 0), Color(0, 0, 0, 127))
- screen.Draw(fg, x, y, Color(0, 0, 0, 0), Color(127, 127, 127))
- screen.Draw( tostring(math.Round(perc * 100 * 100) / 100) .. "%", x + w * 0.5 - 2, y)
- end
- function Think()
- if not screen.Connected then return 1 end
- screen.Clear(Color(0, 0, 0, 0))
- local y = 0
- local x = 1
- for k,v in pairs(bats) do
- if v.Connected then
- screen.Draw("Battery " .. tostring(k), x, y)
- print(v.Charge(), v.Capacity())
- ProgressBar(x, y + 1, 60, v.Charge() / v.Capacity())
- y = y + 3
- end
- end
- return 0.0001
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement