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

Measuring a monitor

Started by Awsomehawk, 26 March 2013 - 05:24 AM
Awsomehawk #1
Posted 26 March 2013 - 06:24 AM
I was thinking if there is a way to find the size of a monitor. I'm thinking if there is a way to find min and max cursor positions but I have a felling that's not possible. If you know another way or idea can you please help.
Awsomehawk #2
Posted 26 March 2013 - 06:33 AM
Sorry I thought the way I worded it was a bit confusing basically by measure I mean how many characters can you fit on the monitor no matter what the text size is set to.
Awsomehawk #3
Posted 26 March 2013 - 06:35 AM
Sorry I thought the way I worded it was a bit confusing basically by measure I mean how many characters can you fit on the monitor no matter what the text size is set to.
theoriginalbit #4
Posted 26 March 2013 - 06:35 AM
first method

local width, height = peripheral.call( 'left', 'getSize' )
this is a way not used by many, I just felt like putting it in here :P/>

second method

local monitor = peripheral.wrap( 'left' )
local width, height = monitor.getSize()
this one is used by most people…. but the next is imo the best way…

third method

local monitor = peripheral.wrap('left')
term.redirect(monitor)
local width, height = term.getSize()
term.restore()

this last method is a good method of doing easy printing and such to monitors as you can use the same functions you use for the computer.
it can actually open up some really nice stuff like so


if peripheral.getType('left') == 'monitor' then
  term.redirect( peripheral.wrap('left') )
end

print("This text can print on a monitor if there is one available, or else it just prints on the computers screen")


if peripheral.getType('left') == 'monitor' then
  term.restore()
end
Awsomehawk #5
Posted 26 March 2013 - 06:43 AM
Ok works great so far thank you for the help.
theoriginalbit #6
Posted 26 March 2013 - 06:45 AM
no problems and your welcome. :)/>