Advertisement
justync7

cctor

Jun 24th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. function split(str, pat)
  2. local t = {} -- NOTE: use {n = 0} in Lua-5.0
  3. local fpat = "(.-)" .. pat
  4. local last_end = 1
  5. local s, e, cap = str:find(fpat, 1)
  6. while s do
  7. if s ~= 1 or cap ~= "" then
  8. table.insert(t,cap)
  9. end
  10. last_end = e+1
  11. s, e, cap = str:find(fpat, last_end)
  12. end
  13. if last_end <= #str then
  14. cap = str:sub(last_end)
  15. table.insert(t, cap)
  16. end
  17. return t
  18. end
  19. rednet.open("top")
  20. while true do
  21. id, msg=rednet.receive()
  22. if msg=="torlist;" then
  23. rednet.send(id,os.getComputerID())
  24. print("LOG: Got tor list")
  25. elseif msg:sub(1,5)=="cast:" then
  26. rednet.broadcast(msg:sub(6))
  27. print("LOG: Used broadcast")
  28. elseif msg:sub(1,5)=="send:" then
  29. args=split(msg,":")
  30. sendid=args[2]
  31. sendmsg=args[3]
  32. rednet.send(sendid,sendmsg)
  33. print("LOG: Used send")
  34. end
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement