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

[LUA] program question. HELP ASAP

Started by predatorxil, 30 August 2012 - 10:20 PM
predatorxil #1
Posted 31 August 2012 - 12:20 AM
Hello,

Im trying to make text on the screen span from one end to the other without having to count the spaces, or basically trial and error it.
Here's what ive been doing……

Term.setCursorPos(1,1)
print("____________________________________________")


Thats waht ive done before, im trying to get it so if i attach a monitor of larger size it spans that monitor length. Im am somewhat new to coding, so srry im confusing the F*** out of you, but please help in anyway!

Thanks!
Luanub #2
Posted 31 August 2012 - 02:07 AM
Try doing something like this. I haven't tested it but it should work.


local x, y = term.getSize() -- x is the lines, y is the characters on the line
for a=1, y do
write("_")
end

You will probably want to set the line number that you want to print it on.
Exerro #3
Posted 31 August 2012 - 02:12 AM
Try doing something like this. I haven't tested it but it should work.


local x, y = term.getSize() -- x is the lines, y is the characters on the line
for a=1, y do
write("_")
end

You will probably want to set the line number that you want to print it on.
that will make 18 lines (y is the down length) try this function:

function drawLine(nLine,character)
local x, y = term.getSize()
term.setCursorPos(1,nLine)
for i = 1,x do
write(character)
end
end
Luanub #4
Posted 31 August 2012 - 02:18 AM
Try doing something like this. I haven't tested it but it should work.


local x, y = term.getSize() -- x is the lines, y is the characters on the line
for a=1, y do
write("_")
end

You will probably want to set the line number that you want to print it on.
that will make 18 lines (y is the down length) try this function:

function drawLine(nLine,character)
local x, y = term.getSize()
term.setCursorPos(1,nLine)
for i = 1,x do
write(character)
end
end

lol you're right I had them backwards..
Kingdaro #5
Posted 31 August 2012 - 04:08 AM
You know, you could just use string.rep(), it's easier than using a for loop.

function drawLine(nLine, sChar)
  local w,h = term.getSize()
  print(string.rep(sChar, w))
end