Jump to content




[Question] Monitor text help!


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

#21 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

Posted 04 January 2013 - 09:52 AM

-snip- Double post for some reason

#22 Relk

  • New Members
  • 9 posts

Posted 04 January 2013 - 09:56 AM

Thanks for the help everyone! Worked perfectly!

#23 Bubba

    Use Code Tags!

  • Moderators
  • 1,142 posts
  • LocationRHIT

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

#24 Relk

  • New Members
  • 9 posts

Posted 04 January 2013 - 09:57 AM

View PostBubba, 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 FUCKCOMPUTERCRAFT!"£

  • Validating
  • 87 posts
  • LocationBasement

Posted 04 January 2013 - 10:05 AM

View PostBubba, on 04 January 2013 - 09:46 AM, said:

View PostRelk, on 04 January 2013 - 09:37 AM, said:

Getting this error.

Posted Image

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

View Postx0pk1n, 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 Loki

  • New Members
  • 26 posts
  • LocationA flatland world with 100's of computers and a village that was covered with lava with a parkour course about it; Minecraftia.

Posted 04 January 2013 - 11:12 AM

View PostRelk, on 04 January 2013 - 09:37 AM, said:

View PostBubba, on 04 January 2013 - 09:20 AM, said:

View PostRelk, 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.

Posted Image
Damn that pentagon is hypnotising me like crazy!...Just saying <_<

#27 remiX

  • Members
  • 2,076 posts
  • LocationSouth Africa

Posted 04 January 2013 - 08:24 PM


x0pk1n can you post the full code so we can find the error.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users