-
-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callbacks? #58
Comments
You can replace Code would look like...
Sorry about not having a place this is clear: I gotta pump up the docs to be a LOT more specific with this stuff so that people get the proper guidance. |
This is great! But how do I return null or empty to the first argument of the lua callback? lua.set_function("getUser", [](int id, sol::function cb)
{
cb(NULL, "THE USER");
}); |
|
Thank you! |
Will sol::function take ellipsis? |
No, it won't take ellipses, but you can feed it as many arguments as you like. |
@ThePhD Thanks for all your help. I'm really enjoying your library. I have one more big question for you... I am trying to call a sol::function callback from an asynchronous thread. My Do you have any tips here? Am I on the correct track, should I try to find a way to keep the sol::state from going out of scope (make it a pointer and manually delete it)? |
You need to shift the lifetime of the |
I took your suggestion and made it a shared pointer (moving the
(The lua script is the same as the original posting in this issue.) |
That could happen from a number of things. I have no idea what would be the problem, and I'm not sure I can reason about how your entire application stack sets up things. |
Fair enough. I think the problem is that the actually |
@ThePhD hey, I just wanted to say thank you. I got where I needed to go with the help of your library and advice. To solve the last problem I was having I had to implement lua_lock and lua_unlock in a custom lua build and bind that custom built lua library and header files into my program along with sol2. I now have a fully functioning bridge between nodejs and lua. |
Nice! If you think there's a nice way to do |
I appreciate your willingness but I doubt there is a way to do this. The lua team seems adamant that tread locking be a custom modification and build. The locking and unlocking functions are not even public, they expect you to modify the lua internal If I think of something while I am cleaning up my experiment for prime-time, I will let you know. |
I don't know where to ask this, please point me to a better location if you are offended having it here.
I have been trying to introduce myself to binding my own functions into lua. I have a (from what I can tell) very complicated end-goal read on StackOverflow if interested.
I need to be able to take a callback from lua so I can do asynchronous things before passing back into lua with a result.
Do you have some examples I could look at or suggestions on what to do?
The text was updated successfully, but these errors were encountered: