Protowalker

Untitled

Jun 6th, 2020
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. os.loadAPI("apis/tortoise.lua")
  2. local id,x,z = ...
  3. id = tonumber(id)
  4. x = tonumber(x)
  5. z = tonumber(z)
  6.  
  7. local function digRow(l, d)
  8. if d==1 then
  9. tortoise.forceForward(l)
  10. else
  11. tortoise.forceBack(l)
  12. end
  13. end
  14.  
  15. local position = {}
  16. position.x = 0
  17. position.y = 0
  18. position.z = 0
  19.  
  20. tortoise.forceForward()
  21. tortoise.forceDown()
  22. position.y=1
  23. if id==2 then
  24. tortoise.turnRight()
  25. tortoise.forceForward(z/2)
  26. tortoise.turnLeft()
  27. tortoise.forceDown(1)
  28. position.x = 1
  29.  
  30. position.z = z/2
  31.  
  32. elseif id==3 then
  33. tortoise.forceForward((x/2) - 1)
  34. tortoise.forceDown(2)
  35. position.x = x/2
  36. position.z = 1
  37. elseif id==4 then
  38. tortoise.forceForward((x/2) - 1)
  39. tortoise.turnRight()
  40. tortoise.forceForward(z/2)
  41. tortoise.turnLeft()
  42. tortoise.forceDown(3)
  43. position.x = x/2
  44. position.z = z/2
  45. end
  46.  
  47. local function returnHome()
  48. print(position.x)
  49. print(position.y)
  50. print(position.z)
  51. tortoise.forceUp(position.y)
  52. tortoise.forceForward(position.z)
  53. tortoise.turnRight()
  54. tortoise.forceForward(position.x)
  55.  
  56. end
  57.  
  58. while true do
  59. for i=1,(x/2) do
  60. digRow((z/2)-1, 1)
  61. if i%2==1 then position.z = position.z + (z/2)
  62. else position.z = position.z - (z/2) end
  63. if (i)%2==1 then tortoise.turnRight()
  64. else tortoise.turnLeft() end
  65. if not(i == x/2) then
  66. tortoise.forceForward()
  67. else position.x = position.x + 1 end
  68.  
  69. if (i)%2==1 then tortoise.turnRight()
  70. else tortoise.turnLeft() end
  71. end
  72. tortoise.forceDown()
  73. position.y = position.y + 1
  74. returnHome()
  75. return
  76. end
Advertisement
Add Comment
Please, Sign In to add comment