1. #1

    help with prepot addon

    so i found this code on the forums from treeston, and have been trying to get it to function in mop to check for potion use. i replaced the old buff names and spell names but it wont print after combat if potions were used or not, i have been testing in SSC. anyone know how to get the addon functioning again? thank you for any help.

    Code:
    local buffNames = {
    	["Potion of the Mountains"]=true,
    	["Potion of Mogu Power"]=true,
    	["Potion of the Jade Serpent"]=true,
    	["Virmen's Bite"]=true,
    }
    local spellNames = { -- unsure which one shows in the combat log, so I'm adding both buff name and spell name for the time being
    	["Potion of the Mountains"]=true,
    	["Potion of Mogu Power"]=true,
    	["Master Mana Potion"]=true,
    	["Potion of Focus"]=true,
    	["Virmen's Bite"]=true,
    	["Potion of the Jade Serpent"]=true,
    	["Master Healing Potion"]=true,
    }
    local select, table, pairs, tinsert, print =
    	  select, table, pairs, tinsert, print
    local GetUnitName, GetInstanceInfo, UnitBuff, GetNumGroupMembers, UnitInRaid =
    	  GetUnitName, GetInstanceInfo, UnitBuff, GetNumGroupMembers, UnitInRaid
    
    local a = CreateFrame("Frame")
    a:SetScript("OnEvent", function(self, event, ...)
        if event == "COMBAT_LOG_EVENT_UNFILTERED" then
    		local subEvent, srcName, spellName = (select(2,...)), (select(5,...)), (select(13,...))
    		local raidIndex = UnitInRaid(srcName)
            if subEvent == "SPELL_CAST_SUCCESS" and spellNames[spellName] and raidIndex then
                self.pots = self.pots or {}
                self.pots[GetUnitName(("raid%d"):format(raidIndex),true)] = spellName
            end
        elseif event == "PLAYER_REGEN_DISABLED" then
            local n = GetNumGroupMembers()
            local nP=(select(5, GetInstanceInfo()))
            if nP and (nP >= 10) and (n>0) then
                self.pots = self.pots and table.wipe(self.pots) or {}
                self.prepots = self.prepots and table.wipe(self.prepots) or {}
                for id=1, n do
    				local uID = ("raid%d"):format(id)
                    for buffName in pairs(buffNames) do
    					if UnitBuff(uID, buffName) then
    						self.prepots[GetUnitName(uID,true)] = true
    						break
    					end
    				end
                end
            end
        elseif event == "PLAYER_REGEN_ENABLED" then
            local n  = GetNumGroupMembers()
            local nP=(select(5, GetInstanceInfo()))
            if nP and (nP >= 10) and (n>0) then
                local noprepot, noinpot = {}, {}
                for id=1, n do
                    local name = GetUnitName(("raid%d"):format(id),true)
                    if not self.prepots[name] then tinsert(noprepot, name) end
                    if not self.pots[name] then tinsert(noinpot, name) end
                end
                if (#noprepot>0) then
                    print("Players that did not have a potion buff when combat started: "..table.concat(noprepot, ", "))
                else
                    print("Everyone had a potion buff when combat started!")
                end
                if (#noinpot>0) then
                    print("Players that did not use a potion in combat: "..table.concat(noinpot, ", "))
                else
                    print("Everyone used a potion during combat!")
                end
            end
        end
    end)
    a:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    a:RegisterEvent("PLAYER_REGEN_ENABLED")
    a:RegisterEvent("PLAYER_REGEN_DISABLED")

  2. #2
    Any Lua errors popping up?
    UI & AddOns expert | Interface & Macros moderator - My work

  3. #3
    not getting any lua errors

    edit: just made a separate clean wow install with just this addon still no lua errors but no print out after combat
    Last edited by Darksole; 2013-08-18 at 08:14 PM.

  4. #4
    Odd, I can't think of anything right away.

    Above the following block:
    Code:
    self.pots = self.pots or {}
    self.pots[GetUnitName(("raid%d"):format(raidIndex),true)] = spellName
    Add this:
    Code:
    print(("%s: %s used by raid%d!"):format(subEvent,spellName,raidIndex))
    PS: Just to make sure, you are in a raid group while testing? This might seem obvious, but I figured I might as well ask.
    UI & AddOns expert | Interface & Macros moderator - My work

  5. #5
    edit: so i tried to add a slash command to activate or deactivate reporting so i could tell it to only report on boss fights but am haveing trouble getting it to function. when i type /ppc enable or disable is i get type /help for help. any ideas?

    Code:
    local buffNames = {
    	["Potion of the Mountains"]=true,
    	["Potion of Mogu Power"]=true,
    	["Potion of the Jade Serpent"]=true,
    	["Virmen's Bite"]=true,
    }
    local spellNames = { -- unsure which one shows in the combat log, so I'm adding both buff name and spell name for the time being
    	["Potion of the Mountains"]=true,
    	["Potion of Mogu Power"]=true,
    	["Master Mana Potion"]=true,
    	["Potion of Focus"]=true,
    	["Virmen's Bite"]=true,
    	["Potion of the Jade Serpent"]=true,
    	["Master Healing Potion"]=true,
    }
    local select, table, pairs, tinsert, print =
    	  select, table, pairs, tinsert, print
    local GetUnitName, GetInstanceInfo, UnitBuff, GetNumGroupMembers, UnitInRaid =
    	  GetUnitName, GetInstanceInfo, UnitBuff, GetNumGroupMembers, UnitInRaid
    
    local a = CreateFrame("Frame")
    
    local enabled = 'true';
    SLASH_PPC1 = '/PPC';
    local function SlashCmd(cmd,self)
    	if (cmd == 'enable') then
    		enabled = 'true';
    		DEFAULT_CHAT_FRAME:AddMessage("Prepotcheck Enabled",1,0,0);
        elseif (cmd == 'disable') then
            enabled = 'false';
    		DEFAULT_CHAT_FRAME:AddMessage("Prepotcheck Disabled",0,1,0);
        else
            DEFAULT_CHAT_FRAME:AddMessage("Unknown command. Enter either '/ppc enable' to activate Prepotcheck, or '/ppc disable' to deactivate it.",1,0,0);
        end
    end
    SlashCmdList["PPC"] = SlashCmd;
    
    a:SetScript("OnEvent", function(self, event, ...)
    
    if (enabled == 'true') then
        if event == "COMBAT_LOG_EVENT_UNFILTERED" then
    		local subEvent, srcName, spellName = (select(2,...)), (select(5,...)), (select(13,...))
    		local raidIndex = UnitInRaid(srcName)
            if subEvent == "SPELL_CAST_SUCCESS" and spellNames[spellName] and raidIndex then
                self.pots = self.pots or {}
                self.pots[GetUnitName(("raid%d"):format(raidIndex),true)] = spellName
            end
        elseif event == "PLAYER_REGEN_DISABLED" then
            local n = GetNumGroupMembers()
            local nP=(select(5, GetInstanceInfo()))
            if nP and (nP >= 10) and (n>0) then
                self.pots = self.pots and table.wipe(self.pots) or {}
                self.prepots = self.prepots and table.wipe(self.prepots) or {}
                for id=1, n do
    				local uID = ("raid%d"):format(id)
                    for buffName in pairs(buffNames) do
    					if UnitBuff(uID, buffName) then
    						self.prepots[GetUnitName(uID,true)] = true
    						break
    					end
    				end
                end
            end
        elseif event == "PLAYER_REGEN_ENABLED" then
            local n  = GetNumGroupMembers()
            local nP=(select(5, GetInstanceInfo()))
            if nP and (nP >= 10) and (n>0) then
                local noprepot, noinpot = {}, {}
                for id=1, n do
                    local name = GetUnitName(("raid%d"):format(id),true)
                    if not self.prepots[name] then tinsert(noprepot, name) end
                    if not self.pots[name] then tinsert(noinpot, name) end
                end
                if (#noprepot>0) then
                    print("Players that did not have a potion buff when combat started: "..table.concat(noprepot, ", "))
                else
                    print("Everyone had a potion buff when combat started!")
                end
                if (#noinpot>0) then
                    print("Players that did not use a potion in combat: "..table.concat(noinpot, ", "))
                else
                    print("Everyone used a potion during combat!")
                end
            end
        end
    end)
    a:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    a:RegisterEvent("PLAYER_REGEN_ENABLED")
    a:RegisterEvent("PLAYER_REGEN_DISABLED")
    DEFAULT_CHAT_FRAME:AddMessage("Prepotcheck loaded - watching for bads.",1,0,0)
    Last edited by Darksole; 2013-08-19 at 01:02 AM.

  6. #6
    Huh, are you sure the addon is even being loaded? How are the folder, the .toc and the .lua named, and what's the content of the .toc?
    UI & AddOns expert | Interface & Macros moderator - My work

  7. #7
    yes addon is loading i have it to the point were the addon with print after combat and can toggle on and off with slash commands but i now have the issue of the print commands firing once for every raid member. any ideads what is causeing this. for example me and a guild member tested it and it prints
    Players without a potion buff when combat started: Darksole
    Players who didn't use a potion in combat: Darksole
    Players without a potion buff when combat started: Darksole, Koarinite
    Players who didn't use a potion in combat: Darksole, Koarinite

    if we add a third member it prints
    Players without a potion buff when combat started: Darksole
    Players who didn't use a potion in combat: Darksole
    Players without a potion buff when combat started: Darksole, Koarinite
    Players who didn't use a potion in combat: Darksole, Koarinite
    Players without a potion buff when combat started: Darksole, Koarinite, Deetra
    Players who didn't use a potion in combat: Darksole, Koarinite, Deetra

    here is my code
    Code:
    local enabled = true
    
    local buffNames = {
    	["Potion of Mogu Power"] = true,
    	["Potion of the Jade Serpent"] = true,
    	["Potion of the Mountains"] = true,
    	["Virmen's Bite"] = true,
    }
    
    local spellNames = {
    	["Master Healing Potion"] = true,
    	["Master Mana Potion"] = true,
    	["Potion of Focus"] = true,
    	["Potion of Mogu Power"] = true,
    	["Potion of the Jade Serpent"] = true,
    	["Potion of the Mountains"] = true,
    	["Virmen's Bite"] = true,
    }
    
    local prepots, pots = {}, {}
    
    local a = CreateFrame("Frame")
    a:RegisterEvent("ZONE_CHANGED_NEW_AREA")
    
    a:SetScript("OnEvent", function(self, event, ...)
    	if event == "COMBAT_LOG_EVENT_UNFILTERED" then
    		local _, subEvent, _, _, srcName, _, _, _, _, _, _, _, spellName = ...
    		if subEvent == "SPELL_CAST_SUCCESS" and spellNames[spellName] then
    			local i = UnitInRaid(srcName)
    			if i then
    				print("|cffff7f7fPPC:|r", srcName, "used", spellName)
    				self.pots[GetUnitName("raid"..i, true)] = spellName
    			end
    		end
    
    	elseif event == "PLAYER_REGEN_DISABLED" then
    		print("|cffff7f7fPPC:|r Combat started")
    
    		wipe(prepots)
    		wipe(pots)
    
    		for i = 1, GetNumGroupMembers() do
    			local unit = "raid"..i
    			for buff in pairs(buffNames) do
    				if UnitBuff(unit, buffName) then
    					prepots[GetUnitName(unit, true)] = true
    					break
    				end
    			end
    		end
    
    		self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    
    	elseif event == "PLAYER_REGEN_ENABLED" then
    		print("|cffff7f7fPPC:|r Combat ended")
    
    		local noprepots, nopots = {}, {}
    		for i = 1, GetNumGroupMembers() do
    			local name = GetUnitName("raid"..i, true)
    			if not prepots[name] then
    				tinsert(noprepots, name)
    				
    			end
    			if not pots[name] then
    				tinsert(nopots, name)
    			end
    			if #noprepots > 0 then
    				--table.sort(noprepots)
    				print("|cffffd200PrePotCheck:|r Players without a potion buff when combat started:", table.concat(noprepots, ", "))
    			else
    				print("|cffffd200PrePotCheck:|r Everyone had a potion buff when combat started.")
    			end
    			if #nopots > 0 then
    				--table.sort(nopots)
    				print("|cffffd200PrePotCheck:|r Players who didn't use a potion in combat:", table.concat(nopots, ", "))
    			else
    				print("|cffffd200PrePotCheck:|r Everyone used a potion in combat.")
    			end
    		end			
    
    		self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    
    	elseif event == "ZONE_CHANGED_NEW_AREA" then
    		local _, instanceType = GetInstanceInfo()
    		if enabled and instanceType == "raid" and GetNumGroupMembers() > 1 then
    			print("|cffff7f7fPPC:|r Enabled")
    			self:RegisterEvent("PLAYER_REGEN_DISABLED")
    			self:RegisterEvent("PLAYER_REGEN_ENABLED")
    		else
    			print("|cffff7f7fPPC:|r Disabled")
    			self:UnregisterEvent("PLAYER_REGEN_DISABLED")
    			self:UnregisterEvent("PLAYER_REGEN_ENABLED")
    			self:UnregisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
    		end
    	end
    end)
    
    SLASH_PREPOTCHECK1 = "/ppc"
    SlashCmdList["PREPOTCHECK"] = function(cmd)
    	enabled = not enabled
    	print("|cffffd200PrePotCheck|r is now", enabled and "enabled" or "disabled")
    	a:GetScript("OnEvent")(a, "ZONE_CHANGED_NEW_AREA")
    end

  8. #8
    just take those "if #___ > 0" chunks out of the for loop

  9. #9
    if i take the if statements out the it prints everything when it should only print peoples names if they did not pot and print that everyone poted if everyone used a potion

  10. #10
    sorry, I should've been clearer. I meant pull them outside of the loop, not delete them.
    right now you have
    Code:
    for i = 1, GetNumGroupMembers() do
    	...
    	if #noprepots > 0 then
    		...
    	end
    	if #nopots > 0 then
    		...
    	end
    	...
    end
    so change that to
    Code:
    for i = 1, GetNumGroupMembers() do
    	...
    end
    if #noprepots > 0 then
    	...
    end
    if #nopots > 0 then
    	...
    end

  11. #11
    thanks that fixed it lol did't even notice that i had the for statement finished after the if statements.

Posting Permissions

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