-snip- Double post for some reason
[Question] Monitor text help!
Started by Relk, Jan 04 2013 07:36 AM
26 replies to this topic
#21
Posted 04 January 2013 - 09:52 AM
#22
Posted 04 January 2013 - 09:56 AM
Thanks for the help everyone! Worked perfectly!
#23
Posted 04 January 2013 - 09:56 AM
Okay I'm confused now. I thought that there were too many entries for it all to fit on one line. The issue with just printing it centered is that if it continues onto the next line, some text will be overwritten.
Edit: OP's problem is solved so nevermind
Edit: OP's problem is solved so nevermind
#24
Posted 04 January 2013 - 09:57 AM
Bubba, on 04 January 2013 - 09:52 AM, said:
Okay I'm confused now. I thought that there were too many entries for it all to fit on one line. The issue with just printing it centered is that if it continues onto the next line, some text will be overwritten.
That was the main issue, but I put your code in and it worked, but it was not centered.
#25
Posted 04 January 2013 - 10:05 AM
Bubba, on 04 January 2013 - 09:46 AM, said:
Relk, on 04 January 2013 - 09:37 AM, said:
Getting this error.


Could you tell me what is on line 42? I just tried the code and it works fine for me. Just in case the code in the code box code box got fudged somehow, here it is again.
local yValue = 1 local xValue = 1 local xSize, ySize = term.getSize() local function writeAt(text) term.setCursorPos((10+xValue)/2-(#text/2), yValue) term.write(text) if yValue == ySize then yValue = 1 xValue = xValue + 20 else yValue = yValue + 1 end end for i=1, #tText do writeAt(tText[i]) end
x0pk1n, on 04 January 2013 - 09:37 AM, said:
function cPrint( text ) -- prints in the centre of the current line. -- Z is just their to stop errors local z,y = term.getCursorPos() local x,z = term.getSize() local textL = string.len(text) local xCor = x/2 - textL/2 term.setCursorPos(xCor, y) print(text) end
This is what I use to have the text begin from the centre.... Taken from my GUI functions
You have a similar problem to the one Remix had; you're still printing from the center of the page, not the column.
Yes my code centres it as you wanted... Just now do cPrint("NAME < FEW SPACES> NAME") You can make it appear like coloums by just putting spaces....
#26
Posted 04 January 2013 - 11:12 AM
Relk, on 04 January 2013 - 09:37 AM, said:
Bubba, on 04 January 2013 - 09:20 AM, said:
Relk, on 04 January 2013 - 09:04 AM, said:
Thanks a lot, it worked for me but I want it centered, I am having trouble doing that, can you help me?
Sure. You want it centered in the column I'm guessing? Try this.
local monitor = peripheral.wrap("left")
local xSize, ySize = monitor.getSize()
local xValue = 0
local yValue = 1
local function writeAt(text)
monitor.setCursorPos((10+xValue)/2-(#text/2), yValue) --Half of the column size + the starting xValue - half of the text length
monitor.write(text)
if yValue == ySize then
yValue = 1
xValue = xValue + 20
else
yValue = yValue + 1
end
end
for i=1, #tText do
writeAt(tText[i])
end
end
Getting this error.

1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











