Advertisement
Daraketh

Send Message Basic

Jul 4th, 2013
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1. local compID = 0
  2. local message = ""
  3. local chatName = ""
  4.  
  5. function help()
  6.  
  7.     print("Please type the following commands to perform the described function:")
  8.     print("Type /name to enter the name change function")
  9.     print("Type /id to enter the ID change function")
  10.     print("Type /clearscreen to clear the chat client screen")
  11.     print("Type /clearscreenr to clear the receival monitor screen")
  12.     print("Type /reboot to restart the client machine")
  13.     print("Type /rebootr to restart the receival machine")
  14.    
  15.     return
  16.    
  17. end
  18.  
  19. function name(name)
  20.  
  21.     print("Please enter desired chat name: ")
  22.     name = read()
  23.    
  24.     return name
  25.    
  26. end
  27.  
  28. function id(id)
  29.  
  30.     print("Please enter ID of receiving server: ")
  31.     id = read()
  32.    
  33.     return id
  34.    
  35. end
  36.  
  37. function clearscreen()
  38.  
  39.     term.clear()
  40.     term.setCursorPos(1,1)
  41.    
  42.     return
  43.    
  44. end
  45.  
  46. function clearscreenr(id)
  47.  
  48.     rednet.send(tonumber(id), "()clear()")
  49.    
  50.     return
  51.    
  52. end
  53.  
  54. function reboot()
  55.  
  56.     os.reboot()
  57.    
  58.     return
  59.    
  60. end
  61.  
  62. function rebootr(id)
  63.  
  64.     rednet.send(tonumber(id), "()reboot()")
  65.    
  66.     return
  67.    
  68. end
  69.  
  70. term.clear()
  71. term.setCursorPos(1,1)
  72.              
  73. print("Welcome to the chat client!\n")
  74.              
  75. compID = id(compID)
  76.              
  77. term.clear()
  78. term.setCursorPos(1,1)
  79.              
  80. chatName = name(chatName)
  81.              
  82. term.clear()
  83. term.setCursorPos(1,1)
  84.              
  85. rednet.open ("top")  
  86.  
  87. print("Type /help for a list of commands\n")
  88.  
  89. while true do
  90.              
  91.     print("Enter Message: ")
  92.     message = read()
  93.    
  94.     if message == "/help" then
  95.    
  96.         help()
  97.        
  98.     elseif message == "/name" then
  99.    
  100.         chatName = name(chatName)
  101.        
  102.     elseif message == "/id" then
  103.    
  104.         compID = id(compID)
  105.        
  106.     elseif message == "/clearscreen" then
  107.    
  108.         clearscreen()
  109.        
  110.     elseif message == "/clearscreenr" then
  111.    
  112.         clearscreenr(compID)
  113.        
  114.     elseif message == "/reboot" then
  115.    
  116.         reboot()
  117.        
  118.     elseif message == "/rebootr" then
  119.    
  120.         rebootr(compID)
  121.        
  122.     else
  123.    
  124.         rednet.send (tonumber(compID), (chatName)..":")
  125.         sleep (0.08)
  126.         rednet.send (tonumber(compID), (message))
  127.         sleep (0.08)
  128.         rednet.send (tonumber(compID), "-----------------------------")
  129.        
  130.     end
  131.                              
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement