etelan

Old Movement

Jan 2nd, 2021 (edited)
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local function proxyFor(name, required)
  2.   local address = component and component.list(name)()
  3.   if not address and required then
  4.     error("missing component '" .. name .. "'")
  5.   end
  6.   return address and component.proxy(address) or nil
  7. end
  8.  
  9.  
  10. --Require
  11. local drone = proxyFor("drone", true)
  12. local navigation = proxyFor("navigation", true)
  13. local m = proxyFor("modem", true)
  14.  
  15. m.open(808)
  16. m.open(809)
  17. m.open(810)
  18.  
  19.  
  20. disX = -17
  21. disY = -100
  22. disZ = 0
  23.  
  24.  
  25.  
  26. local startx, starty, startz = navigation.getPosition()
  27.  
  28. --Initial Values
  29. workedx = 0
  30. workedy = 0
  31. workedz = 0
  32.  
  33.  
  34. while (workedx > disX + 1 or workedx < disX - 1) do
  35.  
  36.   m.broadcast(808, "X: " .. workedx)
  37.   x, y, z = navigation.getPosition()
  38.   workedx = x - startx
  39.  
  40.   if workedx < disX then
  41.     drone.move(1,0,0)
  42.   end
  43.  
  44.   if workedx > disX then
  45.     drone.move(-1,0,0)
  46.   end
  47.    
  48. end
  49.  
  50. while (workedz > disZ + 1 or workedz < disZ - 1) do
  51.   m.broadcast(809, "Z: " .. workedz)
  52.   x, y, z = navigation.getPosition()
  53.   workedz = y - starty
  54.  
  55.   if workedz < disZ then
  56.     drone.move(0,0,1)
  57.   end
  58.  
  59.   if workedz > disZ then
  60.     drone.move(0,0,-1)
  61.   end
  62.  
  63. end
  64.  
  65. while (workedy > disY + 1 or workedy < disY - 1) do
  66.   m.broadcast(810, "Y: " .. workedy)
  67.   x, y, z = navigation.getPosition()
  68.   workedy = y - starty
  69.  
  70.   if workedy < disY then
  71.     drone.move(0,1,0)
  72.   end
  73.  
  74.   if workedy > disY then
  75.     drone.move(0,-1,0)
  76.   end
  77.  
  78. end
Add Comment
Please, Sign In to add comment