Local Variable Limit (100) - Any Way Around It?

Thanks Naomi! Yes, I learned the hard way that the last 10% of the app takes 90% of the time! Don’t forget to put a note on the Corona Indies Facebook page when you ready to ask for reviews. It will be my pleasure to review your new game!

Mo [import]uid: 100814 topic_id: 33601 reply_id: 133635[/import]

[quote=“Naomi,post:2,topic:308826”]

Hey, @nate2, you could try grouping your local variables into tables. That’s how I do it with bazillions of variables I need in my game. So instead of adding each variables as

local myVariable1

,

local myVariable2

, etc., I’d do something like the following for all buttons and images, for example.

-- by doing the following, I end up using 2 (instead of 6 for example): local btn = {} btn.goBack btn.goHome btn.goNext --etc. etc. local img = {} img.background img.image1 img.image2 img.image3 -- etc. etc.

I hope this helps. (BTW, I thought the limit was 200…?) Naomi
[import]uid: 67217 topic_id: 33601 reply_id: 133578[/import] [/quote]

Hi Naomi I have tried to use this but i am getting error  when i tried this

 

 

local levelTen = {}

levelTen.image1 // error shows here in this line

levelTen.image2

levelTen.image3

levelTen.image1gold

levelTen.image2gold

levelTen.image3gold

 

 

 

errror::

 

com.MYDevelopers.LuaSupport.ParseTree.ParseException: Encountered " "levelTen “” at line 73, column 1.

Was expecting one of:

    “:” …

    “.” …

    “(” …

    “{” …

    “[” …

    <sin_quote> …</sin_quote>

    <dbl_quote> …</dbl_quote>

    “[” …

    “.” …

    “:” …

    “(” …

    “{” …

    <sin_quote> …</sin_quote>

    <dbl_quote> …</dbl_quote>

@asad

 

You have to assign something to those table variables - i.e a value, a string, image, another table. You cannot and do not need to define them ahead of time like with top-level local variables.

 

This is ok:

 

[lua]

 

local myImage – myImage is defined as a nil local variable and you can add the image later on

 

[/lua]

 

This isn’t:

 

 

[lua]

 

local images = {}

 

images.myImage

 

[/lua]

 

This will work:

 

 

[lua]

 

local images = {}

 

images.myImage = display.newImageRect(“image.png”,50,50)

 

[/lua]

Yup, as @nick_sherman says, I’d only add each btn (such as btn.goBack) when I’m ready to create the button.  Same is true with images and other grouped variables.  And I like it that way, especially since I don’t even need to plan how many buttons or images I’d need nor would I need to remember to list them up top.  I’m sorry I didn’t make it clear.

 

Naomi

[quote=“Naomi,post:12,topic:308826”]

Hey, @nate2, you could try grouping your local variables into tables. That’s how I do it with bazillions of variables I need in my game. So instead of adding each variables as

local myVariable1

,

local myVariable2

, etc., I’d do something like the following for all buttons and images, for example.

-- by doing the following, I end up using 2 (instead of 6 for example): local btn = {} btn.goBack btn.goHome btn.goNext --etc. etc. local img = {} img.background img.image1 img.image2 img.image3 -- etc. etc.

I hope this helps. (BTW, I thought the limit was 200…?) Naomi
[import]uid: 67217 topic_id: 33601 reply_id: 133578[/import] [/quote]

Hi Naomi I have tried to use this but i am getting error  when i tried this

 

 

local levelTen = {}

levelTen.image1 // error shows here in this line

levelTen.image2

levelTen.image3

levelTen.image1gold

levelTen.image2gold

levelTen.image3gold

 

 

 

errror::

 

com.MYDevelopers.LuaSupport.ParseTree.ParseException: Encountered " "levelTen “” at line 73, column 1.

Was expecting one of:

    “:” …

    “.” …

    “(” …

    “{” …

    “[” …

    <sin_quote> …</sin_quote>

    <dbl_quote> …</dbl_quote>

    “[” …

    “.” …

    “:” …

    “(” …

    “{” …

    <sin_quote> …</sin_quote>

    <dbl_quote> …</dbl_quote>

@asad

 

You have to assign something to those table variables - i.e a value, a string, image, another table. You cannot and do not need to define them ahead of time like with top-level local variables.

 

This is ok:

 

[lua]

 

local myImage – myImage is defined as a nil local variable and you can add the image later on

 

[/lua]

 

This isn’t:

 

 

[lua]

 

local images = {}

 

images.myImage

 

[/lua]

 

This will work:

 

 

[lua]

 

local images = {}

 

images.myImage = display.newImageRect(“image.png”,50,50)

 

[/lua]

Yup, as @nick_sherman says, I’d only add each btn (such as btn.goBack) when I’m ready to create the button.  Same is true with images and other grouped variables.  And I like it that way, especially since I don’t even need to plan how many buttons or images I’d need nor would I need to remember to list them up top.  I’m sorry I didn’t make it clear.

 

Naomi