pson

simpleCane.lua

Aug 25th, 2022 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.25 KB | Gaming | 0 0
  1. -- Slot 1-4 One each of the sugarcane/bamboo/something else that behave
  2. -- the same way
  3. -- Slot 15 the chest/drawer that will take the harvest
  4. -- The turtle will rotate four times while, planting the slots 1-4.
  5. -- After that it will raise one space, put the chest above itself,
  6. -- and start harvesting (rotating and digging)
  7.  
  8. function setup()
  9.     local i
  10.     if turtle.getFuelLevel() == 0 then
  11.         print "Turtle needs at least 1 fuel"
  12.         return
  13.     end
  14.     for i=1,4,1  do
  15.         if turtle.getItemCount(i) > 0 then
  16.             if turtle.detect() then
  17.                 turtle.dig()
  18.             end
  19.             turtle.select(i)
  20.             turtle.place()
  21.         end
  22.         turtle.turnRight()
  23.     end
  24.     if turtle.detectUp() then
  25.         turtle.digUp()
  26.     end
  27.     turtle.up()
  28.     turtle.select(16)
  29.     turtle.placeUp()
  30. end -- setup
  31.  
  32. function main()
  33.     local i
  34.     if turtle.getItemCount(1) > 0 then
  35.         setup()
  36.     end
  37.     while turtle.getItemCount(1) == 0 do
  38.         turtle.select(1)
  39.         for i=1,4,1 do
  40.             if turtle.detect() then
  41.                 turtle.dig()
  42.                 turtle.dropUp()
  43.             end
  44.             turtle.turnRight()
  45.         end
  46.         sleep(15)
  47.     end
  48. end -- main
  49.  
  50. main()
  51.  
Add Comment
Please, Sign In to add comment