These days I am working on a small example/project of myself. What I am doing is creating n
set of random strings of variable lengths. Here is what I want to obtain:
- Two names of length from 3 to 25 characters.
- A message ranging from 40 to 300 characters.
In my C example, I create a struct
and kept inserting into this table as list. In my LUA example, I want a nested table like this:
tTableName = {
[1] = {
"To" = "Name 1",
"From" = "Name 2",
"Message" = "The first message generated"
}
[2] = {
"To" = "Name 3",
"From" = "Name 4",
"Message" = "The second message generated"
}
}
So, basically my structure goes like this:
struct PM {
char *sTo, *sFrom, *sMessage;
} PMs;
I want a similar structure/table in LUA so that I can use a table.insert
method. I currently am doing it like this:
tTempTable = {
"To" = "Name 1",
"From" = "Name 2",
"Message" = "The first message generated"
}
table.insert( tTableName, tTempTable )
but I am thinking it as a wastage of a lot of processing time. Currently I am only generating a sample of 30 such PMs; but later I shall be generating *1000*s of them. Please advice.