lua-users home
lua-l archive

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


Metamethod names begin with two underscores - you're assigning to
Image.mt.index instead of Image.mt.__index.

On 4/14/07, L-28C <kixdemp@gmail.com> wrote:
Hello everyone!

So I have this 'class':


-- Part of Graphics.lua --
Image = {}
Image.mt = {}
Image.mt.index = Image

function Image:Empty(w, h)
        local i = {}
        i.baseImg = SDL.SDL_CreateRGBSurface(SDL.SDL_SWSURFACE, w, h, 32, 0, 0,
0, 0)
        return setmetatable(i, Image.mt)
end

function Image:Clear(color)
        SDL.SDL_FillRect(self.baseImg, nil, color)
end
-- End --


-- Part of another file --
shieldsLyr = Image:Empty(scrWidth, scrHeight)
shieldsLyr:Clear(transp)
-- End --

That last line tells me the method 'Clear' is nil.

Why? Am I doing something wrong? Thanks!