Advertisement
Guest User

tower

a guest
Jan 31st, 2015
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.64 KB | None | 0 0
  1.  
  2. p = peripheral.find("bitnet_tower")
  3. tArgs = {...}
  4.  
  5. function receive()
  6.  print("Waiting message...")
  7.  while true do
  8.   event, side, message, distance = os.pullEvent("bitnet_message")
  9.   print("\nReceived message: "..message)
  10.   print("Received from "..distance.." blocks away")
  11.  end
  12. end
  13.  
  14. function pressKeyStop()
  15.  print("Press any key to stop")
  16.  os.pullEvent("char")
  17. end
  18.  
  19. function send()
  20.  print("What do I send?")
  21.  p.transmit(read())
  22. end
  23.  
  24. print("Send or Receive mode?\n(Use 'send' or 'receive')")
  25.  
  26. if tArgs[1] == "send" then
  27.  send()
  28. elseif tArgs[1] == "receive" then
  29.  parallel.waitForAny(pressKeyStop, receive)
  30. else print("What?")
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement