Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local sides = rs.getSides()
- local updateFromShell = args[1]
- local turtleType = args[2]
- local turtle_channel = "coms_turtles_" .. turtleType
- for i = 1, #sides do
- side = sides[i]
- if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
- rednet.open(side)
- break
- end
- end
- if updateFromShell == "true" then
- rednet.receive(turtle_channel)
- end
- rednet.broadcast("UPDATE_READY", turtle_channel)
- id, msg = rednet.receive("coms_turtles_payload", 15)
- print("Received msg: " .. msg)
- if not msg then
- print("Failed to receieve an updated program packet!")
- else
- packet = textutils.unserialize(msg)
- file = fs.open(packet.name, "w")
- file.write(packet.content)
- file.close()
- print("Update successful. Rebooting turtle..")
- sleep(1)
- os.reboot()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement