[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: best way to add field to userdata?
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 22 Apr 2010 09:33:10 +0200
On Thu, Apr 22, 2010 at 9:27 AM, Ted Unangst <ted.unangst@gmail.com> wrote:
> But in order to get access to the width and height, I needed to use
> getters ("img:width()", as a call) which are annoying. I want
> "img.width" to work.
I'd suggest getting it to work in vanilla Lua first. This sounds like
a job for the 'proxy table' pattern. Property access fires __index,
which is a function which looks up the value in the actual table (and
may even call a setter, if defined). Ditto for __newindex.
steve d.