View difference between Paste ID: Ds1uepPR and Qa2zTNWp
SHOW: | | - or go back to the newest paste.
1
rednet.open('back')
2
status = nil
3
4
while true do
5
  if status == nil then
6
    print("Send status to #148")
7
    rednet.send(148, "status")
8
    local res1, res2 = rednet.receive()
9
    status = res2
10
    print("Received status: "..tostring(status).."\nReload..")
11
    sleep(4)
12
  end
13
  
14
  if status then
15
    term.clear()
16
    term.setCursorPos(1, 1)
17
    print("CLICCA UN TASTO PER PARTIRE!")
18-
    os.pullEvent('key')
18+
    local event, id, msg = os.pullEvent()
19-
    rednet.send(148, "down")
19+
    if event == 'rednet_message' then
20-
    print("\nL'ascensore sta scendendo...")
20+
      if msg == "invertProp" then
21-
    rednet.receive()
21+
        status = false
22-
    status = false
22+
      end
23
    elseif event == 'key' then
24
      rednet.send(148, "down")
25
      print("\nL'ascensore sta scendendo...")
26
      rednet.receive()
27-
    os.pullEvent('key')
27+
      status = false
28-
    rednet.send(148, "up")
28+
    end
29-
    print("\nL'ascensore sta salendo...")
29+
30-
    rednet.receive()
30+
31-
    status = true
31+
32
    print("CLICCA UN TASTO PER CHIAMARE")
33
    local event, id, msg = os.pullEvent()
34
    if event == 'rednet_message' then
35
      if msg == "invertProp" then
36
        status = true
37
      end
38
    elseif event == 'key' then
39
      rednet.send(148, "up")
40
      print("\nL'ascensore sta salendo...")
41
      rednet.receive()
42
      status = true
43
    end
44
  end
45
end