Advertisement
neo34rd

move.lua

Mar 24th, 2019
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. os.loadAPI("transformation")
  2.  
  3. function lineMotionDoWhile(t, x, func)
  4. for xI = 0, x do
  5. --- Do action
  6. local b = func()
  7.  
  8. --- Action failed
  9. if not b then
  10. print("func failed!")
  11. return b
  12. end
  13.  
  14. --- Move forward
  15. transformation.forward(t)
  16.  
  17. --- Cannot move forward
  18. if t.ret == false then
  19. return t.ret
  20. end
  21. end
  22. return true
  23. end
  24.  
  25.  
  26. function rectMotionDoWhile(transform, x, z, func)
  27.  
  28. print("rectMotionDoWhile!")
  29. local turnRight = transformation.turnRight
  30. local turnLeft = transformation.turnLeft
  31.  
  32. local turn = turnRight
  33.  
  34. for xI = 0, x do
  35. print(xI)
  36. if lineMotionDoWhile(transform, z, func) == false then
  37. print("Line motion failed!")
  38. return false
  39. end
  40.  
  41. if xI % 2 == 0 then
  42. turn = turnRight
  43. else
  44. turn = turnLeft
  45. end
  46.  
  47. turn(transform)
  48. if func() == false then
  49. print("func() failed!")
  50. return false
  51. end
  52. transformation.forward(transform)
  53. turn(transform)
  54. end
  55.  
  56. return true
  57. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement