UPDATE2: I’ve figure out the problem myself. For people who want to know the solution and cause of problem:
Briefly:
- Lua has a limit per function, each function can only call up to 60 upvalues.
- Upvalues are variables not stored in the same scope as the function
- Using a table/array will count as 1 upvalue (i use more tables now [
For more information:
http://developer.anscamobile.com/forum/2011/04/24/error-more-60-upvalues
http://www.lua.org/pil/6.1.html
UPDATE: I found the problem. It says i have more than 60 upvalues in my function. How do i solve this? Anything below are
I am encountering a weird bug!
Here is the issue:
I have 2 variable, aa and bb that stores Numbers. When i i use print(aa) and print(bb) in that particular function it will cause a runtime error. If i comment either one of them out, it won’t crash. Any ideas what is possibly causing this?
** using both in other functions works perfectly
[lua]–example 1
local function a()
print(aa) – works
end[/lua]
[lua]–example 2
local function a()
print(bb) – works
end[/lua]
[lua]–example 3
local function a() – runtime error, game won’t start, black screen, director error 440
print(aa)
print(bb)
end[/lua]
[lua]–example 4
local function b() – Other functions: works perfectly
print(aa)
print(bb)
end
local function c()
print(aa)
print(bb)
end[/lua]
This is really weird. I don’t know what is causing it. I really want to know the solution. I can print every other variables just fine in function a(). But just not that 2 together which basically stores only Numbers.
** this came into my mind. Is there a local variable limit in corona sdk or director class per .lua file? I have 121 local variables in my game.lua
** i tried creating new variables but i can’t call it in that function anymore. But still able to call in other functions. Is there a limit for functions? [import]uid: 74723 topic_id: 13127 reply_id: 313127[/import]