Hi,
I'm working on integrating some C code with Lua. The C code is
dynamically bound, so I'm able to do things like the following:
void *obj = obj_new("name_of_obj");
obj_method(obj, "draw");
obj_method(obj, "scale", 2, [0.5, 0.5]);
...
The above C code will allocate an object, then call the object's draw
method, and then set the object's scale parameter. What I'd like to
be able to do with Lua is the following
obj = Obj.new("name_of_obj");
obj:draw()
obj.scale = {0.5, 0.5}
(please excude my lua syntax if it's wrong, I'm still learning}.
In the Lua code, I'm calling the draw method and then setting the
object's scale property to a pair of x, y values. Now, somehow I need
to translate obj:draw() into Lua such that Lua actually calls a
generic function that passes the name of the actual function that was
called as a parameter. If I were to explicity write this in Lua, it
would look like:
obj:method("draw") However, I'd like to have the more convenient
notation of obj:draw() map to this instead. I'm sure there's a way to
do this in Lua, I just can't seem to figure it out right now. Any
ideas?
thanks,
wes