Thread Tools Display Modes
04-17-09, 05:21 AM   #1
Azul
Banned
 
Azul's Avatar
Join Date: Apr 2009
Posts: 19
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!

Last edited by Azul : 04-17-09 at 05:23 AM.
 
04-17-09, 07:07 AM   #2
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
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.
__________________
« Website | GitHub »

Oh hai!
 
04-17-09, 07:20 AM   #3
Azul
Banned
 
Azul's Avatar
Join Date: Apr 2009
Posts: 19
Originally Posted by Cargor View Post
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.
Thanks.

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:
local Var,AnotherVar,Foo,Bar,Etc=1,"blah blah blah",GetTime(),nil
local frame=CreateFrame("Frame")

frame:SetScript("OnUpdate",function(self)

some stuff that uses Var
some stuff that uses AnotherVar
some stuff that uses Foo
some stuff that doesn't use any of them
some stuff that uses Bar
some stuff that uses Etc

end)

SlashCmdList["somecmd"] = function (arg1)
	if Etc then
		Etc=nil
	else
		Etc=1
	end
end
SLASH_somecmd1="/justacmd"
SlashCmdList["anothercmd"] = function (arg1)
	AnotherVar=arg1
end
SLASH_anothercmd1="/justanothercmd"
In this little example there are 5 variables used. If I use a lot then I get the error and it won't run.

Last edited by Azul : 04-17-09 at 07:36 AM.
 
04-17-09, 07:50 AM   #4
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
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.
__________________
« Website | GitHub »

Oh hai!
 
04-17-09, 08:01 AM   #5
Azul
Banned
 
Azul's Avatar
Join Date: Apr 2009
Posts: 19
Originally Posted by Cargor View Post
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.
Thank you. I split them and the performance wasn't as bad as the other ways.


I still wish there was a way to fix the 60 upvalue limit though.
 
04-17-09, 08:41 AM   #6
Nuckin
is laughing at you
 
Nuckin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 58
Originally Posted by Azul View Post
Thank you. I split them and the performance wasn't as bad as the other ways.


I still wish there was a way to fix the 60 upvalue limit though.
the 60-up error is there to try and keep you from eating up all the memory

And what splitting into functions does is it scopes parts of OnUpdate.
General info on scope: http://en.wikipedia.org/wiki/Variable_scoping
__________________
SELECT * FROM users WHERE clue > 0;
0 rows returned.
 

WoWInterface » Developer Discussions » Lua/XML Help » function "has more then 60 upvalues"


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off