Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.wrap("back")
- local total = 0
- monX, monY = mon.getSize()
- --Fonction
- function clear()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,1)
- end
- function drawText(x, y, text, color_txt, color_bg)
- mon.setBackgroundColor(color_bg)
- mon.setTextColor(color_txt)
- mon.setCursorPos(x,y)
- mon.write(text)
- end
- function drawLine(x, y, length, size, color_bar)
- for yPos = y, y+size-1 do
- mon.setBackgroundColor(color_bar)
- mon.setCursorPos(x, yPos)
- mon.write(string.rep(" ", length))
- end
- end
- function drawProg(x, y, name, length, size, minVal, maxVal, color_bar, color_bg)
- drawLine(x, y, length, size, color_bg)
- local barSize = math.floor((minVal/maxVal)*length)
- drawLine(x, y, barSize, size, color_bar)
- local text = name.." "..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
- --End fonction
- mon.setBackgroundColor(colors.black)
- while true do
- mon.clear()
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,1)
- mon.setTextScale(1)
- mon.write("Monitor ..")
- sleep(1)
- local mon = peripheral.wrap("back")
- if mon then
- mon.setTextColor(colors.green)
- mon.write(" Ok")
- else
- mon.setTextColor(colors.red)
- mon.write(" Failed")
- stop()
- end
- sleep(1)
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,2)
- mon.setTextScale(1)
- mon.write("Modem ..")
- sleep(1)
- local modem = peripheral.wrap("top")
- if modem then
- mon.setTextColor(colors.green)
- mon.write(" Ok")
- else
- mon.setTextColor(colors.red)
- mon.write(" Failed")
- stop()
- end
- sleep(1)
- mon.setTextColor(colors.white)
- mon.setCursorPos(1,4)
- mon.write("Waiting for a signal ..")
- while modem do
- modem.open(7)
- local event, modemSide, senderChannel, replyChannel, mfsu, senderDistance = os.pullEvent("modem_message")
- total = mfsu / 4000000 * 100
- clear()
- drawProg(0,0, "MFE", 40, 6, total, 100, colors.green, colors.gray)
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(1,6)
- mon.setTextColor(colors.white)
- sleep(0.2)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement