Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- local mon = peripheral.wrap("monitor_38")
- monX, monY = mon.getSize()
- function drawText(x, y, text, color_txt, color_bg)
- mon.setTextScale(2)
- mon.setBackgroundColor(color_bg)
- mon.setTextColor(color_txt)
- mon.setCursorPos(x, y)
- mon.write(text)
- end
- function drawLine(x, y, length, size, color_bg)
- for yPos = y, y+size-1 do
- mon.setBackgroundColor(color_bg)
- mon.setCursorPos(x, yPos)
- mon.write(string.rep(" ", length))
- end
- end
- function drawProg(x, y, txt, length, size, color_bg, color_bar, minVal, maxVal)
- drawLine(x, y, length, size, color_bg)
- local barSize = math.floor((minVal/maxVal)*length)
- drawLine(x, y, barSize, size, color_bar)
- local text = txt.." ".. math.floor((minVal/maxVal)*100).."%"
- if barSize > length/2+#text/2 then
- drawText(x+length/2-#text/2, y+size/2, text, colors.black, color_bar)
- elseif barSize > #text then
- drawText((x+barSize)-#text, y+size/2, text, colors.black, color_bar)
- else
- drawText(x+length/2-#text/2, y+size/2, text, colors.black, color_bg)
- end
- end
- function clear()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- end
- while true do
- id, cmd = rednet.receive()
- clear()
- drawProg(2, 1, "Energy", monX-2, 1, colors.gray, colors.green, cmd, 100)
- sleep(0.75)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement