wv1106

following sciprt turtle TEST not finished yet

Jan 16th, 2021 (edited)
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.22 KB | None | 0 0
  1. --follower turtle--
  2. function setup()
  3.     print("what's the id of the compact computer you want to conect with?")
  4.     id = read()
  5. end
  6.  
  7.  
  8. function getcor()
  9.     local x, y, z = gps.locate()
  10.     if rednet.recieve() then
  11.         xt, yt, zt = rednet.recieve()
  12.         xm = x-xt   --  west-east
  13.         ym = y-yt
  14.         zm = z-zt   --  north-south
  15.     end
  16. end
  17.  
  18. function forward()
  19.     while not turtle.forward() do
  20.         rednet.send(id,"unable to move =(")
  21.         sleep(2)
  22.     end
  23. end
  24.  
  25. function up()
  26.     while not turtle.up() do
  27.         rednet.send(id,"unable to go up =(")
  28.         sleep(2)
  29.     end
  30. end
  31.  
  32. function down()
  33.     while not turtle.down() do
  34.         rednet.send(id,"unable to go down")
  35.         sleep(2)
  36.     end
  37. end
  38.  
  39. function N()
  40.     if direct==2 then
  41.         turtle.turnLeft()
  42.     elseif direct==3 then
  43.         turtle.turnLeft()
  44.         turtle.turnLeft()
  45.     elseif direct==4 then
  46.         turtle.turnRight()
  47.     end
  48.     direct=1
  49. end
  50.  
  51. function E()
  52.     if direct==1 then
  53.         turtle.turnRight()
  54.     elseif direct==3 then
  55.         turtle.turnLeft()
  56.        
  57.     elseif direct == 4 then
  58.         turtle.turnLeft()
  59.         turtle.turnLeft()
  60.     end
  61.     direct=2
  62. end
  63.  
  64. function S()
  65.     if direct==1 then
  66.         turtle.turnLeft()
  67.         turtle.turnLeft()
  68.     elseif direct==2 then
  69.         turtle.turnLeft()
  70.     elseif direct==4 then
  71.         turtle.turnRight()
  72.  
  73.     end
  74.     direct=3
  75. end
  76.  
  77. function W()
  78.     if direct==1 then
  79.         turtl.turnRight()
  80.     elseif direct==2 then
  81.         turtle.turnLeft()
  82.         turtle.turnLeft()
  83.     elseif direct==3 then
  84.         turtle.turnLeft()
  85.     end
  86.     direct=4
  87. end
  88.  
  89. function move()
  90.    
  91.     if ym>0 then
  92.         up()
  93.     elseif ym<0 then
  94.         down()
  95.     elseif xm>0 then
  96.         W()
  97.         forward()
  98.     elseif xm<0 then
  99.         E()
  100.         forward()
  101.     elseif zm>0 then
  102.         N()
  103.         forward()
  104.     elseif zm<0 then
  105.         S()
  106.         forward()
  107.    
  108.     end
  109. end
  110.  
  111. --here starts the script
  112.  
  113.  
  114. setup()
  115. print("this program is made by wv1106 on reddit and pastebin")
  116. print("open the other part of the script on a wireless or ender pocket computer")
  117. while 1 do
  118.     getcor()
  119.     move()
  120. end
  121.  
  122.        
  123.  
  124.    
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
Add Comment
Please, Sign In to add comment