An object declared as Type variableName
is passed to Lua by value, as a copy managed by Lua. Hence var.d
returns a copy of that d
object, and with var.d.c
you are modifying the c
variable of that copy, not the c
variable of the original d
object.
An object declared as Type* variableName
is passed by reference, hence you modify the original d
object, that's why your second approach works.
More info in the LuaBridge manual.