draw.SimpleText question about colors.

I’ve got a pretty weird question. Am I able to color each letter of the SimpleText?

I highly doubt it.

If you do it one letter at a time, as far as I know.

[lua]
local word = {}
word[1] = {“h”, Color(255, 0, 0)}
word[2] = {“e”, Color(0, 255, 0)}
word[3] = {“l”, Color(0, 0, 255)}
word[4] = {“l”, Color(0, 255, 0)}
word[5] = {“o”, Color(255, 0, 0)}

hook.Add(“HUDPaint”, “draw”, function()
for k, v in pairs(word) do
draw.SimpleText(v[1], “ScoreboardText”, 5 + (k * 20), 500, v[2], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
end)[/lua]

A better method would to create a function that accepts a input string and explodes it into a table, but you get the idea

Thanks c-unit.

The idea of a function that is inefficient as fuck?

I’ve got a problem. It doesn’t space for each words.

on the x axis multiply the value you want by the key

how would you do it

Thanks, let me try and see what it does.

snip, broke my automerge

Great, worked now.

[editline]30th May 2011[/editline]

Couldn’t I do something like this:
[lua]
local word = {}
word[1] = {"h ", Color(255, 0, 0)}
word[2] = {“e”, Color(0, 255, 0)}

hook.Add(“HUDPaint”, “draw”, function()
for k, v in pairs(word) do
draw.SimpleText(v[1], “ScoreboardText”, 5, 500, v[2], TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) endend)
[/lua]

[editline]30th May 2011[/editline]

ignore the endend)

You can just do v[1]…" " so you don’t have too i think.

I supose it could work, but it’s very un professional

I know myself, but doing the * number makes the hud too big as the hud has pretty many letters.