Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- peripheral.find("modem",rednet.open)
- local Protocol = "0000"
- local DirectorId = 0
- local Other = nil
- local ChargeCords = {}
- function Boot()
- local file = fs.open("os/SystemFiles/Turtle.txt","r")
- Protocol = file.readLine()
- DirectorId = file.readLine()
- ChargeCords = textutils.unserialize(file.readLine())
- file.close()
- end
- function Setup()
- local Folders = {"os","os/SystemFiles"}
- for i = 1, #Folders do
- if fs.exists(Folders[i]) then
- else
- fs.makeDir(Folders[i])
- end
- end
- if fs.exists("os/SystemFiles/Turtle.txt") then
- else
- Ex = {1,2,3}
- local file = fs.open("os/SystemFiles/Turtle.txt","w"(
- file.writeLine("Protocol")
- file.writeLine("Director id")
- file.writeLine(textutils.serialize(Ex,{compact = true})
- file.close()
- end
- exit()
- end
- function Main()
- while true do
- local id, message = rednet.receive(Protocol)
- if id == DirectorId then
- local Directive = textutils.unserialize(message)
- shell.run("Mover",Directive[1],Directive[2],Directive[3],Directive[4])
- if Directive[5] == "shutdown" then
- break
- elseif Directive[5] == "take" then
- turtle.suck(Directive[6])
- elseif Directive[5] == "activate" then
- peripherals.find(Directive[6],Directive[7])
- elseif Directive[5] == "deposit" then
- turtle.select(Directive[6])
- turtle.drop(Directive[7])
- elseif Other ~= nil then
- shell.run(Other,Directive)
- end
- end
- rednet.send(DirectorId,"standby")
- end
- os.shutdown()
- end
- if fs.exists("os/SystemFiles/Turtle.txt") then
- Boot()
- if Other ~= nil then
- shell.run(Other,"Start")
- end
- Main()
- else
- Setup()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement