Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- args = { ... }
- local rootId = tonumber(args[1])
- 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")
- local done = false
- while not done do
- io.write("local-network>")
- local input = read()
- local id, msg = rednet.receive(0.1)
- if id ~= nil then
- local tag, pts = getMsgData(msg)
- if tag == "@programs" then
- if pts[1] == "terminate" then
- done = true
- break
- else print("unknown message: ", msg)
- end
- end
- end
- if input ~= nil then
- local pts = string:split(input, " ")
- if pts[1] == "reboot" then --todo maybe with password
- rednet.send(rootId, "@root:reboot")
- done = true
- else print("unknown command: " .. pts[1])
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement