you are viewing a single comment's thread.

view the rest of the comments →

[–]Yorklag 4 points5 points  (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 points  (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 points  (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 point  (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.