Jump to content




Problem with cPrint


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

#1 nutcase84

  • Members
  • 711 posts
  • LocationIn My Lonely Little Computer Corner

Posted 05 April 2013 - 10: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


#2 Sammich Lord

    IRC Addict

  • Members
  • 1,212 posts
  • LocationThe Sammich Kingdom

Posted 05 April 2013 - 10: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.

#3 nutcase84

  • Members
  • 711 posts
  • LocationIn My Lonely Little Computer Corner

Posted 05 April 2013 - 10:16 AM

THANK YOU!!!! :)





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users