Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- osPullEvent = osPullEventRaw
- shell.run("cd","..")
- shell.run("cd","disk")
- shell.run("cp","startup","startup")
- term.clear()
- term.setCursorPos(1,1)
- local function start()
- local correctid = 212 --Set this to whatever the server id
- rednet.open("left")
- rednet.send(correctid, "getturtleID")
- g,TurtleNetID = rednet.receive(5)
- TurtleNetID = TurtleNetID .. " "
- --print("Robot Fleet ID:"..TurtleNetID.. )
- rednet.send(correctid, "New turtle at " .. gps.locate(20, false))
- if TurtleNetID == nil then
- print("Could not get TurtleNet ID, please ctrl+t and try again")
- end
- running = 1
- while running == 1 do
- I,m,d = rednet.receive()
- if I ~== correctid then
- start()
- end
- if m == TurtleNetID .. "location" then
- rednet.send(I, gps.locate(20, false))
- end
- if m == TurtleNetID .. "forward" then
- if turtle.forward() == false then
- rednet.send(I, "Error moving forwards")
- end
- end
- if m == TurtleNetID .. "back" then
- turtle.backward()
- if turtle.backward() == false then
- rednet.send(I, "Error moving backwards")
- end
- end
- if m == TurtleNetID .. "up" then
- if turtle.up() == false then
- rednet.send(I, "Error moving up")
- end
- end
- if m == TurtleNetID .. "down" then
- turtle.down
- if turtle.down() == false then
- rednet.send(I, "Error moving down")
- end
- end
- if m == TurtleNetID .. "turn left" then
- turtle.turnLeft()
- rednet.send(I, "Turned left")
- end
- if m == TurtleNetID .. "turn right" then
- turtle.turnRight()
- rednet.send(I, "Turned right")
- end
- if m == TurtleNetID .. "dig front" then
- turtle.dig()
- rednet.send(I, "Dug front")
- end
- if m == TurtleNetID .. "dig up" then
- turtle.digUp()
- rednet.send(I, "Dug up")
- end
- if m == TurtleNetID .. "dig down" then
- turtle.digDown()
- rednet.send(I, "Dug down")
- end
- if m == TurtleNetID .. "place front" then
- if turtle.place() == false then
- rednet.send(I, "Error placing in front")
- end
- end
- if m == TurtleNetID .. "place up" then
- if turtle.placeUp() == false then
- rednet.send(I, "Error placing up")
- end
- if m == TurtleNetID .. "place down" then
- if turtle.placeDown() == false then
- rednet.send(I, "Error placing up")
- end
- end
- if m == TurtleNetID .. "detect front" then
- if turtle.detect == "true" then
- rednet.send(I, "Block in front")
- end
- end
- if m == TurtleNetID .. "detect up" then
- if turtle.detectUP() == false then
- ednet.send(I, "Block up")
- end
- end
- if m == TurtleNetID .. "detect down" then
- if turtle.detectDown() == false then
- rednet.send(I, "Block down")
- end
- end
- if m == TurtleNetID .. "spew" then
- turtle.drop()
- end
- if m == "reset ID" then
- rednet.send(I, TurtleNetID)
- end
- if m == "report in" then
- rednet.send(I, "Turtle ID ".. TurtleNetID .. " reporting in from " gps.locate(20, false))
- end
- if m == TurtleNetID .. "terminate" then
- running = 0
- end
- I,m,d = 0
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment