if (string.find(text, "$realm", 1, true)) then --realm name
local name, realm = UnitName(unit)
if (string.find(unit, "player", 1, true)) then
realm = "";
elseif not realm then
realm = "";
end
text = string.gsub(text, "$realm", realm);
end
if (string.find(text, "$drealm", 1, true)) then --realm name with a preceeding dash
local name, realm = UnitName(unit)
if (string.find(unit, "player", 1, true)) then
realm = "";
elseif not realm then
realm = "";
else
realm = "-"..realm;
end
text = string.gsub(text, "$drealm", realm);
end