I am trying to create a debug print statement that prints a players 3v3 arena cr. Specifically I seek to target a new player and have the addon read the target’s 3v3 rating and print it in as a debug statement.
I am making an addon to do this and want it to be in the main.lua for now.
I am having trouble finding the correct code to execute this. Can anyone help or point to a list of reliable addon API lists (up to date)?
Hi. Thanks for this. I should have specified that the addon is to read the targets 3v3 rating and print it as an output statement. I have updated the OP.
I have been able to use GetPersonalRatedInfo() and it has worked!
local notifyUnit
local f = CreateFrame("Frame")
f:RegisterEvent("INSPECT_HONOR_UPDATE")
f:SetScript("OnEvent", function(self)
if notifyUnit then
local rating, seasonPlayed, seasonWon, weeklyPlayed, weeklyWon = GetInspectArenaData(2) -- 2 = 3v3
if rating > 0 then
local pvpType = CONQUEST_SIZE_STRINGS[3]
print(format("Current Rating for %s in %s: %s", notifyUnit, pvpType, rating))
else
print(format("%s has no rating!", notifyUnit))
end
notifyUnit = nil
end
end)
SLASH_RATING1 = "/rat"
SlashCmdList.RATING = function(msg)
if UnitExists("target") and UnitIsPlayer("target") then
NotifyInspect("target")
notifyUnit = UnitName("target")
else
print("No target selected!")
end
end
using /rat should show the 3v3 rating for your currently selected target unit if they have a rating greater than 0.
Legend. Thanks for the help! I am learning so much from this whole experience. Lua is a fun language. It is nice not needing to add a ; every line lol.
I have been able to execute these lines of code while using a slash command however I want to be able to execute them during a ButtonPress event. Ie the addon should only look up the rating of the player after a button press such as “search 3v3”.
Are you able to give me any tips or modify your existing code to allow for this funictionality.
My addon is complete in theory but requrires slash commands to use. I want it to be more graphical hence why im trying to call this while using buttons.
Mind giving me a hand again lol? At this point ur my tutor. I have buttons that are not attaching to a frame backdrop. I want to move the whole frame but the buttons are disconnected. Whenever I close the frame with the Cross all UI elements (from the addon) close. Kinda confused.
If you could add a button to your original code I can study that and transfer the principles into my own code. Thanks.
f.Close is a button attached to the frame. The SetPoint(...) line anchors the button to the frame so when the frame moves, the close button moves with it.
When you show/hide a frame, any elements it is the parent of (it’s children) will also show/hide. Setting the parent is done in the code above as either, the third parameter of CreateFrame (eg. the f.Close button) or for regions (Textures/FontStrings) by using the parent to create the region (eg. f.Text).
In other words, it is possible to have a frame/region that is attached (anchored) to one frame but is parented to another frame.