18 posts
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.
88 posts
Location
Austria(German)
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%29Turtle 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>")
18 posts
Posted 13 July 2012 - 10:32 AM
Do I have to enter the Turtle program into each turtle separately?
88 posts
Location
Austria(German)
Posted 13 July 2012 - 10:38 AM
You can copy this code to each turtle
18 posts
Posted 13 July 2012 - 10:39 AM
But I still have to interact with each turtle separately, correct?
88 posts
Location
Austria(German)
Posted 13 July 2012 - 10:44 AM
Do you mean copying the turtle-program or using the turtle itself?
18 posts
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?
88 posts
Location
Austria(German)
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 ^^
18 posts
Posted 13 July 2012 - 10:50 AM
Also, what does the "break" at the end of your code does?
88 posts
Location
Austria(German)
Posted 13 July 2012 - 10:51 AM
break the loop… if you want to using it serveral time then remove it
18 posts
Posted 13 July 2012 - 10:57 AM
When I type this into the comptuer I get an error message;
>rednet.open()
No such program
88 posts
Location
Austria(German)
Posted 13 July 2012 - 10:59 AM
this is a lua/cc method no program !!!!
18 posts
Posted 13 July 2012 - 11:00 AM
Ohhhh, ok then, thanks.
18 posts
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
88 posts
Location
Austria(German)
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"
18 posts
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
88 posts
Location
Austria(German)
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
18 posts
Posted 13 July 2012 - 11:28 AM
Doesn't work, still the same error message.
88 posts
Location
Austria(German)
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
18 posts
Posted 13 July 2012 - 11:34 AM
1)while true do
2)rednet.open(back)
3)local id, mgs, dis = rednet.receive()
88 posts
Location
Austria(German)
Posted 13 July 2012 - 11:41 AM
2. line should be
rednet.open("back")
instad of
rednet.open(back)
18 posts
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.
88 posts
Location
Austria(German)
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)
18 posts
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?
88 posts
Location
Austria(German)
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 :/
18 posts
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
88 posts
Location
Austria(German)
Posted 13 July 2012 - 12:14 PM
um sry the last to points ".." should be removed
print("Debug: "..id..", "..mgs..", "..dis)
18 posts
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 :/.
88 posts
Location
Austria(German)
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?
18 posts
Posted 13 July 2012 - 12:27 PM
the modem is on "back" and on "right"
88 posts
Location
Austria(German)
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
18 posts
Posted 13 July 2012 - 12:31 PM
Can't acces my PC at this time, will check this out in ~30 minutes.
18 posts
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.