lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


  Hi all.  So far so good integrating Lua into my game engine.  I'm very
impressed with the results.

  I have a language specific question.  Take the following C example:

Vector *pVec=&object1.vector;
*pVec=object2.vector;

  So that is a slightly roundabout way of saying object1.vector =
object2.vector.

  In Lua I have this:
vec=object1.vector

  In my environment that is equivalent to Vector *pVec=&object1.vector.  Any
changes made to vec apply to object1.vector.  My question is how best
syntactically to set vec's values to that of another vector?

This will not work:
vec=object1.vector
vec2=object2.vector
vec=vec2

  vec just references the same thing as vec2.
  Currently I have to do this:

vec=object1.vector
vec2=object2.vector
vec.x=vec2.x
vec.y=vec2.y
vec.z=vec2.z

  I could of course simply expose a function like set(), allowing something
like this:
vec.set(vec2)

  However I wanted something more in the spirit of the Lua language, which
is something I'm only superficially familiar with so far (I'm more familiar
with the stack-based API side than the actual Lua language :).

  Suggestions are certainly appreciated!

  Dan East