Advertisement
peptide

ControlNet - MainConsole

May 2nd, 2013
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.13 KB | None | 0 0
  1. function clear()
  2.  term.clear()
  3.  term.setCursorPos(1,1)
  4. end
  5.  
  6. rednet.open("top")
  7. username = "Chum"
  8. local chatBuddy = nil
  9.  
  10. function help()
  11.  print("Welcome to Pesterchum 1.0")
  12.  print("Press C to Connect")
  13.  print("Press H to set your Handle")
  14.  print("Press A to Abscond to menu")
  15.  print("Press T to Type")
  16. end
  17.  
  18. clear()
  19. help()
  20.  
  21. while true do
  22.  event, id, msg = os.pullEvent()
  23.  
  24.  if event == "rednet_message" and id == chatBuddy then
  25.   print(msg)
  26.  
  27.  elseif event == "char" then
  28.  
  29.   if id == "t" then
  30.    write(username.." > ")
  31.    msgsent = read()
  32.    if chatBuddy ~= nil then
  33.     rednet.send(chatBuddy,username.." > "..msgsent)
  34.    else
  35.     print("Quit talking to yourself, dumbass!")
  36.     --always punish users for doing stuff wrong
  37.    end
  38.  
  39.   elseif id == "h" then
  40.    write("New username: ")
  41.    username = read()
  42.  
  43.   elseif id == "c" then
  44.    write("Chum ID: ") --put your chum's computer ID here
  45.    chatBuddy = tonumber(read())
  46.    clear()
  47.    print("Conncted. You may chat if your chum")
  48.    print("is connected to you right now")
  49.  
  50.   elseif id == "a" then
  51.    chatBuddy = nil
  52.    clear()
  53.    help()
  54.  
  55.   end
  56.  
  57.  end
  58.  
  59. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement