Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modemSide
- for _, name in ipairs(peripheral.getNames()) do
- if peripheral.getType(name) == "modem" then
- modemSide = name
- end
- end
- if modemSide == nil then
- error("no modem connected")
- end
- rednet.open(modemSide)
- print("sending initialization beacon")
- rednet.broadcast({ at = "mainFrame", command = { "turti", "init" } })
- while true do
- local id, msg = rednet.receive(5)
- if not id then
- print("sending initialization beacon")
- rednet.broadcast({ at = "mainFrame", command = { "turti", "init" } })
- else
- if msg.at == "turtle" then
- if msg.command[1] == "mainFrame" then
- --[[ if msg.command[2] == "update" then
- print(index)
- else
- print("unknown command: " .. msg.command[2])
- end]]
- elseif msg.command[1] == "initData" then
- local data = msg.data
- write("writing init files... ")
- for name, content in pairs(data.setupFiles) do
- local file = fs.open(name, "w")
- file.write(content)
- file.close()
- end
- print("done")
- if data.executeFile then
- print("executing '" .. data.executeFile .. "'...")
- print()
- shell.run(data.executeFile)
- return
- end
- else
- print("unknown command: " .. msg.command[1])
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment