the overall program is one turtle sets up 36 chests for 36 turtles to move to and run excavate, after excavte finishes, each of the 36 turtles returns to where turtle 37 started them from and turtle 37 picks them up. this was to make a 'quarry' kind of thing.
ok so… here's all the code im trying to use, and also the flow
This is the program being run on the main computer. the main computer is positioned to the left of the disk drive, and all drone turtles are plced below the drive to receive their instructions.. I'm still new to lua so I wrote each individual turtle (36 total) 2 programs each, one which moves it to position, one which returns it after. also there is a 3rd program, named dark. dark is just used to put the turtle into a wait mode until it receives a rednet signal 'go' which makes the turtle begin to dig.
--main computer to copy paths returns and dark to miners. must have disk to side
rednet.open("top")
fs.copy("disk/dark","dark")
fs.makeDir("paths")
fs.makeDir("returns")
count=1
while count <=36 do
fs.copy("disk/paths/"..count,"paths/"..count)
fs.copy("disk/returns/"..count.."r","returns/"..count.."r")
count = count + 1
end
count=1
while count <= 36 do
x,y,z=rednet.receive()
print(y)
if y=="copy" then
fs.copy("paths/"..count,"disk/startup")
fs.copy("returns/"..count.."r","disk/return")
fs.copy("dark","disk/dark")
rednet.broadcast("copied")
sleep(1)
fs.delete("disk/dark")
fs.delete("disk/return")
fs.delete("disk/startup")
count = count + 1
end
end
count=1
while count <=36 do
x,y,z=rednet.receive()
print(y)
if y=="waiting" then
count = count + 1
end
end
if count == 36 then
rednet.broadcast("go")
print("Excavation started.")
end
also, so its clear, the main turtle (we will jsut call him 37) sets up the computer, places a modem, and then turns on the computer so it runs the startup file on the disk, which copies all the paths, returns and the dark file. afterwards turtle 37 removes the computer disk and replaces it with a blank disk to facilitate moving the files from the computer to the drone turtle (1-36) when it received the rednet signal 'copy' after it copies the files, it sends a signal saying it is copied, then turtle 37 turns on the drone, the drone fuels itself, the moves out of its starting position and sends a signal 'moved' which then lets turtle 37 place the next turtle and the whole thing is supposed to repeat for all 36 turtles.
here is the portion of code used to start and copy files and turn on the drones that is on turtle 37. i didn't post the portion where he goes around and sets up the chests because the whole program is 1k lines of code.
--turn on device
function itemOn()
t=peripheral.wrap("front")
t.turnOn()
end
-- turtle places miners
rednet.open("right")
count=1
while count <= 36 do
turtle.select(16)
turtle.place()
sleep(.1)
rednet.broadcast("copy")
x,y,z=rednet.receive()
print(y)
if y=="copied" then
itemOn()
count = count + 1
end
x,y,z=rednet.receive()
print(y)
if y=="moved" then
sleep(.1)
end
end
-- turtle picks up miners
count=1
while count <= 36 do
if turtle.detect() then
turtle.dig()
count=count+1
else
turtle.sleep(.01)
end
end
turtle.forward()
while true do
turtle.turnRight()
end
and here is an example of one of the turtle programs to show what the drone does as far as saying it has moved out of the way
--Tunneler
function tunnel()
goForward()
turtle.digUp()
turtle.placeUp()
turtle.digDown()
end
-- Ensure turtle goes up
function goUp()
while not turtle.up() do
upDig()
end
end
--Ensure turtle goes down
function goDown()
while not turtle.down() do
downDig()
end
end
--place floor
function pFloor()
if turtle.detectDown() then
goForward()
else
turtle.placeDown()
goForward()
end
end
-- Ensure turtle moves forward
function goForward()
while not turtle.forward() do
forwardDig()
end
end
-- Dig forward
function forwardDig()
while turtle.detect() do
turtle.dig()
end
end
-- Dig up
function upDig()
while turtle.detectUp() do
turtle.digUp()
end
end
-- Dig Down
function downDig()
while turtle.detectDown() do
turtle.digDown()
end
end
fs.copy("disk/dark","dark)"
fs.copy("disk/return","return")
turtle.turnRight()
turtle.suck()
turtle.refuel(8)
turtle.drop()
turtle.turnLeft()
turtle.turnLeft()
--Turtle1
goDown()
rednet.broadcast("moved")
goDown()
goForward()
goForward()
turtle.turnLeft()
goForward()
goDown()
turtle.turnRight()
turtle.broadcast("waiting")
shell.run("dark")
EDIT:
adding the program dark
x,y,z=rednet.receive()
print(y)
if y=="go" then
shell.run("excavate 10")
end
shell.run("return")