It's pure Lua code to get a UI color escape from a percentage value. Works fine on the
live Lua demo.
I don't know anything about Pitbull4, never used it.
Edit: From the documentation on
LuaTexts, this is the conversion from your DogTag3 script.
Code:
local cur,max=HP(unit),MaxHP(unit);
local r,g,b=HPColor(cur,max);
Outline();
return (cur>0 and cur<max) and "|cff%02x%02x%02x%.0f%%|r" or "",r,g,b,100*cur/max;
Edit: Fixed typo; corrected
MaxHP()