LDShadowLord

TestUmbra

Feb 17th, 2013
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.41 KB | None | 0 0
  1. tArgs = {...}
  2. --Umbra - 1.5 Enabled IRC Chat
  3. --Designed and coded by LDShadowLord, for use by the CCU server.
  4.  
  5. --Making it look purty
  6. verrbar = "==VERR============================================="
  7. umbrabar = "Umbra, the VERR default chat application!"
  8. commands = "Use /<command> to use commands!"
  9.  
  10. --Defining some Variables
  11. w,h = term.getSize()
  12.  
  13. --Wrapping to the modem, change the value if your modem is not located on the top.
  14. modem = peripheral.wrap("top")
  15.  
  16. --Opening the two channels that we will be operating on.
  17. local sendChannel = 016613
  18. local replyChannel = 026613
  19. modem.open(sendChannel) --Channel to send on
  20. modem.open(replyChannel) --Channel to receive on
  21.  
  22. --Opening servers
  23. --local CCUserver = 654321
  24. --local VerrDef1 = 016613
  25. --local VerrDef2 = 026613
  26. --modem.open(CCUserver)
  27. --modem.open(VerrDef1)
  28. --modem.open(VerrDef2)
  29.  
  30. --Defining a 'Login' function.
  31. local function login()
  32.   local id = os.getComputerID()
  33.   while true do
  34.     term.clear()
  35.     term.setCursorPos(1,1)
  36.     print(verrbar)
  37.     print(umbrabar)
  38.     print("Hello! Please enter your name to use this program!")
  39.     input = read()
  40.     if input == "" then
  41.       print("I am sorry, but that is not a valid username :( ")
  42.       login()
  43.     else
  44.       print("Hello, "..input.."! We will now redirect you to the server screen!")
  45.       modem.transmit(sendChannel, replyChannel, input.." has logged in from ID: "..id)
  46.       sleep(2)
  47.       term.clear()
  48.       term.setCursorPos(1, h-2)
  49.       term.write(string.rep("*", w))
  50.       parallel.waitForAny(sendMessages, listenForMessages)
  51.     end
  52.   end
  53. end
  54.  
  55. local function listenForMessages()
  56.   while true do
  57.      local id, msg = rednet.receive()
  58.      if h == 16 then
  59.        term.setCursorPos(1,1)
  60.      end
  61.      local oldx,oldy = term.getCursorPos()
  62.      term.setCursorPos(1, w + 1)
  63.      term.clearLine()
  64.      if string.find(msg, "::") then
  65.        term.write(string.gsub(msg, "::", ":"))
  66.      else
  67.        term.write(id..":"..msg)
  68.     end
  69.      term.setCursorPos(oldx, oldy)
  70.   end
  71. end
  72.  
  73. local function sendMessages()
  74.   term.setCursorPos(1, h-1)
  75.   while true do
  76.     message = io.read()
  77.     if message == "/exit" then
  78.       break
  79.     end
  80.     modem.transmit(sendChannel, replyChannel, os.getComputerLabel().."::"..message)
  81.     term.setCursorPos(1, h + 1)
  82.     print(os.getComputerLabel()..":"..message)
  83.     term.setCursorPos(1, h-1)
  84.     term.clearLine()
  85.   end
  86. end
  87.  
  88. login()
Advertisement
Add Comment
Please, Sign In to add comment