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

Detecting Computer Type (PC or PDA)

Started by JMZ10, 25 May 2014 - 12:51 AM
JMZ10 #1
Posted 25 May 2014 - 02:51 AM
I would like to make a program (with graphical interface) capable of running on both PDAs and PCs.
Trouble is I can't find a way to make a program detect which type computer it's running on in order to render the gui accordingly.
I could ask the user running it what type it is but I would prefer if the program could determine it automatically.

If possible, how I can achieve this?
CCJJSax #2
Posted 25 May 2014 - 04:49 AM
use term.getSize(). they have different screen dimensions.
theoriginalbit #3
Posted 25 May 2014 - 05:01 AM
obviously the suggestion that CCJJSax suggested is the best, if you make you GUI based on percentiles of the terminal size then your program will also run nicely on monitors. however it is also possible to detect where the program is being run


if not term.isColor then
  print("running on pre-ComputerCraft 1.45; nothing can be changed with colours.")
elseif term.isColor() then
  print("running on ComputerCraft 1.45 or later and is advanced; you can change to any colour you wish")
else
  print("running on ComputerCraft 1.45 or later and is normal; you can change between black and white")
end

if turtle then
  print("I am running on a Turtle")
elseif pocket then
  print("I am running on a Pocket Computer")
else
  print("I am running on a Computer")
end
Edited on 25 May 2014 - 03:02 AM