Posted 07 August 2012 - 12:44 AM
I am currently making a OS with a GUI. What I would like to happen, is the GUI text is printed in the centre. Does anyone know how I would be-able to do this?
local function center(str)
local width = term.getSize()
local x,y = term.getCursorPos()
term.setCursorPos((width-#str)/2,y)
return str
end
print(center(string here))
Uhh.. English?<p>This Should do it </p>
<br />
<div><span></span></div></span> <div><span>local function center(str)</span></div> <div><span> local width = term.getSize()</span></div> <div><span> local x,y = term.getCursorPos()</span></div> <div><span> term.setCursorPos((width-#str)/2,y)</span></div> <div><span> return str</span></div> <div><span>end</span></div> <span>
<div> </div>
<div>Then just Call it using </div>
<div><span></span></div>print(center(string here))
<div> </div>