darkdreamingdan Posted March 6, 2009 Share Posted March 6, 2009 Textlib is a library i wrote to make creation of dxText much easier, while also allowing it to be flexible. It's what i used for my Dance resource (in the MTA vid) to create the text. It makes stuff like shadowed and stroked text a breeze and generally gets rid of the hassle. It also includes an extension for arc's client_anim library to make text animation easy. * By default, Textlib creates centred aligned text and is positioned like serverside textdisplays for maximum simplicity. * if you need to use wordwrap, you will require the use of boundingBox function. This overrides the "position" setting, and sets a bounding box for the text to be wrapped under. * Wordwrap is enabled by default as long as you add a bounding box. * To remove bounding box, use text:boundingBox(false) and it will restore to default positioning using "position" setting. * Make sure you remove any variables that contain references to destroyed text, i.e. "myText = nil" * Scale,font,postGUI,clip parameters mimic dxDrawText * There is a single bug that i know of. "bottom" aligned text does not support multiple lines - wordwrapped or \n'd. * All functions, besides create and destroy, return the current set values if you pass invalid or no arguments, e.g. x,y = text:position() dxText:create( text, x, y, [relative = true ]) --Create dxText dxText:text( text ) -- Change text dxText:position(x,y, [relative = true]) -- Change position dxText:color(r,g,b,[a]) -- Change color dxText:scale(scale) -- Set text scale dxText:visible(bool) -- Make visible or invisible dxText:destroy() -- Delete the dxtext, stop drawing it dxText:font(font) -- Change the dxtext font dxText:postGUI(bool) -- Change whether the text should be drawn on top of or behind any ingame GUI (rendered by CEGUI) dxText:clip(bool) -- if set to true, the parts of the text that don't fit within the bounding box will be cut off dxText:wordWrap(bool) --if set to true, the text will wrap to a new line whenever it reaches the right side of the bounding box. --Set normal, shadow, or border to your texts dxText:type("normal") --No border/shadow dxText:type("shadow",shadowDist, [r = 0, g = 0, b = 0, a = mainTextAlpha]) -- A shadow of color rgba dxText:type("border", [borderSize = 2, r = 0, g = 0, b = 0, a = mainTextAlpha]) -- A border (aka stroke) of rgba dxText:align(horzA, [vertA = currentVertAlign]) -- "center,left,right","center,top,bottom" dxText:boundingBox(left,top,right,bottom, [relative = true]) dxText:sync([player = getRootElement()]) --SERVERSIDE ONLY! http://dan.bastage.net/mta/textlib.zip Link to comment
BulleTTime Posted April 26, 2009 Share Posted April 26, 2009 Could anyone post an example of how to use this lib? I tried the following but it wont work: dxText:create( txt, screenWidth/2, screenHeight/2 ) dxText:font("pricedown") dxText:type("border", 2, 0, 0, 0, 255) Link to comment
50p Posted April 26, 2009 Share Posted April 26, 2009 TXT = dxText:create( txt, screenWidth/2, screenHeight/2 ) TXT:font("pricedown") TXT:type("border", 2, 0, 0, 0, 255) I've never used this lib but that's how OOP works in Lua. 1 Link to comment
BulleTTime Posted April 26, 2009 Share Posted April 26, 2009 that aint working for me Link to comment
darkdreamingdan Posted April 26, 2009 Author Share Posted April 26, 2009 Positions are relative by default (there's a relative param). Use TXT = dxText:create( txt, 0.5, 0.5 ) Link to comment
[DKR]silverfang Posted April 27, 2009 Share Posted April 27, 2009 that aint working for me You have added it to the meta and everything? Link to comment
Gamesnert Posted April 27, 2009 Share Posted April 27, 2009 It's probably not stated due to the fact that the coordinates are relative by default. (see Talidan's post) Link to comment
manuelhimmler Posted December 9, 2009 Share Posted December 9, 2009 Hello! If i write this in th server-script text = dxText:create("Hello Whizzes!",0.5,0.5) text:sync() there is no text showing, but if i write the 1. row in the clientscript it works, what is wrong? Link to comment
darkdreamingdan Posted December 9, 2009 Author Share Posted December 9, 2009 Hello!If i write this in th server-script text = dxText:create("Hello Whizzes!",0.5,0.5) text:sync() there is no text showing, but if i write the 1. row in the clientscript it works, what is wrong? Do you get any errors in the server console? That should work. Link to comment
nowofresh Posted January 8, 2011 Share Posted January 8, 2011 Pls reUpload or get link to resource when i can get text with a border Link to comment
Castillo Posted January 9, 2011 Share Posted January 9, 2011 I uploaded it to mediafire, if you want it get it from this link: http://www.mediafire.com/?o3ndd7jtf8gqf54 Link to comment
Ransom Posted January 16, 2011 Share Posted January 16, 2011 Edit: Silly error on my part. Example usage: test = dxText:create( "1234567890", x/2, y/2, false) test:scale(3.0) test:text( "0123456789" ) test:font("default") test:color(149,176,209) test:type("border", 1.1, 0, 0, 0 ) If you just want the borders/shadow styles here is adapted code from the script: addEventHandler ( "onClientRender", root, function() local x, y = guiGetScreenSize() x = x / 2 y = y / 2 textSizeage = 8 l,t,r,b = x,y,x,y --Background border outlinesize = att1 or 8 if outlinesize > 0 then for offsetX=-outlinesize,outlinesize,outlinesize do for offsetY=-outlinesize,outlinesize,outlinesize do if not (offsetX == 0 and offsetY == 0) then dxDrawText("ABCDEFG", l + offsetX, t + offsetY, r + offsetX, b + offsetY, tocolor(0,0,0), textSizeage, "default", "center", "center" ) end end end end --Background shadow -- local shadowDist = 6 -- dxDrawText("ABCDEFG", l + shadowDist, t + shadowDist, r + shadowDist, b + shadowDist, tocolor(0,0,0), textSizeage, "default", "center", "center" ) dxDrawText ( "ABCDEFG", l, t, r, b, tocolor(149,176,209), textSizeage, "default", "center", "center" ) Link to comment
#Paper Posted June 1, 2011 Share Posted June 1, 2011 How can i adapt that lib instead dxDrawText to use dxDrawColorText, i tried to repleace just on client render, but whit styles the text is a little bui bugged... Link to comment
karlis Posted June 2, 2011 Share Posted June 2, 2011 How can i adapt that lib instead dxDrawText to use dxDrawColorText, i tried to repleace just on client render, but whit styles the text is a little bui bugged... be more specific, screens won't hurt too. Link to comment
#Paper Posted June 2, 2011 Share Posted June 2, 2011 Instead to use the classic draw func i want to use the dxDrawColorText, how can i adapt it? Link to comment
karlis Posted June 2, 2011 Share Posted June 2, 2011 be more specific, whats current corruption? Link to comment
#Paper Posted June 2, 2011 Share Posted June 2, 2011 If i use one of the types the text is ginned Link to comment
karlis Posted June 2, 2011 Share Posted June 2, 2011 you need to do string.gsub(text,"#%x%x%x%x%x%x","") for the shadow/border as well. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now