function "has more then 60 upvalues"
It seems my OnUpdate function has to be pretty small or else the whole addon fails to load with the above error. How do I solve this (besides a horribly hackish (and slow) solution like making tons of frames with OnEvent functions)? Please help! :confused:
|
Never encountered your message, but it seems like you're using a lot (over 60) of local variables which are then accessed by your OnUpdate-function which causes trouble.
As you create a lot of frames, you could try to store them in tables rather than locals - this would basically eliminate a lot of your upvalues as you're only accessing one in your function(the table). In general, it would be more helpful to see some of your code or a description how you're creating/storing the frames. :) |
Quote:
There is just one frame, for the OnUpdate function. It's a command based addon. Also, arrays and globals are to slow and use to much meory.. and locals in the OnUpdate function lose all of their data on each frame.. so I need to know how to do it this way, with more then 60. Please help. Here is some pseudo code; Code:
|
You could try to split your OnUpdate-function into several smaller function which are called from the OnUpdate-function so that less upvalues are used in one single function.
Sorry if it doesn't help, but I'm just wondering why you need to do calculations with over 60 variables on every update. Maybe if you describe a bit what you want to achieve with the functions, we can come up with another solution. Seems like a dilemma to me: accessing lots of upvalues without using tables/global environment while Lua can only handle up to 60. Can't think of alternatives besides storing them somewhere else at the cost of speed or splitting up the function. |
Quote:
I still wish there was a way to fix the 60 upvalue limit though. |
Quote:
And what splitting into functions does is it scopes parts of OnUpdate. General info on scope: http://en.wikipedia.org/wiki/Variable_scoping |
Quote:
|
What is wrong with this? It says that foo is global, and that it's nil.. when obviously it should be local (they all should), and not nil..
Code:
local frame=CreateFrame("Frame") I'm really starting to hate lua with a passion. To bad there are no alternatives. :( |
Quote:
|
Quote:
|
Quote:
The overhead from locals is also far from nuts. |
Quote:
Try separating the function out to test functionality better: Code:
local f = CreateFrame("Blah") |
Quote:
Quote:
Yes text is supposed to be overwritten in the example.. and it's supposed to be a local. BTW your example is broken. Even after fixing the CreateFrame, it says "attempt to call function 'testfunction', a nil value" and I don't know how to fix that, since it's defined right there clear as day. :s Edit: fixed it by moving it over the OnUpdate.. and now it says it's trying to concatenate foo as a GLOBAL, and that it's NIL. Just like in my example. :( |
At first blush this looks like a scope issue.
http://www.lua.org/manual/5.1/manual.html#2.6 I'm a bit curious of the need for 60 separate local variables being accessed on each frame update. You also should take care of creating new locals in each update as well, as it appears that your goal is extreme performance. Though I would offer the advice that getting it working with a table at first and then going back and optimizing the most often executed code wouldntield better or at least more timely results. Just my $.02. I could be wrong. |
Sorry, wasn't meant to be a full blown working example, just kind of a guide to help ya debug. It's 1:30am and I'm tired. :p
|
Quote:
Guess I should have explained this in the first post. I thought I did though. Sorry. P.S. It does work as tables but is to slow. Quote:
|
Quote:
1) check for global foo Code:
if not foo then... Code:
local foo = "foo" Code:
foo = NIL Code:
text = foo..bar Also, I realize after looking back that the function would have to go before the scripts (which is always a good practice to maintain, for the record), but you posted the fix already. |
Quote:
|
You can't check for a local variable outside it's block. You'd have to rename the global foo as something else and pass the data out to it.
Code:
function testfunction(frame) |
Quote:
If not, then all I can think of is updating the lua package in WoW to one that works better.. I don't know how to do this though, and it might be frowned upon by Blizzard (can anyone confirm this?). |
All times are GMT -6. The time now is 02:09 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI