• 0

    posted a message on savedVariables ?
    Quote from Xinhuan
    The variable(s) you declared in ## SavedVariables in your TOC file must be in global scope. You declared buffs in local file scope in your addon so nothing got saved as the global buffs variable doesn't exist.
    .


    I'm sry I didn't specify it: after myrrodin and Farmbuyer replied I changed it, now the variable should be global and it's called Saundo2DB so buffs is no more the one I'm using to store the settings...

    Quote from myrrodin »
    Now that you have renamed your saved variable to Saundo2DB (I hope you renamed it in your toc as well, or it won't work) the reason the SV is blank is because there is nothing in buffs. It is an empty table right now.


    yes I renamed the variable in the toc file as well... the part I don't understand is :
    1)I use the addon the first time --> buffs is empty
    2)during this session I use

    SLASH_SAUNDOADD1= "/saundoAdd"
    SlashCmdList["SAUNDOADD"] = function (msg)
    	table.insert(buffs, msg)
    	---some print message
    end
    

    to add what I want to track in buffs
    so now buffs shouldn't be empty anymore and it's not cus the addon keeps trace of the buffs I added
    3) I logout to test the SavedVariables
    function Saundo2:OnEvent(event, addOn)
    	if event == "ADDON_LOADED" and addOn == "Saundo2" then
    		if Saundo2DB == nil then
    			Saundo2DB = {}
    		else 
    			for i = 1, #Saundo2DB do
    				buffs[i] = Saundo2DB[i]
    			end
    		end
    	end
    	elseif event == "PLAYER_LOGOUT" then
    		for i=1, #buffs do
    			wipe(Saundo2DB)
    			Saundo2DB[i] = buffs[i]
    		end
    	end
            elseif event == "PLAYER_LOGIN" then
    		self:Initialize()
    	end
    end
    

    4) I relog and the variables are gone ??? :(

    Quote from myrrodin »

    -- where are you registering the Event? your OnEvent isn't doing anything


    function Saundo2:Initialize()
    	self:RegisterEvent ("ADDON_LOADED")
    	self:RegisterEvent ("PLAYER_LOGOUT")
    end
    


    Saundo2:SetScript("OnEvent", Saundo2.OnEvent)
    
    if IsLoggedIn() then
    	Saundo2:Initialize()
    else
    	Saundo2:RegisterEvent("PLAYER_LOGIN")
    end
    


    I hope I didn't miss any part of code needed this time :p
    Posted in: AddOn HELP!
  • 0

    posted a message on savedVariables ?
    Ty guyz I did some change according to ur suggestions ... now in the WTF folder I can find my variable but that's it cus it equals nil, it doesn't take the table values

    local Saundo2 = CreateFrame ("Frame", "Saundo2", UIParent)
    
    local buffs ={} --table with buff that must be tracked
    
    function Saundo2:OnEvent(event, addOn)
    	if event == "ADDON_LOADED" and addOn == "Saundo2" then
    		if Saundo2DB == nil then
    			Saundo2DB={}
    		else 
    			for i=1, #Saundo2DB do
    				buffs[i]=Saundo2DB[i]
    			end
    		end
    	end
    	if event == "PLAYER_LOGOUT" then
    		for i=1, #buffs do
    			wipe(Saundo2DB)
    			Saundo2DB[i]=buffs[i]
    		end
    	end
    --there is some other event here but they're about combat and don't
    --modify these 2 tables 
    end
    
    Posted in: AddOn HELP!
  • 0

    posted a message on savedVariables ?
    hey again :)... after solving the previous problem now I've an addon that does pretty much what I wanted but for some reason I can't manage to convince it to save my settings, it is not even creating the file in the WTF...
    I want to save a table as savedVariable... while trying to understand the problem I tried just to save a string ... well with the string it creates the .lua file in the WTF but with my table, that's what I need, it doesn't seem to do anything... can it be related to the fact that is the user the one who fills the table using the slashcommands?... how do I do in this case?

    here's the code:

    local Saundo2 = CreateFrame ("Frame", "Saundo2", UIParent)
    
    local buffs ={} --table with buff that must be tracked
    
    


    SLASH_SAUNDOADD1= "/saundoAdd"
    SlashCmdList["SAUNDOADD"] = function (msg)
    	table.insert(buffs, msg)
    	for i=1, #buffs do
    		print ("Saundo2 buff tracked "..i..buffs[i])
    	end
    end
    


    these are the parts of the code where I modify the content of my table

    here's the toc:

    ## Title: Saundo2
    ## Notes: Associate a sound to your buff fade out
    ## SavedVariables: buffs
    
    
    Saundo2.lua
    Saundo2.xml
    


    pls lemme know i should post more code to make the problem clear
    :confused:
    Posted in: AddOn HELP!
  • 0

    posted a message on assign value to a matrix... how to?
    TY!!:) ... 4 the help and the rapidity... I solved the problem, at least I think cus now it seems to work... it looks like this:

    local alarm = 0;
    local notify = {} 
    function Saundo2_CheckBuff()
    	wipe(notify)
    	for idx, value in ipairs (buffs) do
    		notify[idx] = { }
    		table.insert(notify[idx], 1, value);
    		table.insert(notify[idx], 2, 0);
    		table.insert(notify[idx], 3, 0);
    		table.insert(notify[idx], 4, 0);
    		for j=1,40 do
    			local name, _, _, _, _, duration, expirationTime = UnitAura("player", j)
    			if (name and duration ~= nil) then
    				if (name == value) then
    				local alarm = 1;
    					notify[idx]={name, duration, expirationTime, alarm}
    					table.insert(notify, notify[idx]);
    				end
    			end
    		end
    	end
    	return notify;
    end
    


    tyty again
    Posted in: AddOn HELP!
  • 0

    posted a message on assign value to a matrix... how to?
    Hey all, I want to keep trace of some buff.. to do that I created a table with the buffs I want to track and then I tryed to check all the active buffs on the player to see if the ones I'm intrested in are there.

    After that I would like to store the information about the active ones in another table that should contain all the active buffs that I'm looking for, their duration, expiration time and something else...

    here is the code:

    local buffs ={}
    table.insert(buffs, "Inquisition")--just for test it
    


    I'm adding the buff manually in the table here just to test it


    function Saundo2_CheckBuff()
    	local notify = {} 
    	for i=1, #buffs do
    		notify[i] = { 
    		["notify_name"]=0,
    		["notify_duration"]=0,
    		["notify_expirationTime"]=0,
    		["notify_alarm"]=0,
    		["notify_sound"]=0
    	  }	 
    		for j=1,40 do
    			local name, _, _, _, _, duration, expirationTime = UnitAura("player", j)
    			if (name and duration ~= nil) then
    				for idx, value in ipairs (buffs) do
    					if (name == value) then
    						table.insert(notify, notify[i]["notify_name"], name);
    						table.insert(notify, notify[i]["notify_duration"], duration); --this is my line 50
    						table.insert(notify, notify[i]["notify_expirationTime"], expirationTime);
    						table.insert(notify, notify[i]["notify_alarm"], 1);
    						--table.insert(notify[i]["notify_sound"], sound);
    					end
    				end
    			end
    		end
    	end
    	return notify;
    end
    


    when the other functions call checkBuff() no matter how I try to fix it I can't never manage to have the buffs at their place in the table/matrix. what am i doing wrong?

    that's the error I get: 29x Saundo2\Saundo2.lua:50: attempt to index field '?' (a nil value)
    NB I added a comment close the one that is my line 50 in the code, the weirdest thing it's that line 49 that's almost the same doesn't give me the error but it doesn't seem to work anyway...
    Posted in: AddOn HELP!
  • To post a comment, please or register a new account.