This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
VivusDeus's profile picture

Woodcutter Turtle

Started by VivusDeus, 19 October 2017 - 02:58 AM
VivusDeus #1
Posted 19 October 2017 - 04:58 AM
I got the problem that I started with programming turtles again. Back in my days a sapling was not detected as full block.
Now I tried using the command turtle.compare() which completly fails its job it seems to me.
Got a solution with turtle.inspect(). Everything seemed fine, but now it seems to execute the if statement where comparing the block in front with "minecraft:log" three times no matter what.
Second problem after restarting minecraft: It detects the sapling as log. Resulting in just cutting the sapling over and over. Worked in the past for any reason.
Third problem: After working with os.sleep() the my if condition seems to always fail and else part is running.

Second and third problem occured after restating minecraft.

Thank you for your upcoming help to this.

https://pastebin.com/BRD9n0Ai

<script src="https://pastebin.com/embed_js/BRD9n0Ai"></script>

block, typ = turtle.inspect()

– Cut down the tree
function rodung()
turtle.dig()
turtle.forward()
while turtle.detectUp() do
turtle.digUp()
turtle.up()
end
while not turtle.detectDown() do
turtle.down()
end
turtle.back()
end

–planting the sapling
function pflanzen()
turtle.select(16)
turtle.place()
turtle.select(1)
end
– Warning to put saps in Slot 16
function hinweis()
print("Bitte Setzlinge in Slot 16")
end

hinweis()
while true do
– compares the block in front with "minecraft:log"
if block == true then
for k,v in pairs(typ) do
– if so, do cut the tree and plant again
if v == "minecraft:log" then
print("Baumstamm gewachsen")
rodung()
pflanzen()
else
– print "no tree" and wait
print("Noch kein Baum")
os.sleep(10)
end
end
end
–wait again then clear screen
os.sleep(10)
term.clear()
term.setCursorPos(1, 1)
end
Bomb Bloke #2
Posted 19 October 2017 - 10:18 AM
block, typ = turtle.inspect()

This sets up "typ" to point to a table containing information about the block that was in front of the turtle at the time you made the "inspect" call. That table will not automatically update as the turtle moves around.
VivusDeus #3
Posted 19 October 2017 - 06:00 PM
Wow thanks alot, didnt even think about that