lua-users home
lua-l archive

How does lua_touserdata work? Userdata also..

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


I have a function:
int l_Poke(lua_State* luaVM)
{
 char *address1 = NULL;
 DWORD address = 0;
 void *value = 0;
 int size = 0;
 address1 = (char *)lua_tostring(luaVM, 1);
 value = (void *)lua_touserdata(luaVM, 2);
 size = (int)lua_tonumber(luaVM, 3);
 if (value == NULL)
 MessageBox(NULL, "Uh oh", NULL, MB_OK);
 address = hextoint(address1);
 theScriptWindow->Poke(address, value, size);
 return 1;
}
called like:
Poke("0100579C", 5, 4)
in the script ( 5 being the value here)
It's supposed to be a void * because I want to cast it to BYTE, 
WORD, or DWORD depending on the size parameter.
However.. value always comes out NULL.
What am I doing wrong?

AltStyle によって変換されたページ (->オリジナル) /