"global EnableMouse is nil"
lua Code:
Code:
Message: Interface\AddOns\CFM\CFM_GUI.lua:1285: attempt to call global 'EnableMouse' (a nil value) |
those are not functions, they're methods. i would expect, tho i'm not sure, that this would work:
func = "EnableMouse" ... fame[func](frame, true/false) assuming that bliz widget methods act like normal methods... also, if you set X = func() then you're executing the function func and assigning x to the result as opposed to X = func which would assign X to be a "pointer" to the function itself (so X() would be the same as func()). not that this would work in this case... |
Hi ChaosInc,
Putting parentheses after the function name makes Lua call the function. If you want to assign the function itself to a variable, rather than its return values, you just write the function name. If it’s a method name, rather than a standalone function, then you usually have to write it as a string, in quotes, so you can look it up in the object table later. This would work: Code:
-- disable mouse stuffs Code:
CFM_ToggleSetting( self, "EnableMouse" ) |
Quote:
|
You can’t do func = EnableMouse because there isn’t any function named EnableMouse. Frame-type objects do have an EnableMouse method, but it’s only accessible through the object, not as a global function. You have to store it as a string, and do a table lookup to get the method.
I’m also not sure what you meant by not being able to use the second example with multiple buttons. The only difference between it and the first example is that instead of passing along “clamp” and then having extra code to turn “clamp” into “SetClampedToScreen”, you just pass along “SetClampedToScreen” directly. There’s nothing in there that ties it to a specific button or frame. :confused: |
Using functions:
Code:
function CFM_ToggleSetting(self, prop) Using methods: Code:
function CFM_ToggleSetting(self, prop) |
Quote:
|
All times are GMT -6. The time now is 11:35 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI