Tables and storyboard

Hello everyone

I have a table that stores certain images.

yourTable={}

I’m working with storyboard…

We have put all display object in a group. 

The issue I’m having is that  I can’t insert a table into a group. Is there a work around for getting tables to work with storyboard

I get this error [quote] table expected. If this is function call you might have used . instead of :

I’m confused. Why do you want to put a table into the group? A table is not a display object, it is an associative array. Do you mean you want to put all of the objects that are already inside the table into a group? If so just loop through the table and insert each item into the group: for i =1, #myTable do group:insert(my table[i]) end

edit: nvm i fixed it.

I’m going to re-paste your last post, before it was edited. It’s really not helpful if someone has the same problem as you, finds this topic, and the only answer they get is “nvm i fixed it”.

thanks for the reply!

I’ve tried that!

At the line 

MyGroup:insert(mytab[i])

I’m getting the error: 

Table Expect. If this is function call you might have used . instead of :

This is my 

MyTable = {‘Big1’, ‘Big2’,Big3}

here is my spawn (code is if helps)

function spawnBoxes()   local YanNr = math.random(1, 3)  local Number   –   if (MyTable[YanNr]==“Big1”) then          Number = display.newImage(“big1.png”)    Number.name = “Big 1”    print(“Number1 was printed”)       Number.x = math.random(_W-140, _W+150)   Number.y = 10 --etc other boxes

I’m trying to insert those objects that I have in the table into the scene group. For Storyboard. So I can purge when I move to a different screen.

I’m going to go over your post to show where things could be incorrect. I’m not trying to be overly harsh, but some of these points are things that beginners could easily do, and it doesn’t help anyone for the content to be removed from a forum post.

First:

MyGroup:insert(mytab[i])

I’m going to assume that you already had created a display.newGroup() called “MyGroup”, and a table called “mytab”. If not, then that was one problem, trying to reference a table that didn’t exist. Likewise, I presume the insertion was being performed in a loop, though this wasn’t shown in your post.

Next you showed your table:

MyTable = {'Big1', 'Big2',Big3}

It contains 2 strings, and a variable called Big3. Again I presume this is a typo. 

Your spawn function creates objects called Number, but as far as I could see does not insert them into the table called “mytab”. The objects are also not added to any group individually, so they remain “sceneless” (i.e. if you change scene they will just stay on screen).

 I deleted it because the solution you gave me didn’t really work for me. My solution was a bit different from what you had posted.

There was really no point, in me posting my possibly bad code.

Again I appreciate the help.

I’m confused. Why do you want to put a table into the group? A table is not a display object, it is an associative array. Do you mean you want to put all of the objects that are already inside the table into a group? If so just loop through the table and insert each item into the group: for i =1, #myTable do group:insert(my table[i]) end

edit: nvm i fixed it.

I’m going to re-paste your last post, before it was edited. It’s really not helpful if someone has the same problem as you, finds this topic, and the only answer they get is “nvm i fixed it”.

thanks for the reply!

I’ve tried that!

At the line 

MyGroup:insert(mytab[i])

I’m getting the error: 

Table Expect. If this is function call you might have used . instead of :

This is my 

MyTable = {‘Big1’, ‘Big2’,Big3}

here is my spawn (code is if helps)

function spawnBoxes()   local YanNr = math.random(1, 3)  local Number   –   if (MyTable[YanNr]==“Big1”) then          Number = display.newImage(“big1.png”)    Number.name = “Big 1”    print(“Number1 was printed”)       Number.x = math.random(_W-140, _W+150)   Number.y = 10 --etc other boxes

I’m trying to insert those objects that I have in the table into the scene group. For Storyboard. So I can purge when I move to a different screen.

I’m going to go over your post to show where things could be incorrect. I’m not trying to be overly harsh, but some of these points are things that beginners could easily do, and it doesn’t help anyone for the content to be removed from a forum post.

First:

MyGroup:insert(mytab[i])

I’m going to assume that you already had created a display.newGroup() called “MyGroup”, and a table called “mytab”. If not, then that was one problem, trying to reference a table that didn’t exist. Likewise, I presume the insertion was being performed in a loop, though this wasn’t shown in your post.

Next you showed your table:

MyTable = {'Big1', 'Big2',Big3}

It contains 2 strings, and a variable called Big3. Again I presume this is a typo. 

Your spawn function creates objects called Number, but as far as I could see does not insert them into the table called “mytab”. The objects are also not added to any group individually, so they remain “sceneless” (i.e. if you change scene they will just stay on screen).

 I deleted it because the solution you gave me didn’t really work for me. My solution was a bit different from what you had posted.

There was really no point, in me posting my possibly bad code.

Again I appreciate the help.