Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function string: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 = string:split(string.sub(msg,i+1,-1), ",")
- return tag,pts
- end
- --syslib end
- rednet.open("back")
- function identify()
- rednet.broadcast("@root:identify")
- end
- identify()
- while true do
- local id, message = rednet.receive()
- local tag, pts = getMsgData(message)
- if tag == "root" then
- if pts[1] == "initialise" then
- identify()
- else print("unknown fromRoot-msg: ", tag)
- end
- else
- print("unknown msg-tag: ", tag)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement