Advertisement
WhiteFire_Sondergaar

Platform

May 6th, 2013
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.79 KB | None | 0 0
  1. -- Platform
  2. -- by Fenthis
  3.  
  4. args = { ... }
  5. forward = tonumber(args[1])
  6. right = tonumber(args[2])
  7.  
  8. if not (forward and right) then
  9.     print("Usage: platform forward right")
  10.     exit()
  11. end
  12.  
  13. if not act then
  14.     os.loadAPI("act")
  15.     if not act then
  16.         print("act api required.")
  17.         exit()
  18.     end
  19. end
  20.  
  21. function do_left_or_right(dir)
  22.     if dir then
  23.         turtle.turnLeft()
  24.     else
  25.         turtle.turnRight()
  26.     end
  27. end
  28.  
  29. function is_odd(n)
  30.     return ((n % 2) == 1)
  31. end
  32.  
  33. for r = 1,right do
  34.     for x = 1,forward do
  35.     act.select(1)
  36.         act.placeDown()
  37.         if x ~= forward then
  38.             act.try()
  39.         end
  40.     end
  41.  
  42.     if r ~= right then
  43.         do_left_or_right(not is_odd(r))
  44.         act.try()
  45.         do_left_or_right(not is_odd(r))
  46.     end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement