Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function split(s, delimiter)
- local result = {};
- for match in (s .. delimiter):gmatch("(.-)" .. delimiter) do
- table.insert(result, match);
- end
- return result;
- end
- function getMsgData(msg)
- local i, j = string.find(msg, ":")
- local tag = string.sub(msg, 1, i - 1)
- local pts = split(string.sub(msg, i + 1, -1), ",")
- return tag, pts
- end
- function log(group, txt)
- rednet.broadcast("@log:" .. group .. "," .. txt)
- end
- function receiveRednet()
- while true do
- local id, msg = rednet.receive()
- if type(msg) == "string" then
- if string.len(msg) > 13 and string.sub(msg, 1, 14) == "<transmitted>:" then
- msg = string.sub(msg, 15, -1)
- local i=string.find(msg,",")
- id=tonumber(string.sub(msg,1,i-1))
- msg=string.sub(msg,i+1,-1)
- end
- if string.find(msg, ":") ~= nil then
- return id, msg
- end
- end
- end
- end
- function getRawLabel(label)
- local l,l2=getLabelParts(label)
- if l2=="" then l2=label end
- return l2
- end
- function getLabelParts(label)
- local i=string.find(label,"/")
- if i~=nil then
- return string.sub(label,0,i-1),string.sub(label,i+1,-1)
- end
- return label,nil
- end
- function sendRednet(id,msg)
- rednet.send(id,msg)
- rednet.broadcast("@other:"..id..","..msg)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement