Advertisement
Guest User

startup

a guest
Dec 21st, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.07 KB | None | 0 0
  1. term.setCursorPos(1, 19)
  2. term.clear()
  3. rednet.open("bottom")
  4. local nickname = "User"
  5. local receiverID = nil
  6. write("Nickname: ")
  7. input = read()
  8. nickname = input
  9. term.clear()
  10. print("Your ID - "..os.getComputerID())
  11. write("Server ID: ")
  12. input = read()
  13. receiverID = tonumber(input)
  14. rednet.send(receiverID, "Pinging")
  15. recID, msg, connected = rednet.receive()
  16. if msg == "Pinged" and connected then
  17. print("Connected To Server "..recID)
  18. else
  19. print("Failed To Connect.")
  20. print("Press Any Key To Reboot")
  21. os.pullEvent("key")
  22. os.reboot()
  23. end
  24. term.clear()
  25. term.setCursorPos(1, 19)
  26.  
  27. local function receive()
  28.   senderID, msg, nick = rednet.receive()
  29.   term.setTextColor(colors.white)
  30.   print(nick..": "..msg)
  31. end
  32. local function send()
  33.   term.setCursorPos(1, 19)
  34.   term.setTextColor(colors.gray)
  35.   rednet.send(receiverID, read(), nickname)
  36. end
  37.  
  38. while true do
  39. term.setCursorPos(1, 1)
  40. term.setTextColor(colors.blue)
  41. print("Redhost Chat Program 1.0 - By BJ Rafferty")
  42. print("ID - "..os.getComputerID())
  43. term.setTextColor(colors.white)
  44. parallel.waitForAny(receive, send)
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement