252 posts
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
139 posts
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?
252 posts
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.
1688 posts
Location
'MURICA
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
521 posts
Location
Stockholm, Sweden
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
1688 posts
Location
'MURICA
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.
252 posts
Posted 26 October 2012 - 02:43 AM
Lol, thanks guys, I didn't know where I was going wrong, but this works perfect!