Hi,
I would like to know if there is a built-in function that allows me to change the colour of the output text similar to how chat.AddText does it.
https://files.facepunch.com/forum/upload/111841/10d8c9c7-604b-4405-b03f-87af34483689/image.png
I would like to make the text "OK" appear another colour to the "[ ]" without using multiple draw.SimpleText statements as this would be a huge ball ache.
If anyone knows how I would achieve this that would be great.
Thanks
function draw.YeehawText(font, x, y, xalign, yalign, ...)
font = font or "DermaDefault"
x = x or 0
y = y or 0
local nx, col = x, color_white
for i, arg in ipairs{...} do
if (IsColor(arg)) then
col = arg
elseif (isstring(arg)) then
local w, h = draw.SimpleText(arg, font, nx, y, col, xalign, yalign)
nx = nx + w
end
end
end
hook.Add("HUDPaint", "", function()
draw.YeehawText("DermaLarge", 50, 50, nil, nil, Color(255, 0, 0), "Red, ", Color(0, 255, 0), "green, ", Color(0, 0, 255), "blue.")
end)
don't judge my variable names
As far as I know, this isn't possible.
You could create your own function like chat.AddText that takes a variable amount of arguments then loops through the arguments to perform multiple draw.SimpleText draws:
function draw.SimpleTextColored( ... )
local args = { ... };
for _,arg in pairs( args ) do
--Do some stuff here
end;
end;
This works, thank you very much!
Sorry, you need to Log In to post a reply to this thread.