DennouNeko

honey_prep.lua

Oct 15th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. -- Honeycomb Prepare by DennouNeko
  2. --
  3. -- Prepares terrain for Honeycomb Build
  4. -- Requires mining turtle.
  5. -- Place torches or other light blocks in slot 16 to lit up the floor
  6.  
  7. local args = {...}
  8. local swap = (args[1] == "left")
  9. local t = turtle
  10. t.select(16)
  11.  
  12. function down(num)
  13.   if num == nil then num = 1 end
  14.   num = tonumber(num)
  15.  
  16.   for i = 1,num do
  17.     while not t.down() do
  18.       t.digDown()
  19.     end
  20.   end
  21. end
  22.  
  23. function up(num)
  24.   if num == nil then num = 1 end
  25.  
  26.   for i = 1,num do
  27.     while not t.up() do
  28.       t.digUp()
  29.     end
  30.   end
  31. end
  32.  
  33. function fwd(num)
  34.   if num == nil then num = 1 end
  35.   num = tonumber(num)
  36.  
  37.   for i = 1,num do
  38.     while not t.forward() do
  39.       t.dig()
  40.     end
  41.   end
  42. end
  43.  
  44. function step()
  45.   if t.detectDown() then t.digDown() end
  46.   if t.detectUp() then t.digUp() end
  47. end
  48.  
  49. function run_n(num, place)
  50.   step()
  51.   for i = 2,num do
  52.     fwd()
  53.     step()
  54.    
  55.     if place and (i % 5 == 0) then
  56.       t.placeDown()
  57.     end
  58.   end
  59. end
  60.  
  61. function row_up(left)
  62.   if left then
  63.     t.turnLeft()
  64.     fwd()
  65.     t.turnRight()
  66.     fwd()
  67.   else
  68.     t.turnRight()
  69.     fwd()
  70.     t.turnLeft()
  71.     fwd()
  72.   end
  73.   t.turnLeft()
  74.   t.turnLeft()
  75.   step()
  76. end
  77.  
  78. function row_dn(left)
  79.   t.turnRight()
  80.   t.turnRight()
  81.   if left then
  82.     fwd()
  83.     t.turnRight()
  84.     fwd()
  85.     t.turnLeft()
  86.   else
  87.     fwd()
  88.     t.turnLeft()
  89.     fwd()
  90.     t.turnRight()
  91.   end
  92.   step()
  93. end
  94.  
  95. function turn(left)
  96.   if left then
  97.     t.turnLeft()
  98.     fwd()
  99.     t.turnLeft()
  100.     step()
  101.   else
  102.     t.turnRight()
  103.     fwd()
  104.     t.turnRight()
  105.     step()
  106.   end
  107.  
  108.   for i=1,15 do
  109.     if t.getItemCount(i) > 0 then
  110.       t.select(i)
  111.       t.drop()
  112.     end
  113.   end
  114.   t.select(16)
  115. end
  116.  
  117. function dig_layer(place)
  118.   local len = 14
  119.  
  120.   for i = 1,6 do
  121.     run_n(len)
  122.     row_up(not swap)
  123.     len = len + 2
  124.     run_n(len, place and i % 2 == 1)
  125.     turn(swap)
  126.   end
  127.  
  128.   run_n(len)
  129.   turn(not swap)
  130.   run_n(len, place)
  131.   turn(swap)
  132.  
  133.   for i=1,6 do
  134.     run_n(len)
  135.     row_dn(not swap)
  136.     len = len - 2
  137.     run_n(len, place and i % 2 == 1)
  138.     if i < 6 then
  139.       turn(swap)
  140.     else
  141.       if swap then
  142.         t.turnRight()
  143.         fwd(25)
  144.         t.turnRight()
  145.       else
  146.         t.turnLeft()
  147.         fwd(25)
  148.         t.turnLeft()
  149.       end
  150.     end
  151.   end
  152. end
  153.  
  154. down(3)
  155.  
  156. if swap then
  157.   t.turnLeft()
  158. else
  159.   t.turnRight()
  160. end
  161.  
  162. dig_layer(true)
  163. up(3)
  164. dig_layer(false)
  165. up(3)
  166. dig_layer(false)
  167. down(3)
  168.  
  169. if swap then
  170.   t.turnRight()
  171. else
  172.   t.turnLeft()
  173. end
Advertisement
Add Comment
Please, Sign In to add comment