Hey everyone, i am making a program and i added some theme support and i want to print a big space (not all) of the screen. I tried to use paintutils to draw an image, but it would print only the color that i choose in paint. I am trying to print line by line and it worked until the last line, where it changed to a new line. So i cant print the last line becasue the computercraft will always change to a new line. Any sugestions or anyone knows how to disable the new line thing? Thanks in advance.
Disable new line?
Started by RoD, Apr 13 2014 10:19 PM
3 replies to this topic
#1
Posted 13 April 2014 - 10:19 PM
#2
Posted 13 April 2014 - 10:21 PM
I'm not entirely sure I understand what you're on about, but I can tell you that "print" will perform a linebreak at the end of whatever text you pass it, and "write" won't. "term.write" will avoid word-wrap, too.
Edited by Bomb Bloke, 13 April 2014 - 10:21 PM.
#3
Posted 14 April 2014 - 08:34 AM
When dealing with GUI I highly encourage people to use term.write. Why not print or write? print and write functions apply new lines and word wrapping which is totally unnecessary when it comes to drawing a GUI. I actually had a problem when I was making an OS: I couldn't write anything to the right side of the screen because of word wrapping print and write used.
Also, if you just want to draw some lines, boxes or pixels you can always use paintutils.drawLine and paintutils.drawPixel or write your own drawing algorithms. Here's a simple function which would draw a box:
Which you could use like this:
Also, if you just want to draw some lines, boxes or pixels you can always use paintutils.drawLine and paintutils.drawPixel or write your own drawing algorithms. Here's a simple function which would draw a box:
local function drawBox (x, y, width, height, color)
if color then
term.setBackgroundColor(color)
end
for h = y, y + height - 1 do
term.setCursorPos(x, h)
term.write(string.rep(" ", width))
end
end
Which you could use like this:
drawBox(3, 2, 10, 7, colors.green) -- Draws a 10 wide and 7 tall green box who's top-left corner is at X: 3 and Y: 2
#4
Posted 14 April 2014 - 11:31 AM
MKlegoman357, on 14 April 2014 - 08:34 AM, said:
When dealing with GUI I highly encourage people to use term.write. Why not print or write? print and write functions apply new lines and word wrapping which is totally unnecessary when it comes to drawing a GUI. I actually had a problem when I was making an OS: I couldn't write anything to the right side of the screen because of word wrapping print and write used.
Also, if you just want to draw some lines, boxes or pixels you can always use paintutils.drawLine and paintutils.drawPixel or write your own drawing algorithms. Here's a simple function which would draw a box:
Which you could use like this:
Also, if you just want to draw some lines, boxes or pixels you can always use paintutils.drawLine and paintutils.drawPixel or write your own drawing algorithms. Here's a simple function which would draw a box:
local function drawBox (x, y, width, height, color)
if color then
term.setBackgroundColor(color)
end
for h = y, y + height - 1 do
term.setCursorPos(x, h)
term.write(string.rep(" ", width))
end
end
Which you could use like this:
drawBox(3, 2, 10, 7, colors.green) -- Draws a 10 wide and 7 tall green box who's top-left corner is at X: 3 and Y: 2
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











