lua-users home
lua-l archive

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

Jose Marin wrote:


I have a problem when using Luna (or Lunar):

How I create a method to deal with this:

a = Account(100)
b = Account(200)


The problem is how to, inside the method 'check', get
the pointer to the class Account.

Yahoo! Acesso Grátis - Internet rápida e grátis. Instale o discador agora!

this code is valid for luna template for lua 4.x (I think)

int your_class::check(lua_State *L)
	your_class *p;
	lua_pushnumber(L, 0); /* userdata object is stored in index 0 */
	lua_gettable(L, 1);		/* first argument for the user function y the table object
	p = (some_class *)lua_touserdata(L,-1);
... ...