lua-users home
lua-l archive

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


Actually, there is a missing chunk, which may already be obvious...

Your user needs to be able to set the functions.

So, when they have the userdata (or as part of its constructor), you
need to set the index metamethod to retrieve the `callbackfunctions`
table, when they ask for it:

```
mybtn.callbackfunctions.action = function() end
```

to do this, in C, just make your __index function retrieve the
uservalue from the userdata (which will automatically be at index 1 on
the stack) and return the callbackfunctions table from the uservalue
table.

---Andrew

On Sat, Nov 16, 2013 at 3:52 PM, Andrew Starks <andrew.starks@trms.com> wrote:
> On Sat, Nov 16, 2013 at 3:52 PM, Andrew Starks <andrew.starks@trms.com> wrote:
>> lua_setuservalue(L, 8); //position 8 is where your user value was.
>
> Sorry this should read:
>
> lua_setuservalue(L, 8); //position 8 is where your userdata was.