私はLuaでC++関数を登録しようとしています。LuaのC++関数を登録しますか?
しかし、このエラーを取得:
CScript.cpp|39|error: argument of type 'int (CScript::)(lua_State*)' does not match 'int (*)(lua_State*)'|
EDIT:
int CApp::SetDisplayMode(int Width, int Height, int Depth)
{
this->Screen_Width = Width;
this->Screen_Height = Height;
this->Screen_Depth = Depth;
return 0;
}
int CScript::Lua_SetDisplayMode(lua_State* L)
{
// We need at least one parameter
int n = lua_gettop(L);
if(n < 0)
{
lua_pushstring(L, "Not enough parameter.");
lua_error(L);
}
int width = lua_tointeger(L, 1);
int height = lua_tointeger(L, 2);
int depth = lua_tointeger(L, 3);
lua_pushinteger(L, App->SetDisplayMode(width, height, depth));
return 0;
}
そしてメインで:
lua_register(L, "setDisplayMode", Lua_SetDisplayMode);
私たちは、このエラーを生成したソースコードのスニペットを見ることができますか? – badgerr
これは簡単な機能です。上記の私の投稿を編集する。 – Cobra
39行目はどちらですか? – Deco