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
and the code for the computer :
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 :)/>/> )
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 :)/>/> )