Advertisement
guerrier5

eReceiverAdvance

Apr 27th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local component = require("component")
  2. local string = require("string")
  3. local term = require("term")
  4. local math = require("math")
  5. local gpu = component.gpu
  6. local modem = component.modem
  7. local event = require("event")
  8. local previousValue = 0
  9. local resx, resy = gpu.getResolution()
  10. term.clear()
  11.  
  12. while true do
  13.   modem.open(6767)
  14.   local _, _, _, port, _, protocole, energySource, receivedValue = event.pull("modem_message")
  15.   if(port == 6767 and protocole == "eProtocole" and energySource == "wind") then
  16.     term.clear()
  17.     gpu.copy(1, 1, resx, resy,1,1,1,1)
  18.     local barCalcul = math.floor((receivedValue/100000)*158)
  19.     gpu.fill(1,3,1,3,"|")
  20.     gpu.fill(160,3,1,3,"|")
  21.     gpu.setBackground(0x006DFF)
  22.     gpu.fill(2,3,barCalcul,3," ")
  23.     gpu.setBackground(0xD2D2D2)
  24.     gpu.setForeground(0x000000)
  25.     print("Energie Type: "..energySource.." "..math.floor(receivedValue).."/100000 - "..((math.floor(receivedValue)/100000)*100).."%")
  26.     if(receivedValue == 0) then
  27.       gpu.set(45,1,"Empty")
  28.     else
  29.       gpu.set(1,2,string.format("% 5s",(math.floor((receivedValue-previousValue)/3))).." RF/s")
  30.     end
  31.     previousValue = receivedValue
  32.    end
  33. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement