Advertisement
machasins

long distance button

Jul 15th, 2022 (edited)
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.53 KB | None | 0 0
  1. peripheral.find("modem", rednet.open)
  2. local input = false
  3. print("Starting loop")
  4. while (true)
  5. do
  6.   if (redstone.getInput("left")) then
  7.     if (input == false) then
  8.       print("Sending ping...")
  9.       rednet.send(tonumber(arg[1]), "ping")
  10.     end
  11.     input = true
  12.   else
  13.     input = false
  14.   end
  15.   local id, msg = rednet.receive(nil, 0.1)
  16.   if (id == tonumber(arg[1]) and msg == "ping") then
  17.     print("Received ping...")
  18.     redstone.setOutput("right", true)
  19.     os.sleep(1)
  20.     redstone.setOutput("right", false)
  21.   end
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement