Advertisement
Guest User

control.lua

a guest
Oct 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1. peripheral.find("modem", rednet.open)
  2.  
  3. print("Waiting for remote connection...")
  4. while true do
  5.     -- Always wait for a connection
  6.     local remoteId, message = rednet.receive()
  7.     if message == "connect" then
  8.         print("Connected to "..remoteId)
  9.         -- Main loop once connected
  10.         while true do
  11.             local sender, command = rednet.receive("command", 60)
  12.             if sender == nil then
  13.                 print("Disconnected from "..remoteId)
  14.                 break
  15.             else if sender == remoteId then
  16.                 print(command)
  17.                 shell.run(command)
  18.             end
  19.         end
  20.     end
  21. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement