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

Detect if a program is running on a Turtle or Computer?

Started by Corbald, 24 July 2012 - 07:56 PM
Corbald #1
Posted 24 July 2012 - 09:56 PM
I have searched the forums, the Wiki and google and can't find anything that'll work for me.

I'm trying to make a startup program that'll boot on a turtle, but NOT a computer. Is there any method to detect what a program is running on, or any difference in the default file structure, or any difference AT ALL that I can detect and work with?
MysticT #2
Posted 24 July 2012 - 09:58 PM
The turtle api is not present on computers, so you can use it to check if it's a turtle:

if turtle then
  print("Yay! I'm a turtle.")
else
  print("Hello, I'm a computer.")
end
Corbald #3
Posted 24 July 2012 - 10:08 PM
Wow! Thanks for the easy way! I was afraid I was going to have to do something silly like detect display size or somesuch!
Noodle #4
Posted 25 July 2012 - 09:57 AM
The "turtle" is a built-in component. It would suck if you had to write out the turtle "way".