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

calling a turtle with rednet

Started by Glotz659, 03 April 2012 - 06:51 PM
Glotz659 #1
Posted 03 April 2012 - 08:51 PM
hey guys!
i've tried to write a program which i'll use to "call" turtles to any location:
the turtle code

tname = tester
rednet.open("right")
-- first some code that makes the turtle drive to a  waiting position
while true do
print("waiting for signal...")
repeat
id, msg = rednet.receive()
until msg == tname
rednet.send(id, "rdy")
id, msg = rednet.receive()
if msg == "position1" then
-- some code to tell the turtle where it has to go
break
elseif msg == "upstairs" then
-- some code to tell the turtle how to get upstairs
break
end
end

and the code for the computer :

CompName="position1"
rednet.open("right")
print("which turtle?")
tname=read()
rednet.broadcast(tname)
id, msg = rednet.receive(1)
if msg == "rdy" then
rednet.send(id, CompName)
print ("turtle coming...")
else
print ("turtle currently not available")
rednet.close("right")

basically, this works. but i'd prefer to run it as "call myturtle" instead of "call" and then entering the turtles name. also i'd prefer to use the turtle's label instead of a variable.

so all i need to know is how to read the arguments a program is runned with and how to get the label of a turtle

(and sorry if it's bad english, but it isn't my native language :)/>/> )
PatriotBob #2
Posted 03 April 2012 - 09:53 PM
Should just be like….

local args = {...}
-- other codes... using args[1], args[2], etc... etc...
Glotz659 #3
Posted 04 April 2012 - 07:23 AM
thank you!

edit: i found out how to get a computer's label:

label = os.getComputerLabel()