957 posts
Location
Web Development
Posted 15 February 2015 - 09:44 PM
To check if a computer is advanced or not is really easy. Just do 'term.isColor()'
To check if a computer is a turtle, just check to see if the turtle api was initialized.
How do you check if a computer is a pocket computer or a regular (block) computer?
I've been using the screen size:
local w,h = term.getSize()
if w ~= 51 and h ~= 19 then
--#Not a block computer
end
But I realized that if the program is being run in a window, the size will change.
So how do you know for sure?
808 posts
Posted 15 February 2015 - 09:54 PM
I believe that there's a blank "pocket" table in the global space if its a PDA.
function os.getComputerType()
local ret = {}
if term.isColor() then
table.insert(ret, "advaned")
end
if pocket then
table.insert(ret, "pda")
elseif turtle then
table.insert(ret, "turtle")
else
table.insert(ret, "computer")
end
return table.concat(ret, "_")
end
This should return things in the format of "advanced_pda". Really there should be similar functions in CraftOS.
45 posts
Location
IA, USA
Posted 15 February 2015 - 09:54 PM
Use term.getSize() it returns the dimensions of the screen and you can conclude if it is pocket regular or turtle. If you are asking about advanced vs non advanced computers then I am pretty sure there is a function that returns true or false but not 100% sure! Hope this helps! :)/>
957 posts
Location
Web Development
Posted 16 February 2015 - 03:15 AM
Use term.getSize() it returns the dimensions of the screen and you can conclude if it is pocket regular or turtle.
I realized that if the program is being run in a window, the size will change.
So how do you know for sure?
7083 posts
Location
Tasmania (AU)
Posted 16 February 2015 - 06:50 AM
Er, to elaborate on that, it's possible to
define "virtual displays",
redirect the terminal to them, and run programs within the result. This is process that
multishell relies on, for example. Because these windows don't have to be of the same size as the computer's "real" display, programs can't trust term.getSize() to return the dimensions of the actual computer screen.
Although I suppose you could always check up on term.native()… In any case, EJ seems to have pegged a simpler answer.
2151 posts
Location
Auckland, New Zealand
Posted 16 February 2015 - 09:38 AM
I believe that there's a blank "pocket" table in the global space if its a PDA.
function os.getComputerType()
local ret = {}
if term.isColor() then
table.insert(ret, "advaned")
end
if pocket then
table.insert(ret, "pda")
elseif turtle then
table.insert(ret, "turtle")
else
table.insert(ret, "computer")
end
return table.concat(ret, "_")
end
This should return things in the format of "advanced_pda". Really there should be similar functions in CraftOS.
Yeah this seems like a pretty complete answer. The only change I'd make would be to add the new command computers.
function os.getComputerType()
local ret = {}
if term.isColor() then
table.insert(ret, "advaned")
end
if pocket then
table.insert(ret, "pda")
elseif turtle then
table.insert(ret, "turtle")
elseif commands then
table.insert(ret, "command")
else
table.insert(ret, "computer")
end
return table.concat(ret, "_")
end
I think that should work… although as a disclaimer, I haven't actually even downloaded 1.7 or any of the betas due to lack of time yet.
Edited on 16 February 2015 - 08:40 AM
957 posts
Location
Web Development
Posted 16 February 2015 - 03:53 PM
Thanks for all your replies.
ElvishJerricco, I think I'll end up using your suggestion (Although you spelled 'advanced' wrong :)/> )
oeed, thas's a good point, but the screen is basically the same as the advanced computer, and that's really what I'm worried about.