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).