Advertisement
lucifersamfr

MSfollower

Apr 16th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. local followChannel = 14
  2. local followRespChannel = 15
  3. local modem = peripheral.wrap("right")
  4. modem.open(followChannel)
  5.  
  6. commands = {
  7.     follow_Up = function()
  8.         turtle.up()
  9.     end,
  10.     follow_Down = function()
  11.         turtle.down()
  12.     end,
  13.     follow_Forward = function()
  14.         turtle.forward()
  15.     end,
  16.     follow_Backward = function()
  17.         turtle.back()
  18.     end,
  19.     follow_Left = function()
  20.         turtle.turnLeft()
  21.         turtle.forward()
  22.         turtle.turnRight()
  23.     end,
  24.     follow_Right = function()
  25.         turtle.turnRight()
  26.         turtle.forward()
  27.         turtle.turnLeft()
  28.     end,
  29. }
  30.  
  31. while true do
  32.   local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
  33.   print(message)
  34.  
  35.   if string.find(string.lower(message), "follow_") then
  36.   --if ( (string.len(op.name) > 7) and (string.find(op.name, "follow_", nil, true) ~= nil) ) then
  37.     commands[message]()
  38.     modem.transmit(followRespChannel ,followChannel ,"Following OK")
  39.   end
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement