--------------------------------------------------- --Center-API-by-jack------------------------------- --------------------------------------------------- -- --How to use-- -- Enter this function to include this API -- -- os.loadAPI( enter here path to this API ) -- -- -- --Functions-- -- -- Function: CentralWrite(y,text) -- -- Description: Draws text on Center of Screen on -- different y -- -- Example: CentralWrite(5,"hello") - writes hello -- on center of line #5 -- -- -- Function: GetScrCenterX(pixels) -- -- Description: Returns Center of Screen for -- Centered text or any needs (returns two poses -- start and end of center) -- -- Example: GetScrCenterX(4) - returns two points -- of center to draw line or text with size -- 4 pixels -- -- -- Function: GetScrCenterY(pixels) -- -- Description: Works as well as GetScrCenterX ,but -- gets two points of y center -- -- Example: GetScrCenterY(3) - returns two points -- of center on Y axys for 3 pixels -- -- -- Function: GetCenter(start pos,end pos,pixels) -- -- Description: Works as well as GetScrCenterX or -- GetScrCenterY ,but gets center two points with -- using entered start and end pos -- -- Example: GetCenter(2,8,2) - gets two center -- points of entered here points of x axys -- -- --The End-- -- --Sorry for bad english-- -- --Code of this api here-- -- \/\/\/\/\/\/\/\/\/\/\/\/ --------------------------------------------------- function CentralWrite(y,text) scrX = term.getSize() x = (scrX/2)-(#text/2) term.setCursorPos(x,y) write(text) end function GetScrCenterX(pixels) scrX = term.getSize() x = (scrX/2)-(pixels/2) x2 = x+pixels-1 return x,x2 end function GetScrCenterY(pixels) scrX,scrY = term.getSize() y = (scrY/2)-(pixels/2) y2 = y+pixels-1 return y end function GetCenter(SP,EP,pixels) Center = math.floor(SP+((EP-SP)/2)-pixels/2) CenterP2 = Center+pixels-1 return Center,CenterP2 end