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

Problem with cPrint

Started by nutcase84, 05 April 2013 - 09:08 AM
nutcase84 #1
Posted 05 April 2013 - 11:08 AM
It doesn't print it in the middle, it prints to the side. What am I doing wrong?

function cPrint(message)
  local blarghx, blarghy = term.getCursorPos()
  local termX, termY = term.getSize()
  term.setCursorPos(termX/2 - #message, blarghy)
  print(message)
end
Sammich Lord #2
Posted 05 April 2013 - 11:10 AM
Lemme give you a nice little function:

local x, y = term.getSize()
function cPrint(str, ypos)
  term.setCursorPos(x/2-#str/2, ypos)
  term.write(str)
end
I use that function all the time.
nutcase84 #3
Posted 05 April 2013 - 11:16 AM
THANK YOU!!!! :)/>