function expected instead of nil
Hello,
i run into following issue: Code:
when im trying to run this code: Code:
I'm guessing that it has something to do with "IsOnMount()" not receiving and/or the EVENT_MANAGER not giving away its variables - in this case the EventID and the Boolean value. This is my first experience in coding in lua, so im glad for any help I can get. cheers |
You have a stray space after "EVENT_MANAGER:"
|
Are you using a text editor that shows line counters? (Or do you have that setting turned on?) Line numbers can be very helpful for fixing bugs, especially in larger programs. For example, the lua error you encountered tells you that the error is on line 5, so you could just look at that particular line and figure out what's wrong.
|
Quote:
greets. |
Quote:
It seems pretty easy to use :D |
Quote:
Is it telling the EVENT_MANAGER where to look for the mentioned function? As far as i haven understood it, you can call different variables from other functions with e.g differentFunctionNName.VariableName. Does self.VariableName equal variableName? Is this in some sense comparable to a pointer from c? (Thatīs the only programming language i have basic knowledge about) |
What Votan means is that when you declare the variable (ADDON_NAME = "Test") you should put local first (local ADDON_NAME = "Test")
That makes it so that ADDON_NAME is only available to code within that file. So if some other addon calls ADDON_NAME, then it will be nil. self.variable name is not generally defined. If you have a table, the table might have a field called variableName, and then it would be defined, but in all other cases it will not be defined. (and in fact, if self is not a table you will get a lua error - 'Attempt to index a non table variable') You also cannot do functionName.variableName. Local variables within a function are unavailable outside of it, and global variables within a function will be available anywhere simply with variableName. I would suggest reading some lua tutorials about scope. |
I usually create a table for my addons name:
Code:
AM.name = "AuraMastery" |
My rule of thumb has always been that most addons should be in the local scope, but if yours is one that is likely to be incorporated into another (such as MM), then use the global scope. As long as you use a properly unique global name you shouldn't run into issues, however, take CraftStore and Crafting Stations: if they both used global CS, you'd likely run into some issues.
|
All times are GMT -6. The time now is 01:47 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI