How can I make a table a copy of another table?

Take a look at this code:

[lua]

local happy = {

a = 1,

b = 2

}

local happy2 = happy

happy2.a=0

print (happy.a)

[/lua]

When I change the variable “a” in the happy2 table, it changes in the happy table too.

How can I make it so happy2 has it’s own a and b variables rather than having them be the same variables that are in happy?

Assignments are direct references in lua.  See: https://forums.coronalabs.com/topic/27482-copy-not-direct-reference-of-table/

Okay. Thank you.

Assignments are direct references in lua.  See: https://forums.coronalabs.com/topic/27482-copy-not-direct-reference-of-table/

Okay. Thank you.