Hi.
So, I created a dx rectangles library, it works perfectly, then I created a dx text library for colorcodes. All works perfectly but the dx text appears behind the rectangle, I put postGUI argument to true and don't work. I tried to find the problem, but nothing...
DX Text:
list [ 1 ] = dx:Create ( getPlayerName ( localPlayer ), ( 312 / 800 ) * x, ( 453 / 600 ) * y, ( 161 / 800 ) * x, ( 20 / 600 ) * y, { 255, 255, 255, 255 }, 1, 'default', 'center', 'left', false, false );
DX Rectangle:
top = dxRectangle:Create ( ( 274 / 800 ) * x, ( 426 / 600 ) * y, ( 278 / 800 ) * x, ( 169 / 600 ) * y, { 0, 0, 0, 210 }, false );
DX Text library:
dx = { }
dx.__index = dx
local visible = { }
function dx:Create ( Text, X, Y, W, H, Color, Scale, Font, AlignX, AlignY, Clip, Wordbreak )
if (
type ( Text ) == "string"
and
type ( X ) == "number"
and
type ( Y ) == "number"
and
type ( W ) == "number"
and
type ( H ) == "number"
and
type ( Scale ) == "number"
)
then
local text =
{
eText = Text;
eX = X;
eY = Y;
eW = W;
eH = H;
eColor = Color;
eScale = Scale;
eFont = Font;
eClip = Clip;
eWordbreak = WordBreak;
ePostGUI = true
}
setmetatable ( text, { __index = dx } )
visible [ text ] = true;
return text
end
end
function dx:Color ( )
return unpack ( self.eColor )
end
function dx:SetColor ( r, g, b, a )
self.eColor = { r, g, b, a }
end
function dx:Text ( text )
self.eText = text
end
addEventHandler ( 'onClientRender', root,
function ( )
for self, _ in pairs ( visible ) do
while true do
draw ( self.eText, self.eX, self.eY, self.eW, self.eH, tocolor ( unpack ( self.eColor ) ), self.eScale, self.eFont, self.eAlignX, self.eAlignY, self.eClip, self.eWordbreak, self.PostGUI )
break
end
end
end
)
function draw ( str, ax, ay, bx, by, color, scale, font, left, top, clip, wordbreak, postGUI )
local pat = "(.-)#(%x%x%x%x%x%x)"
local s, e, cap, col = str:find(pat, 1)
local last = 1
while s do
if cap == "" and col then color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ),
tonumber( "0x"..col:sub( 5, 6 ) ), 255 ) end
if s ~= 1 or cap ~= "" then
local w = dxGetTextWidth(cap, scale, font)
dxDrawText( cap, ax, ay, ax + w, by, color, scale, font )
ax = ax + w
color = tocolor( tonumber( "0x"..col:sub( 1, 2 ) ), tonumber( "0x"..col:sub( 3, 4 ) ), tonumber( "0x"..col:sub( 5, 6 ) ), 255 )
end
last = e + 1
s, e, cap, col = str:find( pat, last )
end
if last <= #str then
cap = str:sub( last )
local w = dxGetTextWidth( cap, scale, font )
dxDrawText( cap, ax, ay, ax + w, by, color, scale, font, left, top, clip, wordbreak, postGUI )
end
end