View difference between Paste ID: ndWb6Txb and sKTesQiQ
SHOW: | | - or go back to the newest paste.
1-
local component = require("component")
1+
local component = require("component")
2-
local string = require("string")
2+
local string = require("string")
3-
local term = require("term")
3+
local term = require("term")
4-
local math = require("math")
4+
local math = require("math")
5-
local gpu = component.gpu
5+
local gpu = component.gpu
6-
local modem = component.modem
6+
local modem = component.modem
7-
local event = require("event")
7+
local event = require("event")
8-
local previousValue = 0
8+
local previousValue = 0
9-
local resx, resy = gpu.getResolution()
9+
local resx, resy = gpu.getResolution()
10-
term.clear()
10+
term.clear()
11-
11+
12-
while true do
12+
while true do
13-
  modem.open(6767)
13+
  modem.open(6767)
14-
  local _, _, _, port, _, protocole, energySource, receivedValue = event.pull("modem_message")
14+
  local _, _, _, port, _, protocole, energySource, receivedValue = event.pull("modem_message")
15-
  if(port == 6767 and protocole == "eProtocole" and energySource == "wind") then
15+
  if(port == 6767 and protocole == "eProtocole" and energySource == "wind") then
16-
    term.clear()
16+
    term.clear()
17-
    gpu.copy(1, 1, resx, resy,1,1,1,1)
17+
    gpu.copy(1, 1, resx, resy,1,1,1,1)
18-
    local barCalcul = math.floor((receivedValue/100000)*158)
18+
    local barCalcul = math.floor((receivedValue/100000)*158)
19-
    gpu.fill(1,3,1,3,"|")
19+
    gpu.fill(1,3,1,3,"|")
20-
    gpu.fill(160,3,1,3,"|")
20+
    gpu.fill(160,3,1,3,"|")
21-
    gpu.setBackground(0x006DFF)
21+
    gpu.setBackground(0x006DFF)
22-
    gpu.fill(2,3,barCalcul,3," ")
22+
    gpu.fill(2,3,barCalcul,3," ")
23-
    gpu.setBackground(0xD2D2D2)
23+
    gpu.setBackground(0xD2D2D2)
24-
    gpu.setForeground(0x000000)
24+
    gpu.setForeground(0x000000)
25-
    print("Energie Type: "..energySource.." "..math.floor(receivedValue).."/100000 - "..((math.floor(receivedValue)/100000)*100).."%")
25+
    print("Energie Type: "..energySource.." "..math.floor(receivedValue).."/100000 - "..((math.floor(receivedValue)/100000)*100).."%")
26-
    if(receivedValue == 0) then
26+
    if(receivedValue == 0) then
27-
      gpu.set(45,1,"Empty")
27+
      gpu.set(45,1,"Empty")
28-
    else
28+
    else
29-
      gpu.set(1,2,string.format("% 5s",(math.floor((receivedValue-previousValue)/3))).." RF/s")
29+
      gpu.set(1,2,string.format("% 5s",(math.floor((receivedValue-previousValue)/3))).." RF/s")
30-
    end
30+
    end
31-
    previousValue = receivedValue
31+
    previousValue = receivedValue
32-
   end
32+
   end
33
end