WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   MoP Beta archived threads (https://www.wowinterface.com/forums/forumdisplay.php?f=162)
-   -   Have they changed how SendChatMessage works? (https://www.wowinterface.com/forums/showthread.php?t=43599)

Coote 06-30-12 05:22 AM

Have they changed how SendChatMessage works?
 
Currently on live
Code:

SendChatMessage(msg[random(trash)], "SAY", NIL)
works perfectly fine, but on the beta servers, I'm getting errors.

Code:

Message: Interface\AddOns\AfterKill\AfterKill.lua:29: attempt to index global 'msg' (a nil value)
Time: 06/30/12 06:05:18
Count: 1
Stack: Interface\AddOns\AfterKill\AfterKill.lua:29: in function <Interface\AddOns\AfterKill\AfterKill.lua:27>


That particular line of code is the only one that's throwing errors. I've tested with that line removed, and everything else works perfectly. I've tried looking and seeing what changed, but finding nothing. Undocumented change, or just me being noobier than usual?

Xrystal 06-30-12 05:34 AM

One thing to do is find out where your msg table is set as it thinks it is null at present

It doesn't look like SendChatMessage function itself has changed.
SendChatMessage(msg, "WHISPER", editBox.languageID, lastTell);
Is an example of what is in the latest beta version of ChatFrame.lua

Coote 06-30-12 05:49 AM

Thanks. I fixed it by changing up my table a bit, and the message.

Going from
Code:

local trash = {
        "test 1",
        "test 2",
        "test 3",
}

SendChatMessage(msg[random(trash)], "SAY", NIL)

to
Code:

local trash = {
        [1] = "test 1",
        [2] = "test 2",
        [3] = "test 3",
}

SendChatMessage(trash[random(1,3)], "SAY", NIL)

fixed it up.

Lombra 06-30-12 07:00 AM

The table is identical to what you had before, however you're now actually referring to that table and not some other, non existant one. You were also trying to pass the table as an argument to random, rather than its length.

This should work:
Code:

local trash = {
        "test 1",
        "test 2",
        "test 3",
}

SendChatMessage(trash[random(#trash)], "SAY")

(also, no need to explicitly pass nil since it's the last argument)

Seerah 06-30-12 12:21 PM

For future reference, if the function were changed, the error message would say that you were using it incorrectly. (for example "TipTop-2.9.4\\tiptop-2.9.4.lua:409: Usage: GetSpecializationInfo(specIndex[, isInspect[, isPet]]])")

Your error was just saying that the argument you passed to the function was nil and it couldn't do anything with it. This could be from typos, clearing the variable, scope issues, etc.


All times are GMT -6. The time now is 03:57 PM.

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