0% found this document useful (0 votes)
15 views3 pages

Startup

This document contains Lua code for a basic program to cut down trees of 1 or 2 blocks wide using a turtle in Minecraft. It defines functions for cutting down a single tree, cutting down a tree and turning either left or right, checking what type of tree is present, and rearranging items in the turtle's inventory. The main code calls these functions to cut down the tree detected in front of the turtle.

Uploaded by

maj.jza731
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Startup

This document contains Lua code for a basic program to cut down trees of 1 or 2 blocks wide using a turtle in Minecraft. It defines functions for cutting down a single tree, cutting down a tree and turning either left or right, checking what type of tree is present, and rearranging items in the turtle's inventory. The main code calls these functions to cut down the tree detected in front of the turtle.

Uploaded by

maj.jza731
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 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