Title says it all, I want to add TRP3's last names (when applicable) to my target frame's name, however, I'm not entierly sure how to do this.
I started by simply trying to replace the default name with the one supplied by the TRP chatframe functions, but it just shows blank, no errors, just no name either.
lua Code:
oUF.Tags.Methods["diablo:name"] = function(unit)
local color = oUF.Tags.Methods["diablo:color"](unit)
if IsAddOnLoaded("Totalrp3") then
local UnitID = TRP3_API.utils.str.getUnitID(unit)
local name = TRP3_API.chat.getFullnameForUnitUsingChatMethod(UnitID)
else
local name = UnitName(unit)
end
return "|cff"..color..(name or "").."|r"
end
I've based the UnitID local off what I've gathered going through trp's code. for example: the chatframe.lua never generates the UnitID, but uses it, thus it must come from a global function.
Looking in register_main.lua I fine the mouseover function for tooltips:
lua Code:
local function onMouseOver(...)
local unitID, unitRealm = getUnitID("mouseover");
if unitID and isUnitIDKnown(unitID) then
local _, race = UnitRace("mouseover");
local _, class, _ = UnitClass("mouseover");
local englishFaction = UnitFactionGroup("mouseover");
saveCharacterInformation(unitID, race, class, UnitSex("mouseover"), englishFaction, time(), buildZoneText(), GetGuildInfo("mouseover"));
end
end
which tells me UnitID comes from 'getUnitID', which is a local import of 'utils.str.getUnidID', the utils are globally declared as "TRP3_API.utils" in the utils.lua file, which also has this function in it:
lua Code:
function Utils.str.getUnitID(unit)
local playerName, realm = UnitFullName(unit);
if not playerName or playerName:len() == 0 or playerName == UNKNOWNOBJECT then
return nil;
end
if not realm then
realm = Globals.player_realm_id;
end
return playerName .. "-" .. realm;
end
From this, I can gather feeding a unit into "TRP3_API.utils.str.getUnitID()" should get me the UnitID I require for the next function "TRP3_API.chat.getFullnameForUnitUsingChatMethod(UnitID)"
However, upon doing this, I get no character name.
I also get no errors, so I know i'm calling the right functions with the right information, I'm just not getting back anything.
I found another function aswell
lua Code:
function TRP3_API.register.getUnitRPName(targetType)
local unitName = UnitName(targetType);
local unitID = getUnitID(targetType);
return getUnitRPNameWithID(unitID, unitName);
end
TRP3_API.r.name = TRP3_API.register.getUnitRPName;
However setting name = TRP3_API.r.name or TRP3_API.register.getUnitRPName also, gives me no name to display.
I'm utterly confused by all of this, tbh :S