lua-users home
lua-l archive

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


So I'm overriding the __index call of my script object that wraps my C user data... Short example below... How do I get the prototype call to pass in the instance of my object as the first param (like it does when I reference with : ) ...? So far the only way I can call it is my table.prototype[key] ...

LuaWindow =
{
instanceName="",
prototype = nil
}

function LuaWindow.new(o)
LuaWindow.instanceName = o.instanceName;
LuaWindow.prototype = --Create my C object with metatable here
setmetatable(o,LuaWindow);
return o;
end

LuaWindow.__index = function (table,key)

if LuaWindow[key] ~= nil then
 return LuaWindow[key];
else
--How do I get it to call the method and pass in the first param here? I'm trying : but Lua complains
--  return LuaWindow.prototype[key];
 return table.prototype[key];
end
end

mainWindow = LuaWindow.new{instanceName="newWndObject"};

--This method will be passed to the C object since it doesn't exist in the script object
mainWindow:ShowWindow();