Turtles code save it to a file and name it listen
rednet.open("right") print("Waiting for command") id, message = rednet.receive() term.clear() if message == "test" then shell.run("dance") else print("Does Not Compute") end
- rednet.open("right")--starts the turtle listening for a message.
- print("Waiting for command")-- prints on the screen Waiting for command until an event happens
- id, message = rednet.receive()-- Sets up the receive event the computer will send its id# and a message. The message will always be a string.
- term.clear()-- clears the screen
- if message == "test" then -- once a message is received and it equals the if test then it executes the next line
- shell.run("dance")-- Shell.run will execute what ever program that is stated. dance is an included CC program
else the the received message does not equal the if test then the next line is executed
print("Does Not Compute")-- prints on the screen Does Not Compute
end-- ends the if statement
Computers code save it to a file named makedance
rednet.open("right") rednet.send(2, "test")
Thats all we need
- rednet.open("right")-- right equals the side of the computer the modem is on it could be left top bottom etc
- rednet.send(2, "test")-- the 2 equals the turtles id and test is the message. Remember test from our if statement above if we send the turtle test it will make it dance if we send it anything else it will print out Does not compute.
now stand back and watch the turtle dance. Click on the turtle to stop it dancing.
This method is easy to modify to make the turtle do what ever you want. I can expand on this topic if anyone needs me to.