lua-users home
lua-l archive

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



On 15/07/2005, at 3:09 PM, Ive wrote:

In my .lua file I got the following:

actor = CreateActor("ActorCubeName");
primitive = CreateCube("CubeName", 1, 1, 1);
ActorSetPrimitive(actor, primitive);
...
now... I ll rather do something like this:

actor = CreateActor("ActorCube");
primitive = CreateCube("CubeName", 1, 1, 1);
actor->SetPrimitive(primitive);

Assuming actor is a table (if it it's then your need to use a table), try this instead of your last line above:

actor.SetPrimitive = ActorSetPrimitive
actor:SetPrimative(primative)

Otherwise,
a = { }
a.ptr = actor
a.Set = function(a, prim) ActorSetPrimitive(a.ptr, prim) end
a:Set(primative)

Basically x:y(...) expands to x.y(x, ...)

Hope that helps.  I may have missed the point since your actor->xyz looks more like C++ than Lua.

Russ