Advertisement
GamingwithAtos

Sapling.lua

Dec 6th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.54 KB | None | 0 0
  1. local x = 1
  2. local y = 0
  3. rednet.open("right")
  4.  
  5. function getSapling()
  6.     rednet.broadcast("x: " .. x .. " | y: " .. y)
  7.     while true do
  8.         turtle.select(1)
  9.         turtle.select(1)
  10.         sleep(0.02)
  11.         if turtle.getItemCount() == 0 then
  12.             print("Out of Saplings...")
  13.             Waiting()
  14.         end
  15.         Placing()
  16.     end
  17. end
  18. -----------------------
  19. function Waiting()
  20.     rednet.broadcast("Out of Saplings!")
  21.     while true do
  22.         sleep(0,5)
  23.         if turtle.getItemCount() ~= 0 then
  24.             getSapling()
  25.         end
  26.     end
  27. end
  28. --------------
  29. function Placing()
  30.     local success, block = turtle.inspect()
  31.     if block.name == "minecraft:log" then
  32.         Move()
  33.     end
  34.     turtle.select(1)
  35.     turtle.place()
  36.     while true do
  37.         turtle.select(1)
  38.         turtle.place()
  39.         turtle.select(2)
  40.         turtle.place()
  41.         local success, block = turtle.inspect()
  42.         if block.name == "minecraft:log" then
  43.             Move()
  44.         end
  45.     end
  46. end
  47. --------------
  48. function Move()
  49.    rednet.send(278, "go")
  50.    if x == 0 and y == 0 then
  51.        turtle.turnLeft()
  52.        turtle.back()
  53.        x = x + 1
  54.        local sidex1 = false
  55.        local sidex2 = true
  56.        local sidey1 = false
  57.        local sidey2 = false
  58.        getSapling()
  59.    end
  60.    if x == 10 and y == 7 then
  61.        turtle.turnLeft()
  62.        turtle.back()
  63.        x = x - 1
  64.        local sidex1 = true
  65.        local sidex2 = false
  66.        local sidey1 = false
  67.        local sidey2 = false
  68.        getSapling()
  69.    end
  70.    if x == 0 and y == 7 then
  71.        turtle.turnLeft()
  72.        turtle.back()
  73.        y = y - 1
  74.        local sidey1 = true
  75.        local sidey2 = false
  76.        local sidex1 = false
  77.        local sidex2 = false
  78.        getSapling()
  79.    end
  80.    if x == 10 and y == 0 then
  81.        turtle.turnLeft()
  82.        turtle.back()
  83.        y = y + 1
  84.        local sidey1 = false
  85.        local sidey2 = true
  86.        local sidex1 = false
  87.        local sidex2 = false
  88.        getSapling()
  89.    end
  90.    if x >= 1 or x <= 9 and y == 0 or y == 7 then
  91.        turtle.back()
  92.        if sidex1 == true then
  93.            x = x - 1
  94.            getSapling()
  95.        end
  96.        if sidex2 == true then
  97.            x = x + 1
  98.            getSapling()
  99.        end
  100.    end
  101.    if y >= 1 or y <= 6 and x == 0 or x == 10 then
  102.        turtle.back()
  103.        if sidey1 == true then
  104.            y = y - 1
  105.            getSapling()
  106.        end
  107.        if sidex2 == true then
  108.            y = y + 1
  109.            getSapling()
  110.        end
  111.    end
  112. end
  113. ---------------
  114.  
  115. getSapling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement