Page 109 of 111 FirstFirst ... 95999107108109110111 LastLast
Results 1,081 to 1,090 of 1109

Thread: WeakAuras Tutoring Thread

  1. #1081

    Default

    I'm a bit stuck at the moment. My goal was to create a chi tracker in Weakauras that also had "shadows" representing the future income of chi. This took into account that you would get 2 chi with Power Strikes active. By default this actually worked marvelously, but I was a little annoyed with the bars always appearing, even outside of combat, but I also wanted to know how much chi I had the moment ANYBODY in my group entered combat. What I have should work (based on my new understanding of Lua and WoW API) but it doesn't, in fact NONE of the chi bars are appearing now, no matter what amount of chi that I have. I'm also unsure as how to check if I currently have "power strikes" on my character. The best way that I have found so far is comparing UnitBuff name output to the name of the buff provided in my chiCheck function.

    I'm currently running code to functions in my own addon script to check if anybody is in combat and if there is enough chi. I did this mostly to save space and to make it easier to change the bulk of the code easily in the future.

    Note: chiReq changes for each weakaura, but I leave it as 2 by default.

    Anyways here are bits of my code:
    Code:
    AK = {};
    
    function AK.groupCombatCheck()
    
    	local groupNum = GetNumGroupMembers();
    	local inCombat = UnitAffectingCombat("player");
    
    	if inCombat == 1 then
    		return true;
    	else
    		for i = 1, groupNum, 1 do
    			inCombat = UnitAffectingCombat(("party"..i) or ("raid"..i));
    			if inCombat == 1 then
    				return true;
    			end
    		end
    	end
    	return false;	
    end
    
    function AK.chiCheck(chi, buff, chiReq, sChi)
    
    	local pBuff = "Power Strikes";
    	local pass = false;
    
    	if sChi then
    		if chi == chiReq - 1 then
    			return true;
    		elseif chi == chiReq - 2 then
    			if buff == pBuff then
    				return true;
    			end
    		end
    	else
    		if chi == chiReq then
    			return true;
    		end
    	end
    
    	return false;
    end
    This is my own custom script. The first function (groupCombatCheck) seems right, but I'm a little worried about the whole "party"..i and "raid"..i bit.

    Code:
    function()
    
        local sChi = false;
        local chi = UnitPower("player",12) or 0;
        local pBuff = UnitBuff("player","power strikes");
    
        local chiReq = 2;
    
        if AK.groupCombatCheck() then
            if AK.chiCheck(chi, pBuff, chiReq, sChi) then
                return true;
            end
        end
    
        return false;
    end
    This is my custom trigger in Weakauras for the solid (not "shadow") bars. sChi represents this fact and lets it evaluate the proper code in chiCheck in the previous code segment.

    Code:
    function()
    
        local sChi = false;
        local chi = UnitPower("player",12) or 0;
        local pBuff = UnitBuff("player","power strikes");
    
        local chiReq = 2;
    
        if not AK.groupCombatCheck() then
            return true;
        elseif not AK.chiCheck(chi, pBuff, chiReq, sChi) then
            return true;
        end
    
        return false;
    end
    This is the untrigger for the above code.

    The only difference between those two code segments and my shadow trigger and untrigger is that sChi is set equal to true at the beginning.

    I hope this was formatted well enough and that anybody on Earth can understand what I did haha.

  2. #1082

    Default

    One problem I see is, as you mentioned, the line
    Code:
    inCombat = UnitAffectingCombat(("party"..i) or ("raid"..i));
    ("party"..i) will always be a valid string. It might be party3, which makes sense in a party but not a raid, but it will also be party18 later on in the loop. Lua will just evaluate that string as true because it is not nil. Therefore the ("raid"..i) part of the statement will never be checked.
    Furthermore, even if you would limit i to the correct numbers for party, you would miss people in your raid. party2 is still a valid unitID, even in raids. This means that, if you are NOT in group 1 of your raid, you would scan your group twice and miss the first group entirely for your check.
    You can however fix that behaviour:
    Code:
    function AK.groupCombatCheck()
    
    	local groupNum = GetNumGroupMembers();
    	local inCombat = UnitAffectingCombat("player");
    
    	if inCombat == 1 then
    		return true;
    	else
                    local unit = UnitInRaid("player") and "raid" or UnitInParty("player") and "party";
    		for i = 1, groupNum, 1 do
    			inCombat = UnitAffectingCombat(unit..i);
    			if inCombat == 1 then
    				return true;
    			end
    		end
    	end
    	return false;	
    end
    The first part of the new statement for unit, UnitInRaid("player") and "raid", will check if you are in a raid. If that is the case, it'll evaluate to "raid". If you are not in a raid, it'll evaluate to nil. Then the second part of the or is checked, UnitInParty("player") and "party". UnitInParty will check if you are in a party but will also return true if you are in a raid (since you are technically in a party in a raid I guess). That's why we have to check for the raid first and for the party second.
    So the new variable unit will either contain "raid", "party" or false. If you are not in a party or raid, unit will never get used though, because GetNumGroupMembers is zero and you'll never enter the loop.

    I'm not sure why your WA wouldn't trigger at all though. At least if one of your party members was in combat, it should have triggered. Checking for "party18" doesn't error, it just returns nil.

  3. #1083

    Default

    I realized my mistake with that first bit shortly after posting. I derped hard lol.

    But that second bit is great! I hadn't even thought of checking it like that. I had fixed my mistake with a really silly temp fix but that is a perfect way to fix it.

    I'm still lost as to why it isn't doing anything. I wish it would just throw an error at me lol.

  4. #1084

    Default

    I assume you simply use the check every frame option to run the code in WA?
    Maybe insert some prints to see where the problem is, that's what I usually do if I can't figure out what is going on.

  5. #1085

    Default

    whew... it finally works.... at least solo against dummies.

    Here is my final code and some explanation on what went wrong:
    Code:
    AK = {};
    
    function AK.groupCombatCheck()
    
    	--[[
    	This code checks for the combat status of the player and members of the group. This accounts for both
    	parties and raids.
    	]]
    
    	local groupNum = GetNumGroupMembers();
    	local inCombat = UnitAffectingCombat("player");
    
    	if inCombat then
    		-- print("player in combat"); --debugging help
    		return true;
    	else
    		local unit = UnitInRaid("player") and "raid" or UnitInParty("player") and "party";
    		for i = 1, groupNum, 1 do
    			if unit == nil then
    				-- print("not in group"); --debugging help
    				break;
    			end
    			inCombat = UnitAffectingCombat(unit..i);
    			if inCombat then
    				-- print("group member in combat"); --debugging help
    				return true;
    			end
    		end
    	end
    	
    	-- print(inCombat, unit, groupNum); --debugging help
    	-- print("nobody in combat"); --debugging help
    
    	return false;	
    end
    
    function AK.chiCheck(chiReq, sChi)
    
    	--[[
    	This code checks the amount of chi the player has, if the player has "Power Strikes", and how much
    	chi they will get at any given moment.
    	]]
    
    	local chi = UnitPower("player",12) or 0;
        local pBuff = UnitBuff("player","Power Strikes");
    
    	local buff = "Power Strikes";
    
    	if sChi then
    		if chi == chiReq - 1 then
    			--print("shadow chi requirement met");
    			return true;
    		elseif chi == chiReq - 2 then
    			if pBuff == buff then
    				--print("bonus shadow chi requirement met");
    				return true;
    			end
    		else 
    			return false;
    		end
    	else
    		if chi >= chiReq then
    			--print("chi requirement met");
    			return true;
    		end
    	end
    	--print("no chi");
    	return false;
    end
    The chi code actually worked perfectly already and wasn't showing anything (even with the prints) because I had it coded to only run when groupCombatCheck returned true, which is what I wanted anyways. I'll get to what was keeping it from working in a second, but I really wanted to say how grateful I was for your help Hamsda. I didn't even know that you could evaluate statements like you did with that unit variable. Anyways, the main problem ended up being really stupid. According to wowprogramming.com and all other sources UnitAffectCombat returns either a 1 if in combat or nil if not. This isn't true. It returns true or false respectively. I learned this when I used my print(inCombat,unit,groupNum) statement. It returned true/false and after fixing that everything worked beautifully (except a minor typo that I had in each weakaura denoting the "chiReq".

    Note: I also moved chi and pBuff to the main batch of code to verify that it wasn't errors in my weakauras functions.

    Code:
    function()
    
        local sChi = false;
        local chiReq = 2;
    
        if AK.groupCombatCheck() then
            if AK.chiCheck(chiReq, sChi) then
                return true;
            end
        end
    
        return false;
    end
    This is the constructor for the non-shadow bars and works beautifully. For the shadow variant the ONLY change you have to make is to sChi (false denotes non-shadow, true denotes shadow).

    Code:
    function()
    
        local sChi = false;
        local chiReq = 2;
    
        if not AK.groupCombatCheck() then
            return true;
        elseif not AK.chiCheck(chiReq, sChi) then
            return true;
        end
    
        return false;
    end
    This is the code for the non-shadow bars deconstruct. For the shadow variant the ONLY change you have to make is to sChi (false denotes non-shadow, true denotes shadow).

    I'm super grateful for your help Hamsda and very excited to finally get it working correctly.

  6. #1086

    Default

    No problem man, glad to help you!
    As a sidenote: unit will never be nil, only "raid", "party", or false

    Yeah sadly some of the documentation for the WoW API is not really up2date. Noticed that myself when I used GetRaidRosterInfo recently... the last arguments are different/in a different order >.<
    That's why I basically test every "new" command I haven't used before with a /dump first.

  7. #1087

    Default

    New problem and this time I'm well out of my depth.

    This is a very ridiculous request and probably doesn't deserve the effort, but... I want to show the mana return of Totemic Recall in percent of total mana in weakauras. I've got everything except how to get the mana cost of the totems. I googled around and found that Blizzard, in all of its wisdom, removed powerCost from GetSpellInfo() and now we have to resort to something called "tooltip scanning". I'm wholly unfamiliar with this and after trying to copy and paste some code around I'm not getting anywhere. I get the spell IDs by running a loop for GetTotemInfo and running that name through GetSpellInfo. I know that this works because I tested it with the print functions that are commented out and I get the correct names and spellIDs; in fact it is kinda cool looking, but not useful. I then run it through the "code" and get nil. I'll paste the code that I'm borrowing and my attempted code (with my "test" code commented out).

    Code:
    function AK.GetPowerCost(spellId)
    	local CostTip = CreateFrame('GameTooltip')
    	local CostText = CostTip:CreateFontString()
    	CostTip:AddFontStrings(CostTip:CreateFontString(), CostTip:CreateFontString())
    	CostTip:AddFontStrings(CostText, CostTip:CreateFontString())
    	if spellId == nil then
    		return nil
    	else
    		CostTip:SetOwner(WorldFrame, 'ANCHOR_NONE')
    		CostTip:SetSpellByID(spellId)
    		print(spellId .. ' = ' .. CostText:GetText())
    		return CostText:GetText()
    	end
    end
    and my code from within the display tab of this aura in Weakauras:

    Code:
    function()
        local manaTotal = UnitPowerMax("player","mana");
        local manaCostTotal = 0;
        local returnedMana = 0;
        --local names = {};
        --local IDs = {};
        
        for i=1,4,1 do
            local totemName = select(2,GetTotemInfo(i));
            local totemID = select(7,GetSpellInfo(totemName));
            if AK.GetPowerCost(totemID) == nil then
                return "";
            else
                
                local manaCost = AK.GetPowerCost(totemID);
                manaCostTotal = manaCostTotal + manaCost;
            end
            
            --[names[i] = totemName;
            --IDs[i] = totemID
            
        end
        
        --for j=1,4 do
        --print(names[j]," ",IDs[j]);
        --end
        
        manaCostTotal = manaCostTotal * .25;
        returnedMana = manaCostTotal/manaTotal;
        
        return ("%.0f"):format(returnedMana).."%";
        
        --return "";
    end
    I do not get tooltip scanning at all or how to use it. In reality I'm actually clueless on anything to do with "frames".

    Edit: Messed around a bit and was barely able to reproduce "26 mana" once from searing flame totem but none of the others would show it and then it just gave up haha.
    Last edited by ArcheKnight; 12-20-2015 at 01:02 AM.

  8. #1088

    Default

    Hello everyone, I came here in looking for help since you are very skilled with lua and WA.

    I would like to make a Lua counter for video purposes, something like:

    I get Aura X, Counter noticies i gain the Aura X and prints a number (1), i regain again the aura, counter prints (2) and so on.

    Is this possible? Because i looked everywhere but i cant find anything like this.

    My basic idea was something like a function like this:

    function incCount (n)
    n=n+1
    end

    And a custom Text that prints out the result of that function, about how many times i get the aura. For example i get the aura 10 times in a fight the counter prints a text which says "10".

    Thank you veeeery much for your help!

  9. #1089

    Default

    I made a counter for you. I'll give you the aura that should be easily setup and the aura display code and custom trigger code. All that you need to change is the display text for your spell and use the spellID of the spell that you want in the custom trigger. I've marked those two spots with comments.

    WeakAuras string:
    Code:
    duuYhaGivvxcIk9jimkvroLIQEfev1Se4wqKDredde5yGWYeL8mqutJiPRbsSncQVPk4CQcTofL07iu3tv6GeYcjs0djsnrc0fbP2OIk(OIkDscyLq1mjkDtiQyNkWpvuIHkk1sHO8ujMQQYvvuSvIe8vqsVvqURGAVa)vunyQdtYJb1KHYLLAZIIptumAcYPH0QjsOxRkQzlYTvKDtQFRKHRqlxspxPMUkxxOTRG(oevz8kk15jQ2pAaeGpqzcuWafmWhOGHUhtk5F9Spqb5cdkWX9TM(6zFGsMOg(qx6NMN40000PfSkrdVI6J(LgQT6zrXQAxudBSqiWq3JjL8nIWH(ffRkAPxr911)WHqaVI6dry6vLgsIjonnnnXPPPPjonnnDTVyvt)Jm0XdfRNv6FjsGxr9jMgjKMz30YxXk9EStjAH6At8wJbkr9vrLrMUc(af44(wtGsMOg(qx6NKirY8eNMMMgjKslyvIgEf1h9lnuB1ZIIv1UOg2yHqGHUhtk5ich6xuSQOLEf1xx)dhcb8kQpeHPxvAijM40000PfSkrVh7usRMA6x6)k64HI1)IjonnnDAbRs0A1ut)sp3(MrJEdut9t)JjL8U(pVyItttttCAAA60cwLOZdYd6HT(cYdYdGv7RRb5b5b5by9(cYdYd2JDkjGGb7XoLgOM6GC6xAjsKiM40000eNMMMgndDpS1h97l9FjBOLv2CrZGmr5IYoBzfaAb)PvAmASEF0VV0A1utR0y07XoLgOMA63x69yNsA1utFc1AIttttttttpwr13t9WwFb0WQ911aASEFb07XoLeqWa69yNsdut98IjonnnnnnnDTVyvtF1ylM40000TgJ40000eNMMMU2xSQPZOs7wmXPPPPjonnnnXPPPPrcjO2QNffRQDrnSXcHadDpMuYreo0VOyvrl9kQVU(hoec4vuFict)sdVI6tmXBng4aLAld6s)jFSbLRN9bksX4(qZihuKg6bFqJmq5QOYitxbFGYjFSbf44(wtGcCCFRP8t(ydk9WwFGcwSQo0LguEauGJ7BnbkzIA4dDPFsIejZtCAAA60cwLOHxr9r)sd1w9SOyvTlQHnwieyO7XKs(gr4q)IIvfT0RO(66F4qiGxr9Him9QsdjXeNMMMM40000PfSkrVfqq6xAHHiRhHIyAKqAMDtlFfR0J1otxRng9EStjAH6AtCAAAAIttttNwWQeDCGAQPFPNBFZOrVbQP(P)XKsEx)NxmXPPPPjonnnDAbRs05b5b9WwFb5b5bWQ911G8G8G8aSEFb5b5b7XoLeqWG9yNsdutDqo9lTejsetCAAAAIttttJMHUh26J(9L(VKn0YkBUOzqMOCrzNTScaTG)0kngnwVp63x64a1utR0y07XoLeqq63x6TacsFc1AIttttttttdVI6J(LgEf1hnYNgcXeNMMMMMMMgQT6zrXQAxudBSqiWq3JjL8nIWH(ffRkAPxr911)WHqaVI6dry6xA4vuFIjonnnnnnnDTVyvtF1ylM40000TgJ40000eNMMMU2xSQPZOs7wmXBngOalud)mO0dB9bk9WwFBqr6zb5iLI(YLDwMBo0sbOh8LpZG5iGSFqJmOfeuGJ7BnLlekwdkh6uJboqb5HIDcbMZdpcfiew4SEilidzHf(riYcKbjPkmOGIbkIIvfT0RO(6kOKzPpqrkJO0zxx36Kp2Gc8kQpWaidkc1OYi0bMJWpafOa5hLQWq6XSG4bOazHbzqsQpck640xfvgz66gmacqjTuyGpqbdntgu4y6Kd(aLPy6qbFGdCGsDLAWhOmfthk4dCGduQk4g8bktX0Hc(ah4aLtLA9b(aLPy6qbFGdCGsgf8HU0GpqzkMouWh4ah4ahOSbLSKaHeijbIhaLHGbqi1SGaCaaa

    Display code:
    Code:
    function()
        local count = WeakAurasSaved['displays']["Aura Counter"]['count'] or 0;
        
        
        return "Riptide: "..count; --Use your spell here
    end
    Trigger code:
    Code:
    function(...)
        local count = WeakAurasSaved['displays']["Aura Counter"]['count'] or 0;
        
        local sID = 61295; --Use your preferred spell here
        
        local uName = GetUnitName("player");
        
        local _,_,event,_,_,caster,_,_,_,dest,_,_,spellID,spellName,_ = ...;
        
        if event == "SPELL_AURA_APPLIED" and dest == uName and spellID == sID then
            count = count + 1;
            WeakAurasSaved['displays']["Aura Counter"]['count'] = count;
            return true;
        end
        
        return false;
    end
    I used the combat log to check for when the aura is applied to you, incremented a variable called "count", and then saved that variable globally so that it isn't reset on relog. I wasn't sure what you wanted this to do exactly. It wouldn't be hard to edit the code to check for a specific buff, a buff applied to you BY YOU (only), when the buff is refreshed (if aura is still up and applied again this code won't count it), or for it to reset on /reloadui (or any time you log out). It can be checked to reset after battle ends (I actually already have code to check for combat status) too.

    What I'm trying to say is, if you have more details, this code can be fit to work better for you. If you have any questions or if you run into a problem, please come back and hopefully I or someone with a lot more experience can help or make this code better/more efficient.

    EDIT: I re-read your post and noticed that you were wanting it to show after combat. I desperately tried to get it to work, but I can't, for the life of me, figure out why "PLAYER_REGEN_DISABLED" and it's counterpart aren't ever firing for me. I was trying this with a dummy but it would never fire.
    Last edited by ArcheKnight; 12-20-2015 at 04:08 PM.

  10. #1090

    Default

    Quote Originally Posted by ArcheKnight View Post
    I made a counter for you. I'll give you the aura that should be easily setup and the aura display code and custom trigger code. All that you need to change is the display text for your spell and use the spellID of the spell that you want in the custom trigger. I've marked those two spots with comments.

    I used the combat log to check for when the aura is applied to you, incremented a variable called "count", and then saved that variable globally so that it isn't reset on relog. I wasn't sure what you wanted this to do exactly. It wouldn't be hard to edit the code to check for a specific buff, a buff applied to you BY YOU (only), when the buff is refreshed (if aura is still up and applied again this code won't count it), or for it to reset on /reloadui (or any time you log out). It can be checked to reset after battle ends (I actually already have code to check for combat status) too.

    What I'm trying to say is, if you have more details, this code can be fit to work better for you. If you have any questions or if you run into a problem, please come back and hopefully I or someone with a lot more experience can help or make this code better/more efficient.

    EDIT: I re-read your post and noticed that you were wanting it to show after combat. I desperately tried to get it to work, but I can't, for the life of me, figure out why "PLAYER_REGEN_DISABLED" and it's counterpart aren't ever firing for me. I was trying this with a dummy but it would never fire.
    THANKS REALLY MUCH. I tryed so hard to do this but my little lua knowlage didnt help me at all. It works perfectly as i wanted, thank you really. You're the best!! <3

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •