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

Control more then one turtle with a single computer, modem

Started by modernzink, 01 March 2012 - 04:31 PM
modernzink #1
Posted 01 March 2012 - 05:31 PM
Hi,
i think about something like a start/stopp message for turtle. these turtles should start to dig at the same time, so they are dig synchronous.

So my question is , if one computer handle with more then one turtle id at the same time, to send the information to more then one turtle at the same time .
Liraal #2
Posted 01 March 2012 - 05:38 PM
well, if you use
rednet.send(id1, msg)

rednet.send(id2, msg)

rednet.send(id3, msg)
you may experience a slight delay
if you don't care which turtle to send to, use:
rednet.broadcast(msg)
modernzink #3
Posted 01 March 2012 - 05:42 PM
when i use
rednet.broadcast(msg)
does the turtle need the computerid ?
i think not, but it could be.

Yeay, after thinking about it, its really a strupid question :unsure:/>/>
rockymc #4
Posted 01 March 2012 - 05:58 PM
My program controls every turtle.
joaopada #5
Posted 11 May 2012 - 09:32 PM
Hey, how do i do that rednet command? In my computer it says: no such command found (or something)
joaopada #6
Posted 12 May 2012 - 03:31 PM
WTF????

I don't want to watch porn, i want to know how to use that rednet command. Any exra script, extramod???
Lyqyd #7
Posted 12 May 2012 - 04:37 PM
You've got exactly


rednet.broadcast("Message Here.")

for the function name? What version of ComputerCraft are you running? You might check the release notes if you're using an older version to see when the rednet API gained the broadcast function.
joaopada #8
Posted 12 May 2012 - 09:18 PM
You've got exactly


rednet.broadcast("Message Here.")

for the function name? What version of ComputerCraft are you running? You might check the release notes if you're using an older version to see when the rednet API gained the broadcast function.

Yes, i have the most recent version of computercraft AND minecraft 1.2.5

By the way, how do I do it? Like, open the computer with the modem on the right, and then I just type
rednet.broadcast("excavate 6") which is what i wanna do, and it's ok?
Dirkus7 #9
Posted 12 May 2012 - 09:32 PM
Try executing

rednet,broadcast("message")
in the lua prompt
Lyqyd #10
Posted 12 May 2012 - 11:06 PM
You've got exactly


rednet.broadcast("Message Here.")

for the function name? What version of ComputerCraft are you running? You might check the release notes if you're using an older version to see when the rednet API gained the broadcast function.

Yes, i have the most recent version of computercraft AND minecraft 1.2.5

By the way, how do I do it? Like, open the computer with the modem on the right, and then I just type
rednet.broadcast("excavate 6") which is what i wanna do, and it's ok?

Nope, you're going to need to write a custom program to run on the turtles to receive the rednet signal and then execute whatever program you want them to run.
joaopada #11
Posted 13 May 2012 - 07:35 PM
You've got exactly


rednet.broadcast("Message Here.")

for the function name? What version of ComputerCraft are you running? You might check the release notes if you're using an older version to see when the rednet API gained the broadcast function.

Yes, i have the most recent version of computercraft AND minecraft 1.2.5

By the way, how do I do it? Like, open the computer with the modem on the right, and then I just type
rednet.broadcast("excavate 6") which is what i wanna do, and it's ok?

Nope, you're going to need to write a custom program to run on the turtles to receive the rednet signal and then execute whatever program you want them to run.

Tutorial? Please, I really need this
cant_delete_account #12
Posted 13 May 2012 - 10:41 PM
Tutorial? Please, I really need this
This should work, but it will only work with excavate:

while true do
local e, id, msg, distance = os.pullEvent()
if e == "rednet_message" then
if msg:sub( 1, 8 ) == "excavate" then
  if msg:sub( 9 ) then
   shell.run( msg:sub( 1, 8 ), tonumber( msg:sub( 9 ) ) )
   print( "Successfully finished running program." )
end
end
end
MysticT #13
Posted 13 May 2012 - 11:09 PM
This will take any rednet message as if you were typing in the terminal:

rednet.open("right") -- for turtles is always "right"
local serverID = 1 -- id of the server that sends the commands

while true do
  local id, msg = rednet.receive()
  if id == serverID then
    local tWords = {}
    for s in string.gmatch(msg, "[^ t]+") do
      table.insert(tWords, s)
    end
    local sCommand = tWords[1]
    if sCommand then
    local ok, err = shell.run(sCommand, unpack(tWords, 2))
    if not ok then
      print(err)
    end
  end
end
So, sending "go forward 2" would make the turtle run the "go" program, with parameters "forward" and "2". You can remove the check of the id, but it would run anything received from any computer/turtle.
je06 #14
Posted 15 May 2012 - 10:49 PM
You can try this for computer
while true do
print("1.Turn Left") –Option 1
print("2.Go Forward") –Option 2
print("3.Turn Right") –Option 3
print("4.Dig")
msg = read() –Save as string not number
rednet.broudcast(msg)
end
and this for turtles
while true do
id, msg = rednet.recieve()
if msg == "1" then
turtle.turnLeft()
end
if msg == "2" then
turtle.forward()
end
if msg == "3" then
turtle.turnRight()
end
if msg == "4" then
turtle.dig()
end
end
with some modifying it can do what you want it to do
joaopada #15
Posted 20 May 2012 - 08:59 PM
But i open the lua editor? only thing that i don't get
MysticT #16
Posted 20 May 2012 - 11:46 PM
If you want to make a program with a specific functionality you have to write it in the in-game editor, or any external text editor (like notepad++). If you just want to try the command you can use the lua program in-game, just type lua in the computer and then start typing any commands you want. Don't forget to use rednet.open(<side of the modem>) before sending/receiveing messages.