tommy2805

programma ascensore piano 2

Jun 1st, 2024 (edited)
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. -- Inizializza Rednet sul lato inferiore del computer
  2. rednet.open("bottom")
  3.  
  4. -- Funzione per gestire i messaggi ricevuti
  5. function handleMessages()
  6.     while true do
  7.         local senderId, message = rednet.receive()
  8.  
  9.         if message == "lasciando piano 1" then
  10.             print("muovo giu")
  11.             redstone.setBundledOutput("back", colors.yellow)
  12.         elseif message == "lasciando piano 2" then
  13.             print("muovo su")
  14.             redstone.setBundledOutput("back", colors.lime)
  15.         elseif message == "stop" then
  16.             print("stop")
  17.             local currentOutput = redstone.getBundledOutput("back")
  18.             if currentOutput ~= 0 then
  19.                 redstone.setBundledOutput("back", 0)
  20.                 sleep(0.3)
  21.                 redstone.setBundledOutput("back", currentOutput)
  22.                 sleep(0.3)
  23.                 redstone.setBundledOutput("back", 0)
  24.             end
  25.         end
  26.     end
  27. end
  28.  
  29. -- Avvia la gestione dei messaggi
  30. handleMessages()
  31.  
Advertisement
Add Comment
Please, Sign In to add comment