Skip to content

Question #90

Answered by kunitoki
Mellnik asked this question in Q&A
Mar 13, 2023 · 13 comments

You must be logged in to vote

Thanks for the support !

Will try to answer the questions one by one.

  • When pushing a C++ pointer to Lua is it possible to dynamically choose what exposed class to use?

Yes, if the types have been registered with LuaBridge, than it's a matter of casting to your right type (the best cast depends on the usa case and object types, static or dynamic) before sending the pointer/reference into lua (via stack push or function calls from C++).

So if you registered both class A and class B : public A (as derivedClass from A) then it's possible you dynamic_cast<B*>(my_a_pointer) in C++ and send it into luabridge, using normal RTTI in C++.

See https://kunitoki.github.io/LuaBridge3/Manual#23---class…

Replies: 13 comments

You must be logged in to vote
0 replies
Answer selected by kunitoki

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
3 participants
Converted from issue

This discussion was converted from issue #62 on April 01, 2023 21:26.