m = peripheral.wrap("back")
m.clear()
mX,mY = m.getSize()
x = math.floor(mX/2) - math.floor(string.len("text")/2)
y = math.floor(mY/2) - math.floor(string.len("text")/2)
m.setTextScale(1)
m.setCursorPos(x, y)
m.write("Market")
Showing text in the middle of monitors (Advanced of course)
Started by Bloodmorphed, Sep 30 2015 05:46 AM
2 replies to this topic
#1
Posted 30 September 2015 - 05:46 AM
So far I have this:
#2
Posted 30 September 2015 - 03:51 PM
Please read this, specifically the section about posting a good question. You've left us to guess what you expect the program to do and what it's actually doing instead. Also, you haven't asked a question.
In your case, the problem is obvious - you're setting the cursor position based on the length of the string "text", then you're writing the string "Market". "Market" will never be centered as long as you position the cursor based on the string "text" instead of the string "Market".
In your case, the problem is obvious - you're setting the cursor position based on the length of the string "text", then you're writing the string "Market". "Market" will never be centered as long as you position the cursor based on the string "text" instead of the string "Market".
#3
Posted 30 September 2015 - 03:52 PM
What's your problem?
This should work:
This should work:
local width, height = term.getSize() local function centreWrite( text ) term.setCursorPos( math.floor( width / 2 - #text / 2 ) + 1, math.floor( height / 2 ) + 1 ) term.write( text ) endJust replace term with 'm' or whatever.
Edited by awsumben13, 30 September 2015 - 03:53 PM.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users











