• 0

    posted a message on Localization system

    Also add a list of Global phrases so you can go down the overall list and see how many are done/missing/need checking

    Posted in: WoW Sites Feedback
  • 0

    posted a message on Slash Command Discussion
    full code below with the working line in the only problem w/ it is that it doesn't save right but now it works with both lines added I don't know *shrug* but thanks for the page link it helped a lot not sure why i hadn't found it before

    local addonName, vars = ...				
    local L = vars.L				
    YurekWorld = vars				
    local addon = YurekWorld				
    local addonsls = "/YuWo"				
    local settings				
    				
    local defaults = {				
    	enabled = true,			
    	pet = true,			
    }				
    -- 12				
    local function eventHandler(self, event, ...)				
    	print("test")			
    	if event == "ADDON_LOADED" and select(1,...) == addonName then			
    		if not YurekWorldSettings then		
    			YurekWorldSettings= {} 	
    		end		
    		settings = YurekWorldSettings		
    		for k,v in pairs(defaults) do		
    			if settings[k] == nil then	
    				settings[k] = v
    			end	
    		end		
    	elseif event == "CHAT_MSG_LOOT" then			
    		print(event)		
    	elseif event == "CHAT_MSG_WHISPER" then			
    		print(event)		
    	end			
    end				
    -- (19) 31				
    function addon:SlashHandler(msg)				
    	local cmd = msg:lower()			
    	if cmd == "on" then			
    		settings.enabled = true		
    		print("Enabled.")		
    	elseif cmd == "off" then			
    		settings.enabled = false		
    		print("Disabled.")		
    	elseif cmd == "pet" then			
    		settings[cmd] = not settings[cmd]		
    		print(cmd.." "..(settings[cmd] and "enabled." or "disabled."))		
    	else			
    		print("Usage: "..addonsls.." [ on | off | say | sound ]")		
    	end			
    end				
    -- (16) 47				
    local frame = CreateFrame("Button", addonName.."HiddenFrame", UIParent);				
    frame:SetScript("OnEvent", eventHandler);				
    frame:RegisterEvent("CHAT_MSG_LOOT");				
    frame:RegisterEvent("CHAT_MSG_WHISPER")				
    -- ( 5) 52				
    -- slash cmd function				
    	hash_SlashCmdList[addonsls] = nil			
    	SLASH_YurekWorld1 = addonsls			
    	SlashCmdList[addonName] = function(msg)			
    		addon:SlashHandler(msg)		
    	end -- (16) 58
    Posted in: Lua Code Discussion
  • 0

    posted a message on Slash Command Discussion
    my program i am using is just a tester i am dropping pieces of code in to see how it works so i took the base code and dropped in the slash command code
    local frame = CreateFrame("Button", addonName.."HiddenFrame", UIParent);
    -- ^^ line in question^^		
    frame:SetScript("OnEvent", eventHandler);		
    frame:RegisterEvent("CHAT_MSG_LOOT");		
    frame:RegisterEvent("CHAT_MSG_WHISPER")
    -- ( 5) 36 vv added lines
    -- slash cmd function
    	hash_SlashCmdList[addonsls] = nil	
    	SLASH_YurekWorld1 = addonsls	
    	SlashCmdList[addonName] = function(msg)	
    	local cmd = msg:lower()	
    	if cmd == "on" then	
    		settings.enabled = true
    		print("Enabled.")
    	elseif cmd == "off" then	
    		settings.enabled = false
    		print("Disabled.")
    	elseif cmd == "pet" then	
    		settings[cmd] = not settings[cmd]
    		print(cmd.." "..(settings[cmd] and "enabled." or "disabled."))
    	else	
    		print("Usage: "..addonsls.." [ on | off | say | sound ]")
    	end
    end -- (18) 54 ^^ added lines
    and it didn't work so i looked at the two sets of code and realized the only difference was the two lines

    worked
    local frame = CreateFrame("Button", addonName.."HiddenFrame", UIParent);

    did not work
    local frame = CreateFrame("FRAME", addonName);


    so i was just wondering what the differences were. if i had known it wasn't such an obvious thing i would have said more sorry. it just peaked my interest why/what the other commands had to do with it as most of the code explanations pages are more like "under redundant see redundant"??? i thought someone could tell me in a more non-circular method :) again sorry for the confusion.
    Posted in: Lua Code Discussion
  • 0

    posted a message on Slash Command Discussion
    no it said "Lua Code Discussion" so i was discussing :) and Stupefied fit my question lol
    Posted in: Lua Code Discussion
  • 0

    posted a message on Slash Command Discussion
    ok I'v been working (on the Railroad *sorry*) on slash commands and could not get them to work in my "work" file then i noticed i had one line differant (see below) what/why is there a differance between the two in the case of pulling slash commands??

    works
    local frame = CreateFrame("Button", addonName.."HiddenFrame", UIParent);


    did not work
    local frame = CreateFrame("FRAME", addonName);
    Posted in: Lua Code Discussion
  • 0

    posted a message on using for in ipairs do with arrays
    no help O_o really not even a look in this direction -- come on guys i need at least bone to make bone soup right now i'v just got what i had to start w/ nada :(
    Posted in: Need Help?
  • 0

    posted a message on using for in ipairs do with arrays
    back with part 2 :)
    I am trying to put my sound list in multipul groups (each pet) but when it runs it only goes threw the "for ipair do loop" in soundplay once which means it has a small chance of playing one sound which isn't what i am trying to accomplish :) and the commented out area is my work for one sound table so i can go back and forth easily

    local addonName, vars = ...				
    local L = vars.L				
    YurekWorld = vars				
    local addon = YurekWorld
    local addonsls = "/PrRP"				
    local settings			
    -- 7(7)
    local soundfiles = {				
    [1] = {		---	
    		DW_Do_not_Swear	= {p=10, t=5},		
    		DW_Earth_Death_Scheduled	= {p=10, t=5},		
    		DW_Exterminate	= {p=10, t=5},		
    		DW_Must_Survive	= {p=10, t=5},		
    		DW_Owner_of_Blue_Box	= {p=10, t=5},		
    		DW_TARDIS	= {p=10, t=5},		
    		DW_Upgrading_is_compulsory	= {p=10, t=5},		
    		DW_Weakest_Link	= {p=10, t=5},		
    	},
    	[2] = {				
    		WEF_F_Agree	= {p=10, t=1},		
    		WEF_F_Disagree	= {p=10, t=1},		
    		WEF_F_Follow	= {p=10, t=1},		
    		WEF_F_Greet	= {p=10, t=1},		
    		WEF_F_Heal	= {p=10, t=1},		
    		WEF_F_Help	= {p=10, t=1},		
    		WEF_F_Laugh	= {p=10, t=1},		
    		WEF_F_Stop	= {p=10, t=1},		
    		WEF_F_Thanks	= {p=10, t=1},		
    	},--[[----]]--
    }				
    -- 31(24)
    addon.soundtable = {}				
    addon.soundsum = {}						
    for i = 1, 2 do	
    	local roll_flag = 0	 --[[----]]--
    	for name, data in pairs(soundfiles[i]) do	-- 
    		addon.soundsum[i] = {}		
    		addon.soundtable[i] = {}	--[[----]]--
    		print("2 ".. name .. " " .. data.p .. " " .. data.t)
    		local soundname = ("Interface\\AddOns\\"..addonName.."\\sound\\"..name..".mp3")
    		table.insert(addon.soundtable[i], {	-- 
    			soundname, data.p, data.t
    			})	
    --		addon.soundsum = addon.soundsum  + data.p
    		roll_flag = roll_flag + data.p		
    	end			
    	addon.soundsum[i] = roll_flag			
    	print("3 ".. addon.soundsum[i] .. " " .. roll_flag)--[[----]]--
    end				
    -- 51(20)
    function addon:soundplay(pet_f)
    	local Y_sound = addon.soundsum[pet_f]
    	local Y_table = addon.soundtable[pet_f]	
    --[[--	local Y_sound = addon.soundsum
    	local Y_table = addon.soundtable	--]]--
    	local roll = math.random(Y_sound)
    	print("4 ".. roll .. " " .. Y_sound)
    		for i,e in ipairs(Y_table) do	
    			local f,p,t = unpack(e)
    			roll = roll - p
    			print("5 ".. i .. " " .. p .. " " .. roll .. " " .. t)
    			if roll <= 0 then	
    				PlaySoundFile(f, "Master")
    				print("6".. "playing "..f)
    ---				pause = math.max(pause, t)
    				break
    			end	
    		end
    end
    -- 166(20)
    local function eventHandler(self, event, arg1)				
    	if event == "CHAT_MSG_LOOT" then
    		print(event)
     	elseif event == "CHAT_MSG_WHISPER" then
    		print(event)
    		addon:soundplay(1)
    	end
    end
    -- 15(8)
    local frame = CreateFrame("FRAME", addonName);				
    frame:SetScript("OnEvent", eventHandler);
    frame:RegisterEvent("CHAT_MSG_LOOT");
    frame:RegisterEvent("CHAT_MSG_WHISPER")
    Posted in: Need Help?
  • 0

    posted a message on pulling item loot number
    there this works now i can move to my next stage :) thanks
    and as for what info is needed at the start :p if i knew that i wouldn't have to come here :D


    	if event == "CHAT_MSG_LOOT" then
    		local itemstr = LOOT_ITEM_PUSHED_SELF:gsub("%%s","%(.*%)") -- for Skinning
    		local itemstr2 = LOOT_ITEM_SELF:gsub("%%s","%(.*%)") -- for tailery
    		local message = ... or ""
    			print(message)
    		local link = message:match(itemstr) --
    -- 31
    		local link2 = message:match(itemstr2) --
    		local hold
    		if (link) then hold = link else hold = link2 end
    		local id = hold and tonumber(hold:match("\124Hitem:(%d+):"))
    			print("3 " .. id)
    		if id and lootitems[id] then		
    			print("worked")
    		else
    			print(lootitems[2589])
    		end
    	end


    start looking for my other requests for help as i can think of them :)
    Posted in: Need Help?
  • 0

    posted a message on pulling item loot number
    		local message = ... or ""
    			print(message)
    		local link = message:match(itemstr) --
    			print(link)
    		local id = link and tonumber(link:match("\124Hitem:(%d+):"))
    			print(id)
    		if id and lootitems[id] then		
    			print("worked")
    		else
    			print(lootitems[2589])
    		end


    and i get:
    * standard loot message
    * nil
    * nil
    * true

    the odd thing is it worked for the mail or buying but not for the looting ???
    Posted in: Need Help?
  • 0

    posted a message on pulling item loot number
    I am trying to run code if a certain item is looted but I can't seem to get the number to show I keep getting nil for id what am i missing ??

    local addonName, vars = ...				
    local L = vars.L				
    YurekWorld = vars				
    local addon = YurekWorld
    local addonsls = "/PrRP"				
    local settings			
    -- 7
    local itemstr = LOOT_ITEM_PUSHED_SELF:gsub("%%s","%(.*%)")	
    	
    local lootitems = {				
    	[119813] = true, 	-- Furry Caged Beast		
    	[119810] = true, 	-- Meaty Caged Beast		
    	[119814] = true, 	-- Leathery Caged Beast		
    	[119815] = true, 	-- Caged Mighty Wolf		
    	[119817] = true, 	-- Caged Mighty Riverbeast		
    	[119819] = true, 	-- Caged Mighty Clefthoof
    	[2589]   = true,	-- linen-cloth
    	[2592]   = true,	-- wool-cloth
    	[4306]   = true,	-- silk-cloth
    	[4338]   = true,	-- mageweave-cloth
    	[14047]  = true,	-- runecloth
    }
    -- 22
    local function eventHandler(self, event, ...)				
    	if event == "CHAT_MSG_LOOT" then
    		local message = ... or ""
    		local link = message:match(itemstr) --
    		local id = link and tonumber(link:match("\124Hitem:(%d+):"))
    			print(id)
    		if id and lootitems[id] then		
    			print("worked")
    		else
    			print(lootitems[2589])
    		end
    	end
    end
    -- 35
    local frame = CreateFrame("FRAME", addonName);				
    frame:SetScript("OnEvent", eventHandler);
    frame:RegisterEvent("CHAT_MSG_LOOT")
    Posted in: Need Help?
  • 0

    posted a message on Help with an "'}' expected (to close" error
    ok I have done a few changes since the first one so here is how it stands now no errors but no for next loop with the sounds *thud*
    		for _,e in ipairs(addon.soundtable[pet_f]) do	
    now does not work ??? I know that it is supposed to 'for do loop' the number of songs and then subtract the p till it gets to the negative number. it worked without the array but not w/ how do i transform it ??

    local addonName, vars = ...				
    local L = vars.L				
    Profesion_RP = vars				
    local addon = Profesion_RP				
    local settings				
    				
    local defaults = {				
    	enabled = true,			
    	playfrequency = 5,			
    	sound = true,			
    	say = true,			
    	pet = true,			
    }				
    				
    local function chatMsg(msg) 				
    	DEFAULT_CHAT_FRAME:AddMessage(addonName..": "..msg)			
    end				
    				
    local pet_n = {				
    	[1] = "BattlePet-0-00000486CF51",			
    	[2] = "BattlePet-0-00000486CE3C",			
    }				
    				
    local soundfiles = {}				
    soundfiles[1] = {				
    	DW_Do_not_Swear	= {p=10, t=5},		
    	DW_Earth_Death_Scheduled	= {p=10, t=5},		
    	DW_Exterminate	= {p=10, t=5},		
    	DW_Must_Survive	= {p=10, t=5},		
    	DW_Owner_of_Blue_Box	= {p=10, t=5},		
    	DW_TARDIS	= {p=10, t=5},		
    	DW_Upgrading_is_compulsory	= {p=10, t=5},		
    	DW_Weakest_Link	= {p=10, t=5},		
    }				
    soundfiles[2] = {				
    	WEF_F_Agree	= {p=10, t=1},		
    	WEF_F_Disagree	= {p=10, t=1},		
    	WEF_F_Follow	= {p=10, t=1},		
    	WEF_F_Greet	= {p=10, t=1},		
    	WEF_F_Heal	= {p=10, t=1},		
    	WEF_F_Help	= {p=10, t=1},		
    	WEF_F_Laugh	= {p=10, t=1},		
    	WEF_F_Stop	= {p=10, t=1},		
    	WEF_F_Thanks	= {p=10, t=1},		
    }				
    				
    local cageitems = {				
    	[119813] = true, 	-- Furry Caged Beast		
    	[119810] = true, 	-- Meaty Caged Beast		
    	[119814] = true, 	-- Leathery Caged Beast		
    	[119815] = true, 	-- Caged Mighty Wolf		
    	[119817] = true, 	-- Caged Mighty Riverbeast		
    	[119819] = true, 	-- Caged Mighty Clefthoof		
    }				
    				
    local skinning = GetSpellInfo(74522)				
    local itemstr = LOOT_ITEM_PUSHED_SELF:gsub("%%s","%(.*%)")				
    addon.soundtable = {}				
    addon.soundsum = {}						
    for i = 1, 2 do	
    	local roll_flag = 0		
    	for name, data in pairs(soundfiles[i]) do			
    		addon.soundsum[i] = {}		
    		addon.soundtable[i] = {}		
    		table.insert(addon.soundtable[i], { 		
    			"Interface\\AddOns\\"..addonName.."\\sound\\"..name..".mp3", data.p, data.t	
    			})	
    		roll_flag = roll_flag + data.p		
    	end			
    	addon.soundsum[i] = roll_flag			
    end				
    
    				
    function addon:doSkin()				
    	if not settings or not settings.enabled then return end			
    	local now = GetTime()			
    	local pause = settings.playfrequency			
    	if now < (addon.nextplay or 0) then return end			
    	local pet_gu, pet_f
    	if C_PetJournal.GetSummonedPetGUID() then pet_gu=C_PetJournal.GetSummonedPetGUID() else pet_gu=0 end
    	if pet_gu == pet_n[1] then			
    		pet_f = 1		
    	else			
    		pet_f = 2		
    	end			
    	print("this is the ads " .. pet_f .. " " .. addon.soundsum[pet_f])
    	if not(C_PetJournal.GetSummonedPetGUID()==pet_gu) then
    		pet_call(pet_f)
    	end
    
    	if settings.sound then
    		-- v this was so i could track the loop hits one and done
    		local oll = 0
    		local roll = math.random(addon.soundsum[pet_f])
    	print("this is the sst " .. roll .. " " .. addon.soundsum[pet_f])
    		-- v no for next loop 
    		for _,e in ipairs(addon.soundtable[pet_f]) do	
    			local f,p,t = unpack(e)
    			roll = roll - p
    			oll = oll + 1
    			print("this is the ss " .. oll .. " " .. p .. " " .. roll)
    			if roll <= 0 then	
    				PlaySoundFile(f, "Master")
    				chatMsg("playing "..f)
    				pause = math.max(pause, t)
    				break
    			end	
    		end		
    	end			
    	if settings.say then			
    		local msg = settings.msg or "Give me your skin!"		
    		local _, petName, _, _, _, _, _, petRace  = C_PetJournal.GetPetInfoByPetID(pet_n[pet_f])
    		if not petName then petName = petRace end		
    		SendChatMessage(petName .. " says " .. "'" .. msg .. "'","SAY")		
    	end			
    	addon.nextplay = now + pause			
    end				
    				
    function pet_call(pet_f)				
    	print("this is the #" .. pet_f)			
    	C_PetJournal.SummonPetByGUID(pet_n[pet_f])			
    end				
    				
    local function frame_OnEvent(self,event,...)				
    	if event == "ADDON_LOADED" and select(1,...) == addonName then			
    		if not Profesion_RPSettings then		
    			Profesion_RPSettings = {} 	
    		end		
    		settings = Profesion_RPSettings		
    		for k,v in pairs(defaults) do		
    			if settings[k] == nil then	
    				settings[k] = v
    			end	
    		end		
     elseif event == "UNIT_SPELLCAST_START" then				
    		local unitID, spell, rank, lineID, spellID = ...		
    		if unitID == "player" and spell == skinning then		
    			addon:doSkin()	
    		end		
     elseif event == "CHAT_MSG_LOOT" then				
    		local message = (...) or ""		
    		local link = message:match(itemstr)		
    		local id = link and tonumber(link:match("\124Hitem:(%d+):"))		
    		if id and cageitems[id] then		
    			addon:doSkin()	
    		end		
    	end			
    end				
    				
    local frame = CreateFrame("Button", addonName.."HiddenFrame", UIParent)				
    frame:SetScript("OnEvent", frame_OnEvent)				
    frame:RegisterEvent("ADDON_LOADED")				
    frame:RegisterEvent("UNIT_SPELLCAST_START")				
    frame:RegisterEvent("CHAT_MSG_LOOT")				
    				
    	hash_SlashCmdList["/Prof_RP"] = nil			
    	SLASH_Profesion_RP1 = "/Prof_RP"			
    	SlashCmdList["Prof_RP"] = function(msg)			
    	local cmd = msg:lower()			
    	if cmd == "on" then			
    		settings.enabled = true		
    		chatMsg("Enabled.")		
    	elseif cmd == "off" then			
    		settings.enabled = false		
    		chatMsg("Disabled.")		
    	elseif cmd == "say" or cmd == "sound" or cmd == "pet" then			
    		settings[cmd] = not settings[cmd]		
    		chatMsg(cmd.." "..(settings[cmd] and "enabled." or "disabled."))		
    	else			
    		chatMsg("Usage: "..SLASH_Prof_RP1.." [ on | off | say | sound ]")		
    	end			
    end
    Posted in: Need Help?
  • 0

    posted a message on Help with an "'}' expected (to close" error
    ok i have changed up a little bit of the code
    addon.soundsum = {}
    -- v added this line
    roll_flag = 0

    		-- v changed that up a bit
    		local roll_flag = roll_flag + data.p		
    	end
    	-- added v this one
    	addon.soundsum[i] = roll_flag


    and no errors yet :)
    Posted in: Need Help?
  • 0

    posted a message on Help with an "'}' expected (to close" error
    ok here is round what three:
    * fixed the i issue
    * turned the soundfiles back into tables (added back the parenthesis)
    * turned soundsum into a table instead of a number (added parenthesis)
    * added 2 lines -- after
    	for name, data in pairs(soundfiles[i]) do			
    		addon.soundsum[i] = {}
    		addon.soundtable[i] = {}

    * added 1 line -- before
    		local roll_flag = addon.soundsum[pet_f]	
    		local roll = math.random(roll_flag)
    and
    		local roll_flag = addon.soundsum[i]
    		addon.soundsum[i] = roll_flag + data.p		
    


    from what i can tell the error is now my roll_flag is now a table instead of the variable i want it to be ???

    next error
    Message: ..\AddOns\Profesion_RP\Profesion_RP.lua line 56:
       attempt to perform arithmetic on local 'roll_flag' (a table value)
    Debug:
       Profesion_RP\Profesion_RP.lua:56: in main chunk
    Locals:
    addonName = "Profesion_RP"
    vars = <table> {
     soundtable = <table> {
     }
     soundsum = <table> {
     }
    }
    L = nil
    addon = <table> {
     soundtable = <table> {
     }
     soundsum = <table> {
     }
    }
    settings = nil
    defaults = <table> {
     enabled = true
     pet2 = "BattlePet-0-00000486CE3C"
     say = true
     pet1 = "BattlePet-0-00000486CF51"
     playfrequency = 5
     sound = true
     pet = true
    }
    chatMsg = <function> defined @Interface\AddOns\Profesion_RP\Profesion_RP.lua:17
    soundfiles = <table> {
     1 = <table> {
     }
     2 = <table> {
     }
    }
    (for index) = 1
    (for limit) = 2
    (for step) = 1
    i = 1
    (for generator) = <function> defined =[C]:-1
    (for state) = <table> {
     DW_Exterminate = <table> {
     }
     DW_TARDIS = <table> {
     }
     DW_Upgrading_is_compulsory = <table> {
     }
     DW_Earth_Death_Scheduled = <table> {
     }
     DW_Weakest_Link = <table> {
     }
     DW_Owner_of_Blue_Box = <table> {
     }
     DW_Must_Survive = <table> {
     }
     DW_Do_not_Swear = <table> {
     }
    }
    (for control) = "DW_Exterminate"
    name = "DW_Exterminate"
    data = <table> {
     t = 5
     p = 10
    }
    roll_flag = <table> {
    }
    (*temporary) = <table> {
     1 = <table> {
     }
    }
    (*temporary) = 10
    (*temporary) = "Interface\AddOns\Profesion_RP\sound\DW_Exterminate.mp3"
    (*temporary) = 10
    (*temporary) = 5
    (*temporary) = "DW_Exterminate"
    (*temporary) = ".mp3"
    (*temporary) = "attempt to perform arithmetic on local 'roll_flag' (a table value)"


    i'll post right now but am still working on it
    Posted in: Need Help?
  • 0

    posted a message on Help with an "'}' expected (to close" error
    ok changed line to:

    "Interface\\AddOns\\"..addonName.."\\sound\\"..name..".mp3", data.p, data.t



    and then got the Message :o: ..\AddOns\Profesion_RP\Profesion_RP.lua line 49:
    bad argument #1 to 'pairs' (table expected, got nil)

    then i took the parentheses off the "soundfiles"
    soundfiles1 = {
    soundfiles2 = {


    and it still has the same error arrrg :mad:
    Posted in: Need Help?
  • 0

    posted a message on Help with an "'}' expected (to close" error
    ok I am trying to create my own gatherer addon that will make sounds appropriate for the pet you have out and put out a pet if you don't have one I have started w/ an addon that just played a set of sounds and am trying to add multiple levels to it by adding arrays to the 'soundfiles' variable among others and have ran into a containment issue near the sound file name builder. could you let me in where i have gone blind ???

    thanks ahead of time

    -- error Message: ..\AddOns\Profesion_RP\Profesion_RP.lua line 51: '}' expected (to close '{' at line 50) near '\'

    [php]local addonName, vars = ...
    local L = vars.L
    Profesion_RP = vars
    local addon = Profesion_RP
    local settings

    local defaults = {
    enabled = true,
    playfrequency = 5,
    sound = true,
    say = true,
    pet = true,
    pet1 = "BattlePet-0-00000486CF51",
    pet2 = "BattlePet-0-00000486CE3C",
    }

    local function chatMsg(msg)
    DEFAULT_CHAT_FRAME:AddMessage(addonName..": "..msg)
    end

    local soundfiles = {}
    soundfiles[1] = {
    DW_Do_not_Swear = {p=10, t=5},
    DW_Earth_Death_Scheduled = {p=10, t=5},
    DW_Exterminate = {p=10, t=5},
    DW_Must_Survive = {p=10, t=5},
    DW_Owner_of_Blue_Box = {p=10, t=5},
    DW_TARDIS = {p=10, t=5},
    DW_Upgrading_is_compulsory = {p=10, t=5},
    DW_Weakest_Link = {p=10, t=5},
    }
    soundfiles[2] = {
    WEF_F_Agree = {p=10, t=1},
    WEF_F_Battle = {p=10, t=1},
    WEF_F_Disagree = {p=10, t=1},
    WEF_F_Follow = {p=10, t=1},
    WEF_F_Greet = {p=10, t=1},
    WEF_F_Heal = {p=10, t=1},
    WEF_F_Help = {p=10, t=1},
    WEF_F_Laugh = {p=10, t=1},
    WEF_F_Part = {p=10, t=1},
    WEF_F_Retreat = {p=10, t=1},
    WEF_F_Stop = {p=10, t=1},
    WEF_F_Thanks = {p=10, t=1},
    }
    addon.soundtable = {}
    addon.soundsum = 0
    for I = 1, 2 do
    for name, data in pairs(soundfiles[i]) do
    -- error message came from here
    table.insert(addon.soundtable[i], {
    Interface\\AddOns\\..addonName.."\\sound\\"..name..".mp3", data.p, data.t
    })
    addon.soundsum[i] = addon.soundsum[i] + data.p
    end
    end

    function addon:doSkin()
    if not settings or not settings.enabled then return end
    local now = GetTime()
    local pause = settings.playfrequency
    if now < (addon.nextplay or 0) then return end
    local pet_f = 0
    if settings.pet then
    pet_f = 1
    else
    pet_f = 2

    end

    if settings.sound then
    --- local pet_ga = C_PetJournal.GetSummonedPetGUID()

    if not(C_PetJournal.GetSummonedPetGUID()==petgu) then

    pet_call(pet_f)
    end
    local roll = math.random(addon.soundsum[pet_f])
    for _,e in ipairs(addon.soundtable[pet_f]) do
    local f,p,t = unpack(e)
    roll = roll - p
    if roll <= 0 then
    PlaySoundFile(f, "Master")
    chatMsg("playing "..f)
    pause = math.max(pause, t)
    break
    end
    end
    end
    if settings.say then
    local msg = settings.msg or "Give me your skin!"
    local _, petName, _, _, _, _, _, petRace = C_PetJournal.GetPetInfoByPetID(settings.pet[pet_f])
    if not petName then petName = petRace end
    SendChatMessage(petName .. " says " .. "'" .. msg .. "'","SAY")
    end
    addon.nextplay = now + pause
    end

    function pet_call(pet_f)
    print("this is the #" .. pet_f)
    C_PetJournal.SummonPetByGUID(settings.pet[pet_f])
    end

    local skinning = GetSpellInfo(74522)
    local itemstr = LOOT_ITEM_PUSHED_SELF:gsub("%%s","%(.*%)")
    local cageitems = {
    [119813] = true, -- Furry Caged Beast
    [119810] = true, -- Meaty Caged Beast
    [119814] = true, -- Leathery Caged Beast
    [119815] = true, -- Caged Mighty Wolf
    [119817] = true, -- Caged Mighty Riverbeast
    [119819] = true, -- Caged Mighty Clefthoof
    }

    local function frame_OnEvent(self,event,...)
    if event == "ADDON_LOADED" and select(1,...) == addonName then
    if not Profesion_RPSettings then
    Profesion_RPSettings = {}
    end
    settings = Profesion_RPSettings
    for k,v in pairs(defaults) do
    if settings[k] == nil then
    settings[k] = v
    end
    end
    elseif event == "UNIT_SPELLCAST_START" then
    local unitID, spell, rank, lineID, spellID = ...
    if unitID == "player" and spell == skinning then
    addon:doSkin()
    end
    elseif event == "CHAT_MSG_LOOT" then
    local message = (...) or ""
    local link = message:match(itemstr)
    local id = link and tonumber(link:match("\124Hitem:(%d+):"))
    if id and cageitems[id] then
    addon:doSkin()
    end
    end
    end

    local frame = CreateFrame("Button", addonName.."HiddenFrame", UIParent)
    frame:SetScript("OnEvent", frame_OnEvent)
    frame:RegisterEvent("ADDON_LOADED")
    frame:RegisterEvent("UNIT_SPELLCAST_START")
    frame:RegisterEvent("CHAT_MSG_LOOT")

    hash_SlashCmdList["/Profesion_RP"] = nil
    SLASH_Profesion_RP1 = "/Profesion_RP"
    SlashCmdList["Profesion_RP"] = function(msg)
    local cmd = msg:lower()
    if cmd == "on" then
    settings.enabled = true
    chatMsg("Enabled.")
    elseif cmd == "off" then
    settings.enabled = false
    chatMsg("Disabled.")
    elseif cmd == "say" or cmd == "sound" or cmd == "pet" then
    settings[cmd] = not settings[cmd]
    chatMsg(cmd.." "..(settings[cmd] and "enabled." or "disabled."))
    else
    chatMsg("Usage: "..SLASH_Profesion_RP1.." [ on | off | say | sound ]")
    end
    end[/php]
    Posted in: Need Help?
  • To post a comment, please or register a new account.