Advertisement
Xenogami

circle build

Feb 21st, 2013
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.19 KB | None | 0 0
  1. local nx = 0
  2. local ny = 0
  3. local a = 0
  4. local cx = 0
  5. local cy = 0
  6. local dNeed = 0
  7.  
  8. function checkFuel()
  9.     turtle.select(1)
  10.     while turtle.getFuelLevel() < 100 do
  11.         turtle.refuel(1)
  12.     end
  13.     turtle.select(slotNum)
  14. end
  15.  
  16. local function newPlot()
  17.     nx = math.cos((a*(3.14/180))*r)
  18.     if nx >= 0 then
  19.         nx = math.floor(nx+0.5)
  20.     else
  21.         nx=math.ceil(nx-0.5)
  22.     end
  23.     ny = math.sin((a*(3.14/180))*r)
  24.     if ny >= 0 then
  25.         ny=math.floor(ny + 0.5)
  26.     else
  27.             ny=math.ceil(ny - 0.5)
  28.     end
  29. end
  30.  
  31. local function dRection()
  32.     while dNeed ~= dIs do
  33.         turtle.turnLeft()
  34.         dIs = dIs + 1
  35.         if dIs > 4 then
  36.             dIs = 1
  37.         end
  38.         print("dIs = "..dIs)
  39.         print("dNeed = "..dNeed)
  40.         print("tempX = "..tempX)
  41.         print("tempY = "..tempY)
  42.         print("cx,cy = "..cx..","..cy)
  43.         print("\n")
  44.     end
  45. end
  46.  
  47. local function xMovement()
  48.     tempX = nx-cx
  49.     if tempX == 1 then
  50.         dNeed = 4
  51.     elseif tempX == -1 then
  52.         dNeed = 2
  53.     end    
  54. end
  55.  
  56. local function yMovement()
  57.     tempY = ny-cy
  58.     if tempY == 1 then
  59.         dNeed = 1
  60.     elseif tempY == -1 then
  61.         dNeed = 3
  62.     end
  63. end
  64.  
  65. local function forwardCheck()
  66.     while not turtle.forward() do
  67.         os.sleep(1)
  68.     end
  69. end
  70.  
  71. local function placeBlock()
  72.     if turtle.getItemCount(slotNum) > 0 then
  73.         turtle.placeDown()
  74.     else
  75.         if slotNum <= 15 then
  76.             slotNum = slotNum + 1
  77.         else
  78.             term.clear()
  79.             term.setCursorPos(1,1)
  80.             print ("Out of blocks please reload then press any key to continue.")
  81.             os.pullEvent()
  82.             slotNum = 2
  83.         end
  84.         turtle.select(slotNum)
  85.         turtle.placeDown()
  86.     end
  87. end
  88.  
  89. local function startUp()
  90.     term.clear()
  91.     term.setCursorPos(1,1)
  92.     print("Place fuel in slot 1 and fill the rest of the slots with your blocks.")
  93.     print("Make sure the area is clear of obsticals cause they will screw me up.")
  94.     print ("What is the diameter of your circle?")
  95.     d = tonumber(read())
  96.     print("Hi-Ho Hi-Ho its off to work I go.")
  97.     r = d/2
  98.     slotNum = 2
  99. end
  100.  
  101. startUp()
  102. checkFuel()
  103. turtle.up()
  104. for t=1,r do
  105.     turtle.forward()
  106. end
  107. placeBlock()
  108. dIs = 4
  109. cx = r
  110. cy = 0
  111. for a = 1,360 do
  112.     newPlot()
  113.     xMovement()
  114.     if tempX ~= 0 then
  115.         dRection()
  116.         forwardCheck()
  117.         placeBlock()
  118.     end
  119.     yMovement()
  120.     if tempY ~= 0 then
  121.         dRection()
  122.         forwardCheck()
  123.         placeBlock()
  124.     end
  125.     checkFuel()
  126. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement