I have a table of units with their sprite information in it. I want to spawn the sprites, based on their id, but I get an error. I’ve tried looking on the Lua and Corona documentation, as well as in the forums and Stack Overflow, but I could not find a question related to this.
The error I am getting is <name> expected near ‘…’:
characters. ..characters.units[k].id.. walking.sheet --Line with error
I don’t know how to fix the syntax. Thanks in advance!
Again, the problem is you’re metaphorically trying to build a car engine before you’ve learnt to build an electrical circuit.
All I can tell you is you can’t have ‘characters.’ and then a space. The error is telling you it is expecting a ‘name’, or in other words a ‘child’ of characters, but it finds a space, and then the ‘…’, neither or which it wants.
In the future if you do something like this and it doesn’t work:
characters. ..characters.units[k].id.. walking.sheet --Line with error
debug it on your own by verifying the parts:
-- Print the parts to make sure they are all valid print( "Parts", characters, k, walking ) -- Then start combining, one level at a time, till you find the problem print( "Combined", characters.units, walking.sheet ) print( "Combined", characters.units[k] ) print( "Combined", characters.units[k].id ) characters. ..characters.units[k].id.. walking.sheet --Line with error
Again, the problem is you’re metaphorically trying to build a car engine before you’ve learnt to build an electrical circuit.
All I can tell you is you can’t have ‘characters.’ and then a space. The error is telling you it is expecting a ‘name’, or in other words a ‘child’ of characters, but it finds a space, and then the ‘…’, neither or which it wants.
In the future if you do something like this and it doesn’t work:
characters. ..characters.units[k].id.. walking.sheet --Line with error
debug it on your own by verifying the parts:
-- Print the parts to make sure they are all valid print( "Parts", characters, k, walking ) -- Then start combining, one level at a time, till you find the problem print( "Combined", characters.units, walking.sheet ) print( "Combined", characters.units[k] ) print( "Combined", characters.units[k].id ) characters. ..characters.units[k].id.. walking.sheet --Line with error