Skip to content
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

is there a global variable for the love.js worker? #84

Open
lilmike opened this issue Dec 7, 2023 · 1 comment
Open

is there a global variable for the love.js worker? #84

lilmike opened this issue Dec 7, 2023 · 1 comment

Comments

@lilmike
Copy link

lilmike commented Dec 7, 2023

Hiya,

I'm trying to do something rather complicated, where I send a message from the love.worker.js to the main thread of the browser, which then causes an event listener to run some javascript code on the main thread. However, I'm having trouble identifying if there is a global variable for the worker that runs the lua code. I essentially just need to add an event listener, but that require me to know the variable containing the worker... and this code is complicated as all get out haha. Can you perhaps point me to the variable containing the worker?

Thanks,

-Michael.

@alexjgriffith
Copy link

love.worker.js enables love.thread in love.js. It is not designed to be accessed directly from within the love environment. If you want to create a worker and pass commands to it in the love environment you would do so the same as you would for a native game (so long as you are using the release target, not the compat target). There is a simple example on the wiki love.thread. Like the main thread, this thread would have no access to the javascript environment.

If you want to make a callback into the javascript environment, love.js-api-player provides an async interop. There is an example setup in #89.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants