Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Config
- width = 15
- height = 40
- interval = 3
- title = "Biomass"
- cell = peripheral.wrap("thermalexpansion:storage_cell_3")
- monitor = peripheral.wrap("monitor_2")
- monitor.setTextColor(colors.white)
- monitor.setTextScale(0.5)
- -- Update screen
- function update()
- print("Update")
- -- Calculate energy
- stored = cell.getEnergyStored()
- total = cell.getEnergyCapacity()
- p = math.floor((stored/total) * 10000.0) / 100.0
- h = (stored/total) * height
- -- Draw box
- prev = term.redirect(monitor)
- paintutils.drawFilledBox(0, 0, width, height, colors.black)
- paintutils.drawFilledBox(0, height-h, width, height, colors.blue)
- term.redirect(prev)
- -- Draw text
- monitor.setBackgroundColor(colors.black)
- monitor.setCursorPos(1, 1)
- monitor.write(title)
- monitor.setCursorPos(1, 2)
- monitor.write(p .. "%")
- end
- -- Run endlessly
- print("Running")
- timer = os.startTimer(interval)
- while true do
- event, param = os.pullEvent()
- if event == "key" then
- break
- elseif event == "timer" and param == timer then
- update()
- timer = os.startTimer(interval)
- end
- end
- print("Stopped")
Advertisement
Add Comment
Please, Sign In to add comment