Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("top")
- x, y, z = gps.locate(2, false)
- function send(x1, y1, z1, message)
- return rednet.broadcast(x1.. ":(@!#!):" ..y1.. ":(@!#!):" ..z1.. ":(@!#!):" ..message)
- end
- function receive( nTimeout )
- local timer = nil
- if nTimeout then
- timer = os.startTimer( nTimeout )
- end
- while true do
- local e, p1, p2, p3 = os.pullEvent()
- if e == "rednet_message" then
- local tWords = {}
- for match in string.gmatch(p3, "[^:(@!#!):\t]+") do
- table.insert( tWords, match )
- end
- if(not tWords[4] == nil)then
- if(tWords[1] == x and tWords[2] == y and tWords[3] == z)then
- return tWords[1], tWords[2], tWords[3], tWords[4]
- end
- end
- elseif e == "timer" and p1 == timer then
- return nil, nil, nil
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment