Startup

You might also like

You are on page 1of 3

--programa basico para talar arbol

--de 1 o 2 de ancho

local log = "minecraft:oak_log"


local log2 = "spruce_log"
local log3 = "minecraft:log2"

function cut1()
altura = 0
while turtle.detectUp() do
altura = altura + 1
turtle.digUp()
turtle.up()
end
for i = 0, altura do
turtle.down(altura)
end
turtle.back()
end

function cut2(l_l)
altura = 0
turtle.dig()
while turtle.detectUp() do
altura = altura + 1
turtle.digUp()
turtle.up()
turtle.dig()
end

if l_l == 1 then
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnRight()
else
turtle.turnRight()
turtle.dig()
turtle.forward()
turtle.turnLeft()
end

turtle.dig()
for i = 1, altura do
turtle.digDown()
turtle.down()
turtle.dig()
end

if l_l == 1 then
turtle.turnLeft()
turtle.back()
turtle.turnRight()
turtle.back()
else
turtle.turnRight()
turtle.back()
turtle.turnLeft()
turtle.back()
end

end

function cut(t_t)
if t_t == 0 then
cut1()
else
cut2(t_t)
end
end

function rearrange()
print("preparando")
turtle.select(1)

if turtle.getItemCount(1) ~= 0 then
for i = 2, 16 do
if turtle.getItemCount(i) > 0 then
if turtle.compare(i) then
turtle.transferTo(i)
break
end
elseif turtle.getItemCount(i) < 1 then
turtle.transferTo(i)
break
end
end
turtle.select(1)
end
end

function checkTree()
rearrange()
turtle.dig()
turtle.forward()

succ, b_front = turtle.inspect()


log_tree = turtle.getItemDetail(1)
if turtle.detect() then
if b_front.name == log then
turtle.turnLeft()
succ2, b_front2 = turtle.inspect()
turtle.turnRight()
if b_front2.name == log_tree.name then
return 1
else
return 2
end
else
return 0
end
else
return 0
end

end

function plant_tree()
--to do
end

--INIT
local success, d = turtle.inspect()

if d.name ~= log then


write("Colocame frente a un arbol")
else
cut(checkTree())

term.clear()
term.setCursorPos(1, 1)
print("Finalizado.")
end
read()

You might also like