From the LUA guide, I understand that multidimensional arrays need to be declared explicitly, arrays within arrays:
-- In this example, everything in caps is a variable previously declared to act as a "constant"
Cards[PLAYER1] = {};
Cards[PLAYER1][OFF] = {};
Cards[PLAYER1][OFF][LEFT] = {};
Now, in a traditional language, I would create a “default item” of my array, in order to initialize my array. I would basically do:
Cards[PLAYER1][OFF][LEFT][IMAGE] = 0;
Cards[PLAYER1][OFF][LEFT][INDEX] = 0;
Cards[PLAYER1][OFF][LEFT][X] = 0;
Cards[PLAYER1][OFF][LEFT][Y] = 0;
and then copy it over…
Cards[PLAYER1][OFF][CENTER] = Cards[PLAYER1][OFF][LEFT];
Cards[PLAYER1][OFF][RIGHT] = Cards[PLAYER1][OFF][LEFT];
I would actually use a local variable to do the copying over, for efficiency - but that is not the main point of my question.
Here’s the question:
The way I understand it, in LUA, doing that basically makes Cards[PLAYER1][OFF][CENTER] point to Cards[PLAYER1][OFF][LEFT], which means they’re basically not two seperate entries in the array, but simply two pointers to the same entry… So how would I go about doing what I want to do, in LUA
This probably sounds like one hell of a noobish question, but I’m still having a hard time getting my head around some of the concepts of LUA. [import]uid: 4920 topic_id: 1564 reply_id: 301564[/import]