Advertisement
FoxWorn3365

Clientside-elevator

Apr 15th, 2023 (edited)
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     local event, id, msg = os.pullEvent()
  19.     if event == 'rednet_message' then
  20.       if msg == "invertProp" then
  21.         status = false
  22.       end
  23.     elseif event == 'key' then
  24.       rednet.send(148, "down")
  25.       print("\nL'ascensore sta scendendo...")
  26.       rednet.receive()
  27.       status = false
  28.     end
  29.   else
  30.     term.clear()
  31.     term.setCursorPos(1, 1)
  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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement