• 0

    posted a message on Current artifact item links?
    Quote from evil_morfar >>

    The current (semi reliable) way of doing it would be:

     

    local link = GetInventoryItemLink("player", 16)

     

    Where 16 is Mainhand which is (almost) always the artifact. This includes the relics in the itemLink.

     Thanks, very handy :-).
    Posted in: AddOn HELP!
  • 0

    posted a message on Problems with level comparison
    Quote from Myrroddin >>
    Quote from darkrunedk >>

    I have now added the changed the function to a local function. Hopefully this won't break the addon ☺

     It won't, and now it won't break other addon code, or worse, Blizzard code.
    Think of it this way: assume I am either ignorant or sinister, and you did not make that function local to your addon. I could then write a function with the exact same name "partyLevelUp", and have mine do something totally different to your function. I could even call your function and pass incorrect data to your arguments causing your code to error and you'd never know why.
    That would mean that one function, depending on when it was called, would overwrite the other. Yours would overwrite mine, and sometimes mine would overwrite yours. There is absolutely zero way to control that.
    Now your function is local to your file scope because you added the word "local". Even if I did write something with the same name, neither of our code impacts the other, yet, because my version is not local to my file scope, some other addon or Blizzard code can cause conflicts. Your addon is safe, but mine is ... potentially (probably) corrupt.

    To read more about variable scope, read here:

     
    I know it shouldn't, but it all depends on the order the calls/functions are declared in the file. For instance if you try to call a local function located below the call, it will be unable to run it (because the program doesn't know the function yet).
    In this case it should work I guess... Thanks for the help :-)
    Posted in: AddOn HELP!
  • 0

    posted a message on Current artifact item links?

    Hi.

    I was wondering if there's a way to make a itemlink from the currently equipped artifact weapon? - The regular way doesn't work properly, as it doesn't get the artifacts relics...

    local artifactId = C_ArtifactUI.GetEquippedArtifactInfo();
    	local _, link= GetItemInfo(artifactId);
    	print(link);

     Any idea how it can be done?

    Posted in: AddOn HELP!
  • 0

    posted a message on Problems with level comparison

    I have now added the changed the function to a local function. Hopefully this won't break the addon ☺

    Posted in: AddOn HELP!
  • 0

    posted a message on Problems with level comparison
    Quote from ahak >>

    Only reason why it would return false is the fact congrazTable[i] and newLevel being different values and the comparison returns false.

     

    Maybe this would work (untested)?

     

    function partyLevelUp(self, event, unitID)
    	if (UnitInParty(unitID) and UnitPlayerControlled(unitID)) and not (UnitIsUnit(unitID, "player") and IsInRaid()) and DLUSettings.partyEnabled then
    		local partyMemberName = UnitName(unitID);
    		local _, classFileName = UnitClass(unitID);
    		local newLevel = UnitLevel(unitID);
    		
    		local congratzTable
    		local randomCongratz = {"Gratz, %s", "Gz, %s", "Keep it up, %s"};
    
    		if (classFileName == "DEATHKNIGHT" or classFileName == "DEMONHUNTER") then
    			congratzTable = CLASS_TALENT_LEVELS[classFileName];
    		else
    			congratzTable = CLASS_TALENT_LEVELS["DEFAULT"];
    		end
    		
    		for _, level in pairs(congratzTable) do
    			if level == newLevel then
    				print("Level: "..level)
    				local congratzString = string.format(randomCongratz[math.random(#randomCongratz)], partyMemberName);
    
    				if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
    					SendChatMessage(congratzString, "INSTANCE_CHAT");
    				else
    					SendChatMessage(congratzString, "PARTY");
    				end
    
    				break
    			end
    		end
    	end
    end

     

    Thanks :-). Made a few modifications to the code, but it seems to work correctly :-). At least for Demon Hunters.
    Posted in: AddOn HELP!
  • 0

    posted a message on Problems with level comparison

    Hi.

     

    I am currently trying to make an addon to send a congratz message anytime someone in the players party reaches a level where he will be able to get a new talent (way less spam than sending a congratz everytime someone levels up).

     

    Here is my current code:

    -- Variables --
    local maxLevel = GetMaxPlayerLevel();
    local partyFrame = CreateFrame("Frame", "DarkrunePartyFrame");
    local settingsFrame = CreateFrame("Frame", "DarkruneSettingsFrame");
    
    -- Settings
    function loadSettings()
    	DLUSettings = DLUSettings or {
    		partyEnabled = false,
    		pvpEnabled = false,
    		professionsEnabled = false
    	}
    end
    
    -- Important functions --
    function partyLevelUp(self, event, unitID)
    	if (UnitInParty(unitID) and UnitPlayerControlled(unitID) and not UnitIsUnit(unitID, "player") and not IsInRaid() and DLUSettings.partyEnabled) then
    		local partyMemberName = UnitName(unitID);
    		local InInstanceGroup = IsInGroup(LE_PARTY_CATEGORY_INSTANCE);
    		local class, classFileName = UnitClass(unitID);
    		local newLevel = UnitLevel(unitID);
    		
    		local congratzTable = CLASS_TALENT_LEVELS["DEFAULT"];
    		
    		if (classFileName == CLASS_SORT_ORDER[2] or classFileName == CLASS_SORT_ORDER[12]) then
    			congratzTable = CLASS_TALENT_LEVELS[classFileName];
    		end
    		
    		for i = 1, #congratzTable do
    			print(congratzTable[i] == newLevel);
    			print(type(congratzTable[i]) .. ": " .. congratzTable[i]);
    			print(type(newLevel) .. ": " .. newLevel);
    			
    			if (newLevel == congratzTable[i]) then
    				local randomCongratz = {"Gratz, %s", "Gz, %s", "Keep it up, %s"};
    				
    				local congratzString = string.format(randomCongratz[math.random(#randomCongratz)], partyMemberName);
    				
    				if (InInstanceGroup) then
    					SendChatMessage(congratzString, "INSTANCE_CHAT");
    				elseif (IsInGroup()) then
    					SendChatMessage(congratzString, "PARTY");
    				end
    			end
    		end
    	end
    end
    
    -- Adding event --
    settingsFrame:RegisterEvent("PLAYER_LOGIN");
    settingsFrame:SetScript("OnEvent", function()
    loadSettings();
    
    partyFrame:RegisterEvent("UNIT_LEVEL");
    partyFrame:SetScript("OnEvent", partyLevelUp);
    
    settingsFrame:UnregisterEvent("PLAYER_LOGIN");
    end)

    The problem is, that it seems to return false then I run this:

    print(congratzTable[i] == newLevel);

    Anyone who knows why? - got the class constant from searchcode.com.

    Posted in: AddOn HELP!
  • To post a comment, please or register a new account.