• 0

    posted a message on Detecting Ebonsteel Belt buckle
    I am trying to figure out how to tell if a belt has an ebonsteel belt buckle on it.

    i have been using
    itemlink= GetInventoryItemLink(unit,i)
    				if itemlink~=nil then
    					itemString=select(3, strsplit("|",itemlink))
    					itemId=select(2,strsplit(":",itemString))
    					--get enchantid based off item
    					enchantId = select(3,strsplit(":",itemString))
    end

    to check for enchantments, but this does not seem to see the buckle.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Write Me a SlashCmdFunction
    Quote from egingell
    In a slash command handler, the input message is never nil.

    @marowfreeze: You can't dump multiple inspects to chat in one swoop. You have to wait for INSPECT_READY between each one.

    Edit: Also, the message passed to the chat command handler is a string. To be more specific, it's the string that follows the chat command (e.g. "/command msg" -- msg gets passed to the chat command handler).


    thanks this helped me i figured out what it was that was my problem
    I did not need to declare msg as a variable inside the SlashCmdList function.
    Posted in: AddOn HELP!
  • 0

    posted a message on Write Me a SlashCmdFunction
    Quote from Seerah
    if msg is nil, then it's never going to equal "".


    as far as i understand msg = The SLASH_AVASTRAIDREADY array, at least that is what it looks like because when i looked at the other addons that used a similar function, msg was never set anywhere else.

    checkGuildTabard
    AutoLink
    Fatality
    some of the add ons i checked working on this specific problem
    Posted in: AddOn HELP!
  • 0

    posted a message on Write Me a SlashCmdFunction
    local function Inspect(unit, ChatType)
        --set name of person being inspected
        local name=UnitName(unit)
        --can you inspect the person?
        if CanInspect(unit) then
            if not UnitIsUnit(unit, "player") then
                --inspects person
                NotifyInspect(unit)
            end
            --declare itemlink array
            itemlink{}
           
            for i=1, 18 do
                --get itemlink for slot 1-18
                itemlink[i]= GetInventoryItemLink(unit,i)
                local itemString=select(3, strsplit("|",itemlink))
                --get enchantid based off item
                local enchantId= select(3,strsplit(":",itemString))
                if itemlink[i]~=0 or itemlink[i]~=2 or itemlink[i]~=4 or itemlink[i]~=6 or itemlink[i]~=11 or itemlink[i]~=12 or itemlink[i]~=13 or itemlink[i]~=14 or itemlink[i]~=19 then   
                    if enchantId==nil then
                        SendChatMessage(name.."does not have an enchant on their"..itemlink[i],ChatType)
                    elseif enchantId >= 3365 and enchantId <= 3370 or enchantId >= 4061 and enchantId <= 4112 or enchantId <= 4189 and enchantId >= 4209 or enchantId == 1099 or enchantId == 3594 or enchantId == 3595 or enchantId == 3847 or enchantId == 3883 or enchantId == 4115 or enchantId == 4116 or enchantId == 4118 or enchantId == 4126 or enchantId == 4127 or enchantId == 4175 or enchantId == 4176 or enchantId == 4177 or enchantId == 4217 or enchantId == 4227 or enchantId == 4256 or enchantId == 4257 or enchantId == 4258 or enchantId == 4270 then
                        SendChatMessage(name.."is fully enchanted",ChatType)
                    else
                       
                        SendChatMessage(name.."is not using a Cataclysm Enchant on their"..itemlink[i],ChatType)
                    end
                end
            end
        end       
    end   
       
    local function Check()
        --checks to make sure inspect frame is closed before starting
        if InspectFrame and InspectFrame:IsShown() then
            print(L["Close your inspection window"])
            return
        end
        --declare variables
        local ChatType
        local r = GetNumRaidMembers()
        local p = GetNumPartyMembers()
        --checks if you are in a raid or a party
        if r > 0 then
            ChatType="RAID"
            for i=1, r do
                --call main function
                Inspect("raid"..i,ChatType)
            end
        elseif p > 0 then
            ChatType="PARTY"
            for i=1, p do
                --call main function
                Inspect("party"..i,ChatType)
            end
        else
            print(L["Join a party or raid to be able to check for Enchants!"])
        end
    end
       
    
    SLASH_AVASTRAIDREADY1 = "/avastraidready"
    SLASH_AVASTRAIDREADY2 = "/avastready"
    SLASH_AVASTRAIDREADY3 = "/arr"
    SLASH_AVASTRAIDREADY4 = "/raidready"
    SlashCmdList["AVASTRAIDREADY"]=function(msg)
        local msg=msg:lower()
        if msg=="" then
            Check()
        end
    end
    
    


    the slash commands at the bottom are not working, and after 2 books, 2 forums, 2 wikis, and coping code from 3/4 other addons i am frustrated lol, if anyone could get it working it would be greatly appreciated.
    the slash command should call Check() which sees if you have your inspection window open, if you are in a raid/party/alone and then calls the Inspect() function.
    Posted in: AddOn HELP!
  • 0

    posted a message on Addon in Progress-Enchant Checker
    Quote from Ketho
    • The CheckRaid() and Inspect() functions aren't yet defined, when you are calling them
    • You should get a Lua error for that
      CheckRaid() [COLOR="DarkGreen"]-- not defined yet[/COLOR]
       
      local function CheckRaid()
      	print("hi")
      end
      
      CheckRaid() [COLOR="DarkGreen"]-- defined[/COLOR]

    Big thanks for this, i am use to C# where if i call a function anywhere, it will search for the function, where as Lua is very top->down->call back up to functions


  • The slash command stuff generally should be in this format:
  • SLASH_AVASTRAIDREADY1
    SLASH_AVASTRAIDREADY1 = "/avastraidready"
    SLASH_AVASTRAIDREADY2 = "/avastready"
    SLASH_AVASTRAIDREADY3 = "/arr"
    SLASH_AVASTRAIDREADY4 = "/raidready"
    SlashCmdList["AVASTRAIDREADY"] = function(msg)
    	-- stuff
    end

    This is what is confusing me, that is saying that SlashCmdList is a function that is being passed the variable 'msg', but msg is not defined anywhere else, so is this defaulting to what is being typed by 'player'? i have even found code where msg is defined inside the function that it is being called to
    -----Check guild Tabard code by BigRedBrent----
    SlashCmdList.CheckGuildTabardAddon = function(msg)
    	local msg = msg:lower()
    	if msg == "" then
    		check()
    	else
    		InterfaceOptionsFrame_OpenToCategory(CheckGuildTabardAddonOptionsFrame)
    	end
    end


  • afaik, SendChatMessage only takes channel IDs
  • *I'm not sure why you want to output to a custom channel, instead of just printing to yourself
    SendChatMessage("Try Again", "CHANNEL", nil, GetChannelName("RaidReady"))


    This was actually a mistake, forgot to switch it back to a print statement.

    --updated code---
    local function Inspect(unit, ChatType)
    	--set name of person being inspected
    	local name=UnitName(unit)
    	--can you inspect the person?
    	if CanInspect(unit) then
    		if not UnitIsUnit(unit, "player") then
    			--inspects person
    			NotifyInspect(unit)
    		end
    		--declare itemlink array
    		itemlink{}
    		
    		for i=1, 18 do
    			--get itemlink for slot 1-18 
    			itemlink[i]= GetInventoryItemLink(unit,i)
    			local itemString=select(3, strsplit("|",itemlink))
    			--get enchantid based off item
    			local enchantId= select(3,strsplit(":",itemString))
    			if itemlink[i]~=0 or itemlink[i]~=2 or itemlink[i]~=4 or itemlink[i]~=6 or itemlink[i]~=11 or itemlink[i]~=12 or itemlink[i]~=13 or itemlink[i]~=14 or itemlink[i]~=19 then	
    				if enchantId==nil then
    					SendChatMessage(name.."does not have an enchant on their"..itemlink[i],ChatType)
    				elseif enchantId >= 3365 and enchantId <= 3370 or enchantId >= 4061 and enchantId <= 4112 or enchantId <= 4189 and enchantId >= 4209 or enchantId == 1099 or enchantId == 3594 or enchantId == 3595 or enchantId == 3847 or enchantId == 3883 or enchantId == 4115 or enchantId == 4116 or enchantId == 4118 or enchantId == 4126 or enchantId == 4127 or enchantId == 4175 or enchantId == 4176 or enchantId == 4177 or enchantId == 4217 or enchantId == 4227 or enchantId == 4256 or enchantId == 4257 or enchantId == 4258 or enchantId == 4270 then
    					SendChatMessage(name.."is fully enchanted",ChatType)
    				else
    					
    					SendChatMessage(name.."is not using a Cataclysm Enchant on their"..itemlink[i],ChatType)
    				end
    			end
    		end
    	end		
    end	
    	
    local function Check()
    	--checks to make sure inspect frame is closed before starting
    	if InspectFrame and InspectFrame:IsShown() then
    		print(L["Close your inspection window"])
    		return
    	end
    	--declare variables
    	local ChatType
    	local r = GetNumRaidMembers()
    	local p = GetNumPartyMembers()
    	--checks if you are in a raid or a party
    	if r > 0 then
    		ChatType="RAID"
    		for i=1, r do
    			--call main function
    			Inspect("raid"..i,ChatType)
    		end
    	elseif p > 0 then
    		ChatType="PARTY"
    		for i=1, p do
    			--call main function
    			Inspect("party"..i,ChatType)
    		end
    	else
    		print(L["Join a party or raid to be able to check for Enchants!"])
    	end
    end
    	
    
    SLASH_AVASTRAIDREADY1 = "/avastraidready"
    SLASH_AVASTRAIDREADY2 = "/avastready"
    SLASH_AVASTRAIDREADY3 = "/arr"
    SLASH_AVASTRAIDREADY4 = "/raidready"
    SlashCmdList["AVASTRAIDREADY"]=function()
    	Check()
    end
    
    Posted in: AddOn HELP!
  • 0

    posted a message on Addon in Progress-Enchant Checker
    Hey all,

    My guild likes to make sure everyone is running with full enchants and gems so i have started an add on to do that. This first version is just supposed to check if every piece of gear (that can be enchanted) as a cataclysm level enchant on it.

    I was hoping someone could check through my code and tell me what I can do better/what I am doing wrong etc.

    Currently i can not get the stupid slash commands to work.

    Link Removed: http://www.mediafire.com/?0di7bt46ffyzmbt --link to full file
    SLASH_AvastRaidReadyAddon1 = "/avastraidready"
    SLASH_AvastRaidReadyAddon2 = "/avastready"
    SLASH_AvastRaidReadyAddon3 = "/arr"
    SLASH_AvastRaidReadyAddon4 = "/raidready"
    SlashCmdList["AvastRaidReady"]=function(msg)
    	local msg=msg:lower()
    	if msg=="" then
    		CheckRaid()
    	else
    		SendChatMessage("Try Again","CHANNEL",nil,"RaidReady")
    	end
    end
    
    		
    local function CheckRaid()
    	--checks to make sure inspect frame is closed before starting
    	if InspectFrame and InspectFrame:IsShown() then
    		print(L["Close your inspection window"])
    		return
    	end
    	--declare variables
    	local ChatType
    	local r = GetNumRaidMembers()
    	local p = GetNumPartyMembers()
    	--checks if you are in a raid or a party
    	if r > 0 then
    		ChatType="RAID"
    		for i=1, r do
    			--call main function
    			Inspect("raid"..i,ChatType)
    		end
    	elseif p > 0 then
    		ChatType="PARTY"
    		for i=1, p do
    			--call main function
    			Inspect("party"..i,ChatType)
    		end
    	else
    		print(L["Join a party or raid to be able to check for Enchants!"])
    	end
    end
    	
    local function Inspect(unit, ChatType)
    	--set name of person being inspected
    	local name=UnitName(unit)
    	--can you inspect the person?
    	if CanInspect(unit) then
    		if not UnitIsUnit(unit, "player") then
    			--inspects person
    			NotifyInspect(unit)
    		end
    		--declare itemlink array
    		itemlink{}
    		
    		for i=1, 18 do
    			--get itemlink for slot 1-18 
    			itemlink[i]= GetInventoryItemLink(unit,i)
    			local itemString=select(3, strsplit("|",itemlink))
    			--get enchantid based off item
    			local enchantId= select(3,strsplit(":",itemString))
    			if itemlink[i]~=0 or itemlink[i]~=2 or itemlink[i]~=4 or itemlink[i]~=6 or itemlink[i]~=11 or itemlink[i]~=12 or itemlink[i]~=13 or itemlink[i]~=14 or itemlink[i]~=19 then	
    				if enchantId==nil then
    					SendChatMessage(name.."does not have an enchant on their"..itemlink[i],ChatType)
    				elseif enchantId >= 3365 and enchantId <= 3370 or enchantId >= 4061 and enchantId <= 4112 or enchantId <= 4189 and enchantId >= 4209 or enchantId == 1099 or enchantId == 3594 or enchantId == 3595 or enchantId == 3847 or enchantId == 3883 or enchantId == 4115 or enchantId == 4116 or enchantId == 4118 or enchantId == 4126 or enchantId == 4127 or enchantId == 4175 or enchantId == 4176 or enchantId == 4177 or enchantId == 4217 or enchantId == 4227 or enchantId == 4256 or enchantId == 4257 or enchantId == 4258 or enchantId == 4270 then
    					SendChatMessage(name.."is fully enchanted",ChatType)
    				else
    					
    					SendChatMessage(name.."is not using a Cataclysm Enchant on their"..itemlink[i],ChatType)
    				end
    			end
    		end
    	end		
    end	
    Posted in: AddOn HELP!
  • To post a comment, please or register a new account.