This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Arrk's profile picture

Programing Multiple Wireless Turtles?

Started by Arrk, 13 July 2012 - 08:13 AM
Arrk #1
Posted 13 July 2012 - 10:13 AM
Hello. I have build 140 Wireless Mining Turtles and I want them all to execute this one program at the same time:
while true do
turtle.up(1)
turtle.placedown(1)
end

I was wondering if there was anyway I could use a Computer with a Moden on it, to make all the turtles execute the command at the same time? Thank you.
KevinW1998 #2
Posted 13 July 2012 - 10:30 AM
You can't use like turtle.up(1)
You need to use rednet: http://computercraft.info/wiki/index.php?title=Rednet_%28API%29

Turtle Program:

while true do
rednet.open()
local id, mgs, dis = rednet.receive()
if mgs == "<start>" then
turtle.up()
turtle.placeDown()
break
end
end

Main Computer Program:

rednet.open()
rednet.broadcast("<start>")
Arrk #3
Posted 13 July 2012 - 10:32 AM
Do I have to enter the Turtle program into each turtle separately?
KevinW1998 #4
Posted 13 July 2012 - 10:38 AM
You can copy this code to each turtle
Arrk #5
Posted 13 July 2012 - 10:39 AM
But I still have to interact with each turtle separately, correct?
KevinW1998 #6
Posted 13 July 2012 - 10:44 AM
Do you mean copying the turtle-program or using the turtle itself?
Arrk #7
Posted 13 July 2012 - 10:46 AM
I have to write the program on one turtle and then copy it to each remaining turtle one by one, right?
KevinW1998 #8
Posted 13 July 2012 - 10:50 AM
Yep! But if your using Singelplayer you can go to .minecraft/saves/[world name]/computer and copy the file to each turtle very easy ^^
Arrk #9
Posted 13 July 2012 - 10:50 AM
Also, what does the "break" at the end of your code does?
KevinW1998 #10
Posted 13 July 2012 - 10:51 AM
break the loop… if you want to using it serveral time then remove it
Arrk #11
Posted 13 July 2012 - 10:57 AM
When I type this into the comptuer I get an error message;
>rednet.open()
No such program
KevinW1998 #12
Posted 13 July 2012 - 10:59 AM
this is a lua/cc method no program !!!!
Arrk #13
Posted 13 July 2012 - 11:00 AM
Ohhhh, ok then, thanks.
Arrk #14
Posted 13 July 2012 - 11:06 AM
Could I get some more help.
So I open the Computer and type in:
>Lua
>rednet.open(top)
and I get this error: rednet:313: string expected
KevinW1998 #15
Posted 13 July 2012 - 11:09 AM
1. Write a program using "edit <myprogram-name>" e.g. "edit turtleprogram"
and execute it then with the program name "turtleprogram"
2. rednet.open("top") the sides are strings: "top","right","bottom","left","back","front"
Arrk #16
Posted 13 July 2012 - 11:14 AM
Yeah I wrote the program on the turtle like this:
>edit d
while true do
rednet.open()
local id, mgs, dis = rednet.receive()
if mgs == "<start>" then
turtle.up()
turtle.placeDown()
break
end
end
then press CTRL and save the program, exit the menu and type in:
>d
and I get:
bios:206: [string "d"]:3: '='
expected
KevinW1998 #17
Posted 13 July 2012 - 11:22 AM
very strange…
If I test it I get an other error… try to edit line 2 with:
rednet.open(<yourside>) with the side of the modem
Arrk #18
Posted 13 July 2012 - 11:28 AM
Doesn't work, still the same error message.
KevinW1998 #19
Posted 13 July 2012 - 11:30 AM
have you put rednet.receive in "()" = "rednet.receive()"
Edit: Give me the line 3 exactly you have written in the file
Arrk #20
Posted 13 July 2012 - 11:34 AM
1)while true do
2)rednet.open(back)
3)local id, mgs, dis = rednet.receive()
KevinW1998 #21
Posted 13 July 2012 - 11:41 AM
2. line should be
rednet.open("back")
instad of
rednet.open(back)
Arrk #22
Posted 13 July 2012 - 11:51 AM

It's like this now, when I changed (back) to ("back") on both the turtle and the computer, but the turtle is doing nothing right now, and I can't enter any commands into it.
KevinW1998 #23
Posted 13 July 2012 - 11:58 AM
1. You can Termanite the turtleprogram using ctrl+T
2. The main Computer must be in range of 64 blocks to the turtles (if there is a storm then only 16 blocks)
Arrk #24
Posted 13 July 2012 - 12:00 PM
Yeah, I terminated the program, and the computer is 6 blocks away from the turtle, but when I type in the command it doesn't do anything at all. The turtle just stands there in place.
So, after I program the Turtle, I just type in the broadcast part in the computer and the turtle should activate?
KevinW1998 #25
Posted 13 July 2012 - 12:05 PM

while true do
rednet.open()
local id, mgs, dis = rednet.receive()
if mgs == "<start>" then
print("Debug: "..id..", "..mgs..", "..dis..)
turtle.up()
turtle.placeDown()
break
end
end
use the print method for debug.. I am not quite sure why it doesn't work :/
Arrk #26
Posted 13 July 2012 - 12:09 PM
If I enter the broadcast commnd nothing happens, but If I start the program:
>d
bios:206: [string "d"]:5:
unexpected symbol
KevinW1998 #27
Posted 13 July 2012 - 12:14 PM
um sry the last to points ".." should be removed

print("Debug: "..id..", "..mgs..", "..dis)

Arrk #28
Posted 13 July 2012 - 12:16 PM
If I start the program with
>d
then it freezes up, but if I use the broadcast command, nothing happens :/.
KevinW1998 #29
Posted 13 July 2012 - 12:24 PM
mhh this means the message doesn't get to the turtle…..
Btw: which side is the modem at the turtle?
Arrk #30
Posted 13 July 2012 - 12:27 PM
the modem is on "back" and on "right"
KevinW1998 #31
Posted 13 July 2012 - 12:30 PM
Yep the turtle modem is Always on the right side…….
my last try for debug:

while true do
rednet.open("right")
local id, mgs, dis = rednet.receive()
print("Debug: "..id..", "..mgs..", "..dis)
if mgs == "<start>" then
turtle.up()
turtle.placeDown()
break
end
end

If you don't get any informathions we need to check the main computer
Arrk #32
Posted 13 July 2012 - 12:31 PM
Can't acces my PC at this time, will check this out in ~30 minutes.
Arrk #33
Posted 13 July 2012 - 02:35 PM
I changed it to the one you listed above but it still doesn't work.
Same problem as before.