daily pastebin goal
83%
SHARE
TWEET

Untitled

a guest Apr 16th, 2018 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. dofile("Gassy")
  2.  
  3. function PlaceBlockDownAndRefuel()
  4.   while (true) do
  5.     if (turtle.getItemCount() > 0) then
  6.       turtle.placeDown()
  7.       break
  8.     end
  9.     local curSlot = turtle.getSelectedSlot()
  10.     if (curSlot == 16) then
  11.       curSlot = 1 -- skip 1: fuel
  12.     end
  13.     turtle.select(curSlot + 1)
  14.   end
  15.   if (turtle.getFuelLevel() < 5) then
  16.     local slot = turtle.getSelectedSlot()
  17.     turtle.select(1)
  18.     while (turtle.getItemCount() <= 0) do end
  19.     turtle.refuel(1)
  20.   end
  21. end
  22.  
  23. local r1 = 20.5
  24. local r2 = 37.5
  25.  
  26. local pn = math.floor(r2 * 2 + 4)
  27. local pc = math.floor(pn / 2 + 0.5) -- (pc, pc) = center
  28.  
  29. local pat = {}
  30. local cstart = {}
  31. local cend = {}
  32. local lc = 0
  33. local rc = 0
  34.  
  35. for i = 1, pn do
  36.   pat[i] = {}
  37.   cstart[i] = 0
  38.   cend[i] = 0
  39.   local dx = i - pc
  40.   for j = 1, pn do
  41.     local dy = j - pc
  42.     local d = math.sqrt(dx * dx + dy * dy)
  43.     pat[i][j] = d > r1 and d < r2
  44.     if (pat[i][j]) then
  45.       rc = i -- trick: i increasing
  46.       if (lc == 0) then
  47.         lc = i
  48.       end
  49.       if (cstart[i] == 0) then
  50.         cstart[i] = j
  51.         cend[i] = j
  52.       end
  53.       if (cend[i] == j - 1) then
  54.         cend[i] = j
  55.       end
  56.     end
  57.   end
  58. end
  59.  
  60. Gassy.x = pc
  61. Gassy.y = pc
  62. Gassy.z = 0
  63. -- initially face South
  64. Gassy.dump()
  65.  
  66. turtle.select(2)
  67.  
  68. local ns = 1
  69. for i = rc, lc, -1 do
  70.   if (ns == 1) then
  71.     Gassy.go(i, cend[i], 0);
  72.     Gassy.turn(0)
  73.     PlaceBlockDownAndRefuel()
  74.   else
  75.     Gassy.go(i, cstart[i], 0);
  76.     Gassy.turn(2)
  77.     PlaceBlockDownAndRefuel()
  78.   end
  79.   for jj = 0, (cend[i] - cstart[i]) do
  80.     Gassy.forward()
  81.     PlaceBlockDownAndRefuel()
  82.   end
  83. end
RAW Paste Data
Top