WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   concatenate field error but don't know why (https://www.wowinterface.com/forums/showthread.php?t=41219)

Xeonkryptos 08-20-11 04:52 AM

concatenate field error but don't know why
 
i get the error: attempt to concatenate field (a nil value) but in other parts of my addon it works perfectly...

i initialized my global variable:
Code:

ExecuteSoundTable = {playerDied = "laugh", unitDied = "fatality", executeTime = "finish him", havePost = "hallo post" };
there i don't get any error. in other parts i don't get an error, too.

Code:

elseif (event == "COMBAT_LOG_EVENT_UNFILTERED") then
        local _, subevent,_,_,_,_,_, destguid = ...;
        if (subevent == "UNIT_DIED" and destguid == guid) then
            PlaySoundFile("Interface\\AddOns\\ExecuteSounds\\sounds\\"..ExecuteSoundTable.unitDied..".mp3");
        end

but only here and i don't know why, because the sound file exists and can be played but not within the global variable -.-

Code:

elseif (event == "UPDATE_PENDING_MAIL" and HasNewMail() ~= nil) then
        PlaySoundFile("Interface\\AddOns\\ExecuteSounds\\sounds\\"..ExecuteSoundTable.havePost..".mp3");
    end

i hope you can help me with my concatenate field error... i do the same like in other parts but it doesn't want to work :/

if something i wrote is unclear please ask :) i will try to make it clearer :)

Ketho 08-20-11 10:06 AM

Quote:

Originally Posted by Xeonkryptos (Post 243459)
Code:

ExecuteSoundTable = {playerDied = "laugh", unitDied = "fatality", executeTime = "finish him", havePost = "hallo post" };

Shouldn't it be something like this?
Code:

ExecuteSoundTable = {
        ["playerDied"] = "laugh",
        ["unitDied"] = "fatality",
        ["executeTime"] = "finish him",
        ["havePost"] = "hallo post",
}

btw why does it have to a global? :(

Xeonkryptos 08-20-11 11:25 AM

i tried both possibilities with tables. your code post was the first try to do it and it works but only the havePost variable in the table couldn't be read...

it is a global variable because it should play sounds, not only the defaults one. my thought was that the player can self choose his own sounds if he/she doesn't like the defaults.

and i have a problem with the last variable... ExecuteSoundTable["havePost"] can't be read out... i don't know why because all except the last variable can.

Ailae 08-20-11 12:06 PM

You've made sure the variable is initialized before the event-handler?

I guess it would help if you posted your code in its entirety, via pastebin.com or similar.

p3lim 08-20-11 12:17 PM

Post the whole code and the whole error message (especially which line it errored on helps)

p3lim 08-20-11 12:18 PM

Also don't do 'HasNewMail() ~= nil', just 'HasNewMail()' works

Xeonkryptos 08-20-11 01:15 PM

it is initialized because i can read out the other parts...

hier my whole code: http://pastebin.com/hUN9ZXjm

Ailae 08-20-11 01:29 PM

A quick lock at the code doesn't reveal anything out of the ordinary. I took the liberty to download the released version of your addon and noticed that you use ExecuteSoundTable as your SavedVariables table as well.

This leads me to think that there's a conflict with what's in your ExecuteSoundTable since the savedvars table will be loaded after you have declared the table in your code.

Xeonkryptos 08-20-11 02:48 PM

it is possible that i can solve that with a local variable after loading of the global variable?

p3lim 08-20-11 02:52 PM

Change the name of either the savedvariable or the table, using the same name on those two (local variable or not) will make a conflict no matter what

Phanx 08-20-11 08:55 PM

Quote:

Originally Posted by Ketho (Post 243465)
Shouldn't it be something like this?
Code:

ExecuteSoundTable = {
        ["playerDied"] = "laugh",
        ["unitDied"] = "fatality",
        ["executeTime"] = "finish him",
        ["havePost"] = "hallo post",
}


You only need to bracket/quote table keys if they contain "special" characters like spaces or periods that wouldn't be valid in, say, a variable name. playerDied does not need to be bracketed and quoted as a table key, though if you prefer to always bracket/quote your table keys for style reasons, it won't break anything if you do.


All times are GMT -6. The time now is 03:45 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI