How to change text color based on variable?

So I received help from a member on facepunch (brandonj4) creating an addon to display traitors once you die. I’m still very much a lua noob and I’m just playing around to learn what I can. I’m trying to get it to display the traitors names in different colors if they are dead or alive, but I can’t seem to do it. Can anyone help? Here’s the code I have.


 
if SERVER then
	AddCSLuaFile("pyro_tlist_shared.lua")
	hook.Add("PlayerDeath", "TTT_TSHOW.PlayerDeath", function(ply)
		if !IsValid(ply) or ply:IsTraitor() then return end
		SendTraitorList(ply)
	end)
else
	TTT_TSHOW = TTT_TSHOW or {}
	TTT_TSHOW.Settings = {
		StartX = ScrW() / 1.15,
		StartY = ScrH() / 3,
		color_a = Color( 255, 0, 0 ),
		color_d = Color( 255, 0, 0 ),
		Font = "Trebuchet22",
		FontHeight = draw.GetFontHeight("DermaDefault")
	}
		
	local ply, plyID
	hook.Add("HUDPaint", "TTT_TSHOW.HUDPaint", function()
		if GetConVarNumber("ttt_Tlist") == 0 then return end 
		ply = LocalPlayer()
		if !IsValid(ply) then return end
		plyID = ply:EntIndex()

		if ply:Alive() then 
			if TTT_TSHOW[plyID] then
				TTT_TSHOW[plyID] = nil
			end
		else
			if !TTT_TSHOW[plyID] then
				local trs = {}
				for k,v in ipairs(player.GetAll()) do
					if v:GetTraitor() then table.insert(trs, v) end
				end
				TTT_TSHOW[plyID] = {}
				TTT_TSHOW[plyID].TList = trs
			else
				for k,v in ipairs(TTT_TSHOW[plyID].TList) do
					local startX = TTT_TSHOW.Settings.StartX
					local startY = TTT_TSHOW.Settings.StartY
					local dFont = TTT_TSHOW.Settings.Font
					local tHeight = startY+(TTT_TSHOW.Settings.FontHeight*k*2)
					local color_alive = TTT_TSHOW.Settings.color_a
					local color_dead = TTT_TSHOW.Settings.color_d
					if v:Alive() then color_display = color_alive end
					if not v:Alive() then color_display = color_dead end 
					
					if !IsValid(v) then
						table.remove(TTT_TSHOW[plyID].TList, k) 
						break 
					end	
					draw.RoundedBox(8, startX, startY, 220, 23, Color(96, 96, 96, 60))
					draw.DrawText("Current Traitors:", dFont, startX, startY, Color(0,0,0))
					draw.DrawText(v:Nick().." - "..((v:Alive() and "Alive") or "Dead"), dFont, startX, tHeight, ( color_display ) ) --outputs on color_alive which is red. 
				end
			end
		end
	end)
end


CreateConVar( "ttt_Tlist", 1, true, false )


-snip-

:(Any ideas anyone?

Would you like the color to be over the whole text or would you like it to color the “Dead” or “Alive” after the “-”?

Here are both versions since you took a while to answer.

All colored:
[lua]
draw.DrawText(v:Nick()…" - "…((v:Alive() and “Alive”) or “Dead”), dFont, startX, tHeight, (v:Alive() and colorAlive or colorDead))
[/lua]

Alive status colored:

http://puu.sh/4MJN3.jpg

Source:
[lua]
draw.DrawText(“Current Traitors:”, dFont, startX, startY, Color(0,0,0))
local plyNick = v:Nick()…" - "
draw.DrawText(plyNick, dFont, startX, tHeight, color_white)
draw.DrawText(((v:Alive() and “Alive”) or “Dead”), dFont, startX+(surface.GetTextSize(plyNick)), tHeight, (v:Alive() and colorAlive or colorDead))
[/lua]

damn I coulda sworn I tried exactly that. Anyways, thank you very much again. BrandonJ4 #1

edit: Since i am trying to learn, would it be ok for me to ask you why that worked? I mean I can copy paste but I’d really love to see the reason behind it.