Advertisement
psychedelixx

Minecraft Turtle: Pyramid

Jun 14th, 2013
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --[[
  2.     2013 (c) psychedelixx
  3.     Minecraft Turtle: Pyramid
  4.     2013-06-14
  5.  
  6.     desc
  7.  
  8.     Usage:
  9.     - use turtle and type "label set <name>"
  10.       (to give your turtle an unique name so it remembers its programs)
  11.     - type "pastebin get <code> pyramid"
  12.     - type "pyramid <length>" (32 for full 4x4x64 chest)
  13. --]]
  14.  
  15. slot = 0
  16.  
  17. function move()
  18.     if turtle.getFuelLevel() < 5 then
  19.         turtle.refuel()
  20.     end
  21.     if turtle.getItemCount(slot%16+1)==0 then
  22.     slot = slot+1
  23.     turtle.select(slot%16+1)        
  24.     end
  25.     turtle.placeDown()
  26.     turtle.forward()
  27. end
  28.  
  29. local args = { ... }
  30. if #args < 1 then
  31.     print( "Usage: pyramid <length> [32 for full 4x4x64 chest]" )
  32.     error()
  33. end
  34. x = tonumber(args[1])
  35. odd = x%2==1
  36.  
  37. if turtle.getFuelLevel() == 0 then
  38.     turtle.refuel()
  39. end
  40.  
  41. if turtle.getFuelLevel() == 0 then
  42.     print("I need fuel!")
  43. else
  44.     print("======== 2013 (c) psychedelixx ========")
  45.     print("Let's go!")
  46.    
  47.     start = true
  48.     dir = 1
  49.     turtle.up()
  50.     repeat
  51.         if dir%4 == 1 and not start then
  52.             move()
  53.             turtle.up()
  54.         end
  55.         block = 1
  56.         if odd and x==1 then
  57.             move()
  58.             x=x-1
  59.             else repeat
  60.             move()
  61.             block = block+1
  62.         until block >= x end
  63.         turtle.turnRight()
  64.         dir = dir+1
  65.         if dir%4 == 1 or dir%4 == 0 then x = x-1 end
  66.         if start then start = false end
  67.     until x<=0 
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement