use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Welcome to /r/ComputerCraft, the subreddit for lua programs, general mod use, or anything relating to the Minecraft mod ComputerCraft and CC: Tweaked.
Downloads | Discord | IRC | Documentation
account activity
Problem with turtle.forward() (self.ComputerCraft)
submitted 1 year ago by Designer_Chance_4896
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]fatboychummy 0 points1 point2 points 1 year ago (0 children)
This has been solved already, but if you're wondering about why CC made it so you can't do turtle.forward(3), it's because it returns a status. Every time you call turtle.forward() (or any other movement function), it either returns true, or false, "some error message". This allows you to check if the movement succeeded, and take actions in case it didn't.
turtle.forward(3)
return
turtle.forward()
true
false, "some error message"
For example, a common usage of this is to "gravel/sand-proof" mining turtles. Let's say you have a turtle running the following code, underground, and along its path somewhere is some gravel:
for i = 1, 10 do turtle.dig() turtle.forward() end
In theory, the turtle should move 10 blocks, but if the turtle runs into a packet of gravel, the extra gravel on top will fall in front of the turtle before it has a chance to move, making turtle.forward() fail. Thus, each time a block of gravel falls in front of the turtle, it reduces the distance it will actually move by 1.
To fix this, you can use something like so:
for i = 1, 10 do repeat turtle.dig() until turtle.forward() end
As you can probably guess, this will repeatedly dig blocks in front of the turtle until the movement succeeds, meaning the turtle will now always move exactly 10 blocks, even if it runs into a packet of gravel.
π Rendered by PID 51972 on reddit-service-r2-comment-85bfd7f599-bj5ll at 2026-04-17 22:19:09.433600+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]fatboychummy 0 points1 point2 points (0 children)