Open dotori1995-enu opened 1 year ago
I always thank you for helping me. your results are very good.
but, i run into problem about metatable.
when code made like this, i check it run nomal operation.
sol::state m_luaState; array_name = "ARRAY1_"+usertype_table_name; m_luaState.new_usertype<lua_array1<T>>(array_name, sol::constructors<lua_array1<T>()>(), sol::meta_function::index, sol::resolve<T const & (const lua_array1<T> &, int)>(fetchIndex), sol::meta_function::new_index, sol::resolve<void (lua_array1<T>&, int, T const&)>(storeIndex) ); array_name = "ARRAY2_"+usertype_table_name; m_luaState.new_usertype<lua_array2<T>>(array_name, sol::constructors<lua_array2<T>()>(), sol::meta_function::index, sol::resolve<lua_array1<T>& (lua_array2<T> &, int)>(fetchIndex), sol::meta_function::new_index, sol::resolve<void (lua_array2<T> &, int, lua_array1<T> &)>(storeIndex) ); array_name = "ARRAY3_"+usertype_table_name; m_luaState.new_usertype<lua_array3<T>>(array_name, sol::constructors<lua_array3<T>()>(), sol::meta_function::index, sol::resolve<lua_array2<T>& (lua_array3<T> &, int)>(fetchIndex), sol::meta_function::new_index, sol::resolve<void (lua_array3<T> &, int, lua_array2<T> &)>(storeIndex) );
and next step is making table, and declear new usertype like this,
sol::table Table = m_luaState.create_named_table("A_TABLE"); Table.new_usertype<lua_array1<T>>(array_name, sol::constructors<lua_array1<T>()>(), sol::meta_function::index, sol::resolve<T const & (const lua_array1<T> &, int)>(fetchIndex), sol::meta_function::new_index, sol::resolve<void (lua_array1<T>&, int, T const&)>(storeIndex) ); array_name = "ARRAY2_"+usertype_table_name; Table.new_usertype<lua_array2<T>>(array_name, sol::constructors<lua_array2<T>()>(), sol::meta_function::index, sol::resolve<lua_array1<T>& (lua_array2<T> &, int)>(fetchIndex), sol::meta_function::new_index, sol::resolve<void (lua_array2<T> &, int, lua_array1<T> &)>(storeIndex) ); array_name = "ARRAY3_"+usertype_table_name; Table.new_usertype<lua_array3<T>>(array_name, sol::constructors<lua_array3<T>()>(), sol::meta_function::index, sol::resolve<lua_array2<T>& (lua_array3<T> &, int)>(fetchIndex), sol::meta_function::new_index, sol::resolve<void (lua_array3<T> &, int, lua_array2<T> &)>(storeIndex) ); Table.set(id, (lua_array3*)pObject);
it has error "[C]: in metamethod '__index'"
IDE : Visual Studio Code Language : C++ Compiler: Emscripten lua: 5.3.6
Thanks.
I always thank you for helping me. your results are very good.
but, i run into problem about metatable.
when code made like this, i check it run nomal operation.
and next step is making table, and declear new usertype like this,
it has error "[C]: in metamethod '__index'"
IDE : Visual Studio Code Language : C++ Compiler: Emscripten lua: 5.3.6
Thanks.