Advertisement
Guest User

Untitled

a guest
May 10th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. local term = require("term")
  2. local component = require("component")
  3. local event = require("event")
  4. local m = component.modem
  5. local str="0"
  6.  
  7. -- determine what channel people want to listen on
  8. term.write("What channel do you want to chat on? \n")
  9. local channel=io.read()
  10. m.open(tonumber(channel))
  11. -- begin event
  12. event.listen("modem_message", function(_,_,from,port,_,message)
  13. -- decipher, and print
  14. local cipher = "1234567890qwertyuiopasdfghjklzxcvbnm"
  15. local function decrypt(str)
  16. str = str:gsub("%d",function(a) return string.char(cipher:find(a,nil,true)+47) end)
  17. str = str:gsub("%l",function(a) return string.char(cipher:find(a,nil,true)+86) end)
  18. return str
  19. end
  20. if string.sub(tostring(message), 1, 9)=="encrypted" then
  21. str=tostring(message)
  22. message=decrypt(str)
  23. print("Got a message from " .. from .. " on port " .. port .. ": " .. tostring(message))
  24.  
  25. else
  26. print("Got a message from " .. from .. " on port " .. port .. ": " .. tostring(message))
  27. end
  28. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement