SHARE
TWEET

move.lua

neo34rd Mar 24th, 2019 (edited) 238 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top