Is a LUA file still limited to 200 local variables?

I’m sure my app could be redesigned to be more efficient but I am about to go past 200 variables. Is this the limit still? I read something about using a module for additional ones I guess I will look it up.

Warren

I saw where richard posted this code to help with the variables:

local this -- variable 1/200 local that -- variable 2/200 that = {} -- now that is a table that.something = 2 -- this is not a new variable against the limit, because it's still part of "that"

So can I use this method for all objects? If I need to put 40 images on for a user to select from can I use the table method for it? Can I do the following?

 that.button1 = widget.newButton{ left = 40, top = HTop, defaultFile = "images/HM21.png", overFile = "images/HM21.png", id = "HM10BLUE", onEvent = handleButtonEvent }

I tried this and it did not work. It did not like the .1 on the first line it was used on. Any suggestions?

local txtText5 txtText5 = {} txtText5.1 = display.newText( "10", 5, 180, native.systemFont, 18 ) txtText5.1:setReferencePoint(display.TopLeftReferencePoint) txtText5.1.x = 53 txtText5.1.y = 200 txtText5.1:setTextColor( 255, 106, 0 ) grpText:insert(txtText5.1)

Replace it with ‘txtText5[1] =’ etc

To elaborate, your strategy is correct and I try to use it as much as possible.

-- A regular table local bunchOfStuff = {} bunchOfStuff[1] = "dude" bunchOfStuff[2] = 32 bunchOfStuff[3] = function() print("Hi") end -- Display objects are also tables! local square = display.newRect(0,0,32,32) square.name = "George" square.like = "Pizza" square.age = 32

As Glitch Games suggests, the trick here is how you use a table.

-- sequential things (numbers) must use [] -- This... local myTable = {} myTable[1] = "hi" myTable[2] = "there" -- Is the same as this... myTable = { "hi", "there" }

These things are sequential, meaning you could search through the table by number.

-- This is not sequential local myTable = {} myTable.heartbeat = 32 myTable.pizza = "pepperoni" -- Another way to do the above would be... local myTable = { heartbeat = 32, pizza = "pepperoni" } -- Numbers are sequential so you can only do this with words. print(#myTable) -- 0! word entries are not sequential so they don't count!

I saw where richard posted this code to help with the variables:

local this -- variable 1/200 local that -- variable 2/200 that = {} -- now that is a table that.something = 2 -- this is not a new variable against the limit, because it's still part of "that"

So can I use this method for all objects? If I need to put 40 images on for a user to select from can I use the table method for it? Can I do the following?

 that.button1 = widget.newButton{ left = 40, top = HTop, defaultFile = "images/HM21.png", overFile = "images/HM21.png", id = "HM10BLUE", onEvent = handleButtonEvent }

I tried this and it did not work. It did not like the .1 on the first line it was used on. Any suggestions?

local txtText5 txtText5 = {} txtText5.1 = display.newText( "10", 5, 180, native.systemFont, 18 ) txtText5.1:setReferencePoint(display.TopLeftReferencePoint) txtText5.1.x = 53 txtText5.1.y = 200 txtText5.1:setTextColor( 255, 106, 0 ) grpText:insert(txtText5.1)

Replace it with ‘txtText5[1] =’ etc

To elaborate, your strategy is correct and I try to use it as much as possible.

-- A regular table local bunchOfStuff = {} bunchOfStuff[1] = "dude" bunchOfStuff[2] = 32 bunchOfStuff[3] = function() print("Hi") end -- Display objects are also tables! local square = display.newRect(0,0,32,32) square.name = "George" square.like = "Pizza" square.age = 32

As Glitch Games suggests, the trick here is how you use a table.

-- sequential things (numbers) must use [] -- This... local myTable = {} myTable[1] = "hi" myTable[2] = "there" -- Is the same as this... myTable = { "hi", "there" }

These things are sequential, meaning you could search through the table by number.

-- This is not sequential local myTable = {} myTable.heartbeat = 32 myTable.pizza = "pepperoni" -- Another way to do the above would be... local myTable = { heartbeat = 32, pizza = "pepperoni" } -- Numbers are sequential so you can only do this with words. print(#myTable) -- 0! word entries are not sequential so they don't count!