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

Print to bottom right of screen. [help][lua]

Started by ChaddJackson12, 25 October 2012 - 10:30 PM
ChaddJackson12 #1
Posted 26 October 2012 - 12:30 AM
I am trying to print text to the bottom of the screen, can someone help me?

Here is the code I have so far. (It prints one line from the bottom, on the left)


function printBR( text )
  x, y = term.getSize()
  SetX = - x
  SetY = - y
  term.setCursorPos(x, y)
  print( text )
  term.setCursorPos(1, 1)
end
tom2018 #2
Posted 26 October 2012 - 12:36 AM
is the text you are printing take up more room than is available then move down to the next line and scroll down one putting it on the left?
ChaddJackson12 #3
Posted 26 October 2012 - 12:37 AM
is the text you are printing take up more room than is available then move down to the next line and scroll down one putting it on the left?
It takes up about 7 - 15 letters. Not more than the width of the screen.
Kingdaro #4
Posted 26 October 2012 - 12:37 AM
Simple, just get the width and height of the screen and do some simple math.

The text is going to be printed at the left of the screen, minus how many characters are in the text in order for all of it to show.

function printBottomRight(text)
  local w,h = term.getSize()
  term.setCursorPos(w - #text, h)
  write(text)
end
jag #5
Posted 26 October 2012 - 12:38 AM
function printBR(text)
  local w,h = term.getSize()
  term.setCursorPos(w-#text,h)
  write(text)
end

EDIT: Hah! A split seconds after you kingdaro! And we got identical scripts! LOL
Kingdaro #6
Posted 26 October 2012 - 12:43 AM
That's ridiculously uncanny.

I did feel like I was in some super mega Lua coding race with all of the people below reading the topic, haha.
ChaddJackson12 #7
Posted 26 October 2012 - 02:43 AM
Lol, thanks guys, I didn't know where I was going wrong, but this works perfect!