warfar

Tree Feller

Dec 16th, 2012
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.60 KB | None | 0 0
  1. print("Place saplings in slot 1 and bonemeal in slot 2")
  2. print("Place 1 sapling in slot 13 and 1 bonemeal in slot 14")
  3.  
  4. local i = 1
  5. local p = 1
  6. local v = 1
  7. local fuel = turtle.getFuelLevel()
  8. local tArgs = { ... }
  9.  
  10. if #tArgs ~= 1 then
  11.     print("Please rate lag 1-20 (20 being the worst)")
  12.     return
  13. end
  14.  
  15. local function bonemeal()
  16.   turtle.forward()
  17.   turtle.forward()
  18.   turtle.select(1)
  19.   turtle.place()
  20.   sleep(.1)
  21.   turtle.select(2)
  22.   turtle.place()
  23.   turtle.select(1)
  24. end
  25.  
  26. local function checkdig()
  27.     turtle.dig()
  28.     turtle.forward()
  29.     while true do
  30.       if turtle.detectUp() then
  31.         turtle.digUp()
  32.         turtle.up()
  33.         else turtle.down()
  34.         if turtle.detectDown() then
  35.           turtle.back()
  36.           turtle.back()
  37.           turtle.back()
  38.           break
  39.         end
  40.       end
  41.     end
  42. end
  43.  
  44. local function checkfuel()
  45.     term.clear()
  46.     term.setCursorPos(1, 1)
  47.     if turtle.getFuelLevel() < 100 then
  48.        print("Please add fuel (At least 100)")
  49.        print("Waiting for fuel, press the E key to refuel")
  50.        print("Press Q to continue.")
  51.        print("Press 1-8 to change slots")
  52.        while true do
  53.        local event, param1 = os.pullEvent("key")
  54.        if param1 > 1 and param1 < 10 then
  55.            local sel = param1 - 1
  56.            turtle.select(sel)
  57.        end
  58.           if param1 == 18 then
  59.               turtle.refuel()
  60.               fuel = turtle.getFuelLevel()
  61.              print(fuel.." Fuel")
  62.           elseif param1 == 16 and fuel > 100 then
  63.               print("Fuel Get!"..fuel.." fuel")
  64.               break
  65.           end
  66.        end
  67.     end
  68. end
  69.  
  70. local lag = tonumber(tArgs[1])
  71.  
  72. if lag > 20 then
  73.     print("Error:")
  74.     print("Only numbers 1-20")
  75. end
  76.  
  77. if lag == nil then
  78.     print("Error")
  79.     print("Numbers Only")
  80.     return
  81. else
  82.     print(lag.."Lag")
  83. end
  84.  
  85. local lag2 = lag + 20
  86. local lag3 = lag2 * 2
  87.  
  88. while true do
  89.  
  90.  
  91.     if turtle.getItemCount(1) <= 4 then
  92.         print("Not enough saplings. Please refill")
  93.         return
  94.     elseif turtle.getItemCount(2) <= 3 then
  95.         print("Not enough bonemeal. Please refill")
  96.         return
  97.     else
  98.     end
  99.     turtle.select(1)
  100.     if turtle.compareTo(13) == false then
  101.         print("Only spalings in slot 1")
  102.         return
  103.     end
  104.     turtle.select(2)
  105.     if turtle.compareTo(14) == false then
  106.         print("Only bonemeal in slot 2")
  107.         return
  108.     end
  109.  
  110.  
  111.   checkfuel()
  112.   bonemeal()
  113.   checkdig()
  114.   for i=1, lag3 do
  115.     turtle.suck()
  116.     sleep(1)
  117.     rs.setOutput("bottom", true)
  118.   end
  119.   rs.setOutput("bottom", false)
  120.   sleep(1)
  121. end
Advertisement
Add Comment
Please, Sign In to add comment