WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Help with Error (https://www.wowinterface.com/forums/showthread.php?t=40381)

tinyu 06-03-11 12:31 PM

Help with Error
 
Hey guys im working on a mod i used to maintane way back when (last version was 30100)

i got it 98% working still one error and a few tweeks to do yet

anyway im getting a error and i cant figure out how to fix it

Here's the error

Code:

Date: 2011-06-04 03:45:06
ID: 1
Error occured in: Global
Count: 1
Message: ..\AddOns\SetWrangler\SetWrangler.lua line 718:
  attempt to perform arithmetic on local 'elapse' (a nil value)
Debug:
  [C]: ?
  SetWrangler\SetWrangler.lua:718: SetWrangler_OnUpdate()
  [string "*:OnUpdate"]:1:
      [string "*:OnUpdate"]:1
AddOns:
  Swatter, v5.12.5165 (QuirkyKiwi)
  SetWrangler, v
  Titan, v5.0.5.40100 - Revision 519
  BlizRuntimeLib_enUS v4.1.0.40100 <us>
  (ck=81)

Heres the code

from the Lua (line 718 is highlighted)
Code:

function SetWrangler_OnUpdate(self, elapse)
    if (gDoCacheTimer == 1) then
        --dout("Update: "..gCacheTimer);
        gCacheTimer = gCacheTimer + elapse;

        if (gCacheTimer > SW_CACHE_TIMER) then
            gDoCacheTimer = 0;
            gCacheAttempts = gCacheAttempts + 1;

            if (gCacheAttempts <= SW_MAX_CACHE_ATTEMPTS) then
                gCacheData.callback(gSelectedSet,1);
            else
                nameLocationText:SetText("Failed to load link...");
            end
        end
    end   
end

from the xml
Code:

            <OnUpdate>
                SetWrangler_OnUpdate(self, elapse);
            </OnUpdate>

thanks for any and all help.

Ailae 06-03-11 01:05 PM

Silly question perhaps, but when declaring it via xml does it have to literally be elapsed for it to work?

And are there any errors in FrameXML.log?

tinyu 06-04-11 05:05 AM

Quote:

Originally Posted by Ailae (Post 238696)
Silly question perhaps, but when declaring it via xml does it have to literally be elapsed for it to work?

Im not sure about that i didnt write the mod im just keeping it going where i can.

Quote:

Originally Posted by Ailae (Post 238696)
And are there any errors in FrameXML.log?

No its not producing any errors in the FrameXML.log.

p3lim 06-04-11 09:51 AM

<OnUpdate function="SetWrangler_OnUpdate"/>

humfras 06-04-11 02:33 PM

Code:

<OnUpdate>
                SetWrangler_OnUpdate(self, arg1);
            </OnUpdate>

Should make it work because the argument "arg1" will be passed on.
Before, "elapse" was nil because the OnUpdate function has no argument/variable called 'elapse' but a argument called 'arg1'.



Quote:

Originally Posted by p3lim (Post 238775)
<OnUpdate function="SetWrangler_OnUpdate"/>

This will also suit your needs because this will call the SetWrangler_OnUpdate function with all parsed keys.
e.g.: SetWrangler_OnEvent(self, event, ...)
'...' contains all following parameters/arguments.


LINKS:
http://www.wowpedia.org/UIHANDLER_OnUpdate
http://www.wowpedia.org/Using_OnUpdate_correctly

tinyu 06-04-11 08:51 PM

1 Attachment(s)
i tried both still getting the error, i added the mod im working on if anyone wants to take a look at it.

haste 06-05-11 04:30 AM

Your original code would have worked if you had written elapsed instead of elapse. The suggestion p3lim came with will also work, but in the zip above you have defined your OnUpdate handler twice.

The first suggestion humfras came with isn't correct, as arg1 doesn't exist anymore. This is also your current second definition of OnUpdate, so it overrides the correct one.

Also, I would recommend you to tell people how they can recreate the error, especially when you hand them a couple of thousand lines of Lua and XML. :)

tinyu 06-05-11 11:12 AM

ok i got the error sorted thanks for the help, the next problem is that when you click the link button no items are linked to the selected channel.

humfras 06-05-11 02:08 PM

Quote:

Originally Posted by haste (Post 238837)
The first suggestion humfras came with isn't correct, as arg1 doesn't exist anymore. This is also your current second definition of OnUpdate, so it overrides the correct one.

I had written 'elapsed' based on my memory but took a look @wowpedia to ensure and it stated 'arg1'.:rolleyes:

Rilgamon 06-05-11 02:22 PM

Quote:

Originally Posted by humfras (Post 238858)
I had written 'elapsed' based on my memory but took a look @wowpedia to ensure and it stated 'arg1'.:rolleyes:

And I hope you have corrected in the wiki ... :P


All times are GMT -6. The time now is 11:55 PM.

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