I created a mining machine with CC. It is controlled by one Master Computer and 15 turtles. I coded everything with timing, but the time the turtles need is variable. When the time the turtles need >> the time the computer is coded, everything gets clogged up.
That's why I changed the coding. (When the turtles are done, they send a security message back, and when the computer has 15 messages, it does the next loop). The problem is that I don't know what is wrong with the code.
This is my code:
Computer:
Autocycle:
while true do
if redstone.getInput("top") == true then
shell.run("cycle2")
end
sleep(2)
end
cycle2:
local dingetje = 0
function continue()
rednet.open("right")
while true do
senderID, message, distance = rednet.receive()
dingetje = dingetje + 1
if dingetje == 15 then
dingetje = 0
shell.run("cycle2")
end
end
end
local tArgs={...}
if tArgs[1] == nil then tArgs[1] = 1 end
for i = 1, tArgs[1] do
shell.run("move")
sleep(1)
shell.run("command")
print("Iteration: "..i)
end
continue()
Turtles:
AwaitCommand:
rednet.open("right")
while true do
senderID, message, distance = rednet.receive()
print(message)
shell.run(message)
end
Mine:
function deploy()
turtle.select(1)
turtle.place()
end
function clearInv()
for i = 1,16 do
turtle.select(i)
turtle.dropDown()
end
turtle.select(1)
end
function getMiner()
turtle.select(1)
while turtle.getItemCount(1) > 0 do
clearInv()
sleep(1)
end
turtle.dig()
end
deploy()
sleep(3)
clearInv()
sleep(3)
clearInv()
getMiner()
rednet.open("right")
rednet.send(21, "done")
Can someone help me?
Note: I labeled all of my turtles to q1, maybe that wasn't a real smart thing to do…
Note2: Rednet gets opened in two separate programs for the turtles.