If I were to do this, how would I handle table variable accesses from within the table scripts?
For example, say I create the following script file:
MySprite = {}
MySprite.state = 0
MySprite.speed = 3
MySprite.update = function()
MySprite.state = MySprite.state + 1
MySprite.speed = MySprite.speed * 2
end
And several entities use this script file, so I create a new copy of this table for each of them. I'll probably be generating names for these new tables based on entity ID or something like that, so now I have the following tables: entity1, entity2, entity3. I call entity1.update(), entity2.update(), and entity3.update() from my engine every frame to update these entities. But nothing will happen, since each entity will be updating MySprite.state and MySprite.speed rather than their own variables, right?
I'm sure I"m missing an obvious way to do this, or perhaps I'm simply attacking the problem from the wrong angle.