Advertisement
DerMarten

Server

Sep 2nd, 2013
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. local empaenger = 3
  2. local message = ""
  3. local modemside = "right"
  4. local senderId = 0
  5. function string:split(sSeparator, nMax, bRegexp)
  6.         assert(sSeparator ~= '')
  7.         assert(nMax == nil or nMax >= 1)
  8.  
  9.         local aRecord = {}
  10.  
  11.         if self:len() > 0 then
  12.                 local bPlain = not bRegexp
  13.                 nMax = nMax or -1
  14.  
  15.                 local nField=1 nStart=1
  16.                 local nFirst,nLast = self:find(sSeparator, nStart, bPlain)
  17.                 while nFirst and nMax ~= 0 do
  18.                         aRecord[nField] = self:sub(nStart, nFirst-1)
  19.                         nField = nField+1
  20.                         nStart = nLast+1
  21.                         nFirst,nLast = self:find(sSeparator, nStart, bPlain)
  22.                         nMax = nMax-1
  23.                 end
  24.                 aRecord[nField] = self:sub(nStart)
  25.         end
  26.  
  27.         return aRecord
  28. end
  29. function send()
  30.         rednet.send(empaenger,message,true)
  31.         print("senden")
  32. end
  33. function connect()
  34.     if rednet.isOpen(modemside) == false then
  35.         rednet.open(modemside)
  36.     end
  37. end
  38. function recive()
  39.     while true do
  40.         local senderId, message, distance = rednet.receive()
  41.         senderId = senderId
  42.         message = message
  43.         print(message)
  44.     end
  45. end
  46. -- Main --
  47. connect()
  48. while true do
  49.     local senderId, message, distance = rednet.receive()
  50.     rednet.send(empaenger,message,true)
  51.     os.sleep(0.0001)
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement