Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- local debug = true
- local cmpid = os.getComputerID() -- get the computer / turtle ID
- print(cmpid) -- Print the Tutle / computer ID (this is always good to show and know)
- rednet.open("right")
- -- event is the computer event code eg. "rednet_message" which is what we are looking for.
- -- p1 is our senders computer ID.
- -- p2 is our senders message.
- -- p3 is our senders distance from the turtle.
- while true do -- Loop Infinitely
- local event,p1,p2,p3 = os.pullEvent() -- Pull event with args.
- if debug and event == "rednet_message" then -- only if we are debugging the script execute this
- print( event .. " " .. p1 .. " " .. p2 .. " " .. p3 ) -- debug screen output on Turtle
- end
- if event == "rednet_message" then -- only if the event is a rednet incoming message do anything, otherwise return to loop waiting.
- rednet.send(p1,"ack") -- reply to say we received the message
- if debug then print("ack " .. p2 );end
- if p2 == "left" then
- if debug then print("l ");end
- turtle.turnLeft()
- elseif p2 == "right" then
- if debug then print("r ");end
- turtle.turnRight()
- elseif p2 == "back" then
- if debug then print("b ");end
- turtle.back()
- elseif p2 == "forward" then
- if debug then print("f ");end
- turtle.forward()
- elseif p2 == "up" then
- if debug then print("u ");end
- turtle.up()
- elseif p2 == "down" then
- if debug then print("d ");end
- turtle.down()
- elseif p2 == "dig" then
- if debug then print("dig ");end
- turtle.dig()
- elseif p2 == "return" then -- for now we only want the turtle to return to the ground level...
- for x=1,20 do
- turtle.down()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement