Jilani Khaldi wrote:
Hi All,
how to write in Lua something like this:
newtab=table("table_name")
and have a new table (newtab) which has all the data of the table
"table_name"
Write a function called 'tab' ('table' is already taken
by the lua's standard optional table library) which uses
the string of its first parameter as an index into the
globals table. That'll fetch a table with that name, if
it exists. Then return a new table with a shallow copy
of the table you just fetched (or simply return that
table itself, which will return a reference instead of
a copy -- that might be okay or desirable depending on
what you want to do with the returned table).
If you want more detail then ask. :) (I know that some
people on this list will gleefully write exactly the
function that anyone asks for if it's half-interesting
to do so, but writing such relatively simple things
yourself is a perfect way to learn Lua!).