Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- monitor = peripheral.find("monitor")
- monitor.clear()
- msgTemp = -1
- box = peripheral.find("chatBox")
- function monitorShow(message)
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.write(message)
- end
- function consummation(_msg)
- rfCons = _msg
- print(rfCons)
- value = ""
- size = string.len(_msg)
- pow = size-3
- print(pow.."p|s"..size)
- --si c'est au dessus de 0 donc il faut faire une simplification
- if pow>0 then
- if size>3 and size<7 then
- rfCons = _msg/(math.pow(10,3))
- value = "k"
- end
- if size>6 and size<10 then
- rfCons = _msg/(math.pow(10,6))
- value = "M"
- end
- if size>9 and size<13 then
- rfCons = _msg/(math.pow(10,9))
- value = "G"
- end
- if size>12 then
- rfCons = _msg/(math.pow(10,12))
- value = "T"
- end
- end
- --message = string.sub(rfCons.."",1,5)..value.."FE/t)
- --value = value.."FE/t"
- print(rfCons)
- --retour de la valeur de la consommation
- return string.sub(rfCons.."",1,5)..value.."FE/t"
- end
- function chatBox(rfCons)
- event, player, chatItem = os.pullEvent("chat")
- if chatItem == ".cons" then
- box.sendMessage(rfCons,"Info Conso")
- end
- end
- while true do
- id, msg = rednet.receive()
- rfCons = consummation(msg)
- --On passe ici que s'il y a changement d'etat
- if id~=nil and msg~=nil and msg~=msgTemp then
- monitorShow(rfCons)
- os.sleep(1)
- end
- id, msgTemp = rednet.receive()
- chatBox(rfCons)
- end
Add Comment
Please, Sign In to add comment