Jump to content




[LUA] program question. HELP ASAP


  • You cannot reply to this topic
4 replies to this topic

#1 predatorxil

  • Members
  • 19 posts

Posted 30 August 2012 - 11:20 PM

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!

#2 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 31 August 2012 - 01: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.

#3 Exerro

  • Members
  • 801 posts

Posted 31 August 2012 - 01:12 AM

View Postluanub, on 31 August 2012 - 01:07 AM, said:

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


#4 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

Posted 31 August 2012 - 01:18 AM

View Postawsumben13, on 31 August 2012 - 01:12 AM, said:

View Postluanub, on 31 August 2012 - 01:07 AM, said:

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..

#5 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 31 August 2012 - 03: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






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users