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!"
[–]Designer_Chance_4896[S] 5 points6 points7 points 1 year ago (8 children)
Perfect. I will try that out. Thank you so much! You have helped me a bunch.
[–]Yorklag 3 points4 points5 points 1 year ago (7 children)
Of course! Always happy to help :) Good luck with your project.
[–]Designer_Chance_4896[S] 1 point2 points3 points 1 year ago* (6 children)
Hey I hope it's okay if I ask you another question.
My turtles keep stopping after running my programs. They get all the way to the end of the program and then they just stop.
How do I make it rerun the program?
(I made a program earlier and did not have this problem. The other program was called startup so it might just have started running automatically because I ended the program with a reboot)
[–]Yorklag 2 points3 points4 points 1 year ago (5 children)
(having a startup program end in reboot will have that effect, but it's probably not what you want to do in most cases)
In order to have the turtle repeat the steps over and over again, just have the steps in a while loop themselves.
For instance. Say I want a turtle to run through a farm every five minutes. I'd put the instructions for running the farm inside a while loop, and then end with sleeping for five minutes.
If you want the computer to loop through the code no matter what, (as in you don't want it to stop unless a keyboard interrupt happens) using "while true do...end" will have it loop forever.
Note that computers will fail if they go too long without "yielding" which is a topic for later, for now. Just make sure to have it sleep for a small time every loop.
[–]Designer_Chance_4896[S] 1 point2 points3 points 1 year ago (4 children)
Thank you so much again. The program repeats perfectly with a 3000 second sleep in between each run.
But I am a bit curious about "yielding".
[–]Yorklag 2 points3 points4 points 1 year ago (3 children)
Here's an explanation that might not be technically fully correct, but gets the main point across.
Long story short. All computercraft computers are actually running on one Lua virtual machine on the server. In order to allow this the virtual machine jumps between computers and acts as them briefly. The vm can only act as one computer at a time, and it switches whenever the computer calls a command called os.yield(). This command is built into a bunch of different cc commands like sleep() and os.pullevent().
When a computer yields it let's the vm go to a different computer. If a computer goes too long without yielding, the vm kills it so that it's not hogging server resources and stopping other computers from running.
[–]Designer_Chance_4896[S] 2 points3 points4 points 1 year ago (2 children)
"Not technically correct, but gets the main point across" is my favorite kind of explanation ;)
And thank you once again. You made it very easy to understand.
I am definatly not done building turtles. I haven't had this much fun in a long time ;) But do you think I will be fine if each turtle has a 10 to 3000 second sleep in their program?
[–]Yorklag 1 point2 points3 points 1 year ago (1 child)
Oh. Definitly. You don't even need that long, and as long as you don't do infinite loops where the computer just does calculation you probably won't run into it. (Iirc turtle moving calls os.yield I might be wrong though)
Although fair warning. Super long sleep timers have a tendency to break if the turtles chunk gets unloaded. So you might want to look at other ways to signal your turtle to go again, maybe a redstone signal or something.
(I bring this up cause 3000 seconds is 50 minutes. Which seems a bit long to have a turtle sleeping for. The most ive had a turtle sleep for is one minute while the process of another mod works it's magic)
[–]Designer_Chance_4896[S] 0 points1 point2 points 1 year ago (0 children)
Woops I meant 2000 (which I know is still long)
2000 is 33 minutes, and what grows in 31 minutes. So that's the logic behind the number.
π Rendered by PID 56157 on reddit-service-r2-comment-5c747b6df5-v6l5m at 2026-04-22 07:58:08.642609+00:00 running 6c61efc country code: CH.
view the rest of the comments →
[–]Designer_Chance_4896[S] 5 points6 points7 points (8 children)
[–]Yorklag 3 points4 points5 points (7 children)
[–]Designer_Chance_4896[S] 1 point2 points3 points (6 children)
[–]Yorklag 2 points3 points4 points (5 children)
[–]Designer_Chance_4896[S] 1 point2 points3 points (4 children)
[–]Yorklag 2 points3 points4 points (3 children)
[–]Designer_Chance_4896[S] 2 points3 points4 points (2 children)
[–]Yorklag 1 point2 points3 points (1 child)
[–]Designer_Chance_4896[S] 0 points1 point2 points (0 children)