Jump to content




Measuring a monitor

peripheral game computer

5 replies to this topic

#1 Awsomehawk

  • Members
  • 18 posts

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.

#2 Awsomehawk

  • Members
  • 18 posts

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.

#3 Awsomehawk

  • Members
  • 18 posts

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.

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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


#5 Awsomehawk

  • Members
  • 18 posts

Posted 26 March 2013 - 06:43 AM

Ok works great so far thank you for the help.

#6 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 26 March 2013 - 06:45 AM

no problems and your welcome. :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users