Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Receive data from send_data_reactor_CC and display it on a monitor
- local modem = peripheral.wrap("left")
- local mon = peripheral.wrap("back")
- local maxPower = 150000 -- Votre puissance maximale
- local gaugeWidth = 3 -- Largeur de la jauge en blocs
- local gaugeMargin = 1 -- Marge en haut et en bas de la jauge
- local width, height = mon.getSize() -- Taille totale de l'écran
- while true do
- rednet.open("left")
- local senderID, power, protocol = rednet.receive()
- rednet.close("left")
- -- Nettoie la zone de la jauge
- mon.setBackgroundColor(colors.gray)
- for i = 1, height do
- mon.setCursorPos((width - gaugeWidth) / 2 + 1, i)
- mon.write(string.rep(" ", gaugeWidth))
- end
- -- Calcul de la taille de la jauge
- local gaugeHeight = math.floor((power / maxPower) * (height - 2 * gaugeMargin))
- -- Affiche la jauge
- mon.setBackgroundColor(colors.green)
- for i = 1, gaugeHeight do
- mon.setCursorPos((width - gaugeWidth) / 2 + 1, height - gaugeMargin - i + 1)
- mon.write(string.rep(" ", gaugeWidth))
- end
- -- Affiche les valeurs
- mon.setCursorPos((width - string.len("Max: " .. maxPower)) / 2 + 1, gaugeMargin) -- Positionne le texte au-dessus de la jauge
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- mon.write("Max: " .. maxPower)
- mon.setCursorPos((width - string.len("Current: " .. power)) / 2 + 1, height - gaugeMargin + 1) -- Positionne le texte en dessous de la jauge
- mon.write("Current: " .. power)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement