Guest User

lumber

a guest
Jul 31st, 2016
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.01 KB | None | 0 0
  1. --[[ Landstryder's Lumber Jack
  2.  
  3. Only works with redstone signal
  4.  from bottom when at the harvest
  5.  location, ment to come from a
  6.  daylight detector to keep it from
  7.  bonemealing at night.
  8. Drop off point is to the right of
  9.  the harvest location. Wood goes in
  10.  container strait at the end of path
  11.  and the excess saplings to the left
  12.  the bot at the end of path. Comparator
  13.  can be use on drop off chest to send
  14.  redstone to top of turtle at drop
  15.  location to pause program cycle till
  16.  more wood is required.
  17. ]]--
  18.  
  19. local i=0
  20.  
  21. function Dream()
  22.   while rs.getAnalogInput("bottom")<1 do
  23.     sleep(30)
  24.   end
  25. end
  26.  
  27. function Breaks()
  28.   while rs.getAnalogInput("top")>1 do
  29.    sleep(30)
  30.   end
  31. end
  32.  
  33. function GasUp()
  34.   if turtle.getFuelLevel()<100 then
  35.     turtle.select(1)
  36.     turtle.refuel(1)
  37.   end
  38. end
  39.  
  40. function Lumber()
  41.   turtle.select(4)
  42.   if turtle.compare() then
  43.     turtle.select(5)
  44.     turtle.dig()
  45.     turtle.forward()
  46.     while turtle.compareUp() do
  47.       turtle.digUp()
  48.       turtle.up()
  49.       i=i+1
  50.       end
  51.     while i>0 do
  52.      turtle.down()
  53.      i=i-1
  54.      end
  55.      turtle.back()
  56.     turtle.select(2)
  57.     turtle.place()
  58.   else
  59.     Dream()
  60.     Bone()
  61.     turtle.place()
  62.   end
  63. end
  64.  
  65. function DropOff()
  66.  turtle.select(5)
  67.  if turtle.getItemCount()>45 then
  68.  turtle.turnRight()
  69.  for x=1,6 do  --you can change to the distance to your drop point
  70.    turtle.forward()
  71.    end
  72.  turtle.drop()
  73.  turtle.turnLeft()
  74.  for x=6,16 do
  75.    turtle.select(x)
  76.    turtle.drop()
  77.    end
  78.  turtle.turnLeft()
  79.  Breaks()
  80.  for x=1,6 do  --if you change the number above make this one match
  81.    turtle.forward()
  82.    end
  83.  turtle.turnRight()
  84.  end
  85. end
  86.  
  87. function Bone()
  88.   turtle.select(3)
  89.   if turtle.getItemCount()<1 then
  90.     turtle.turnLeft()
  91.     turtle.turnLeft()
  92.     turtle.suck()
  93.     turtle.turnLeft()
  94.     turtle.turnLeft()
  95.   end
  96. end
  97.  
  98.    
  99. -- Main Program Loop
  100.  
  101. while true do    
  102.   for x=1,5 do
  103.     GasUp()
  104.     Lumber()
  105.     sleep(3)
  106.   end
  107.   GasUp()
  108.   DropOff()
  109.   sleep(3)
  110. end
Advertisement
Add Comment
Please, Sign In to add comment