Search found 45 matches

by ptmikheev
08 Nov 2020, 19:49
Forum: General Development
Topic: Lua scripting in OpenMW
Replies: 81
Views: 13177

Re: Lua scripting in OpenMW

Could we have something like a bunch of scripts that need to be run at some point during the frame, and the main thread sticks them in a queue of waiting scripts that get picked up by a pool of worker threads, then once it needs the results of things, it can either deal with what the worker threads...
by ptmikheev
08 Nov 2020, 00:04
Forum: General Development
Topic: Lua scripting in OpenMW
Replies: 81
Views: 13177

Re: Lua scripting in OpenMW

Lua doesn't support threads. Async logic can be implemented with coroutines, but it's not real threads. Well, there is a library that adds multithreading to Lua, but anyway, a worker thread is not a solution. In a general case we will have a bunch of scripts, each of them is too small to be moved t...
by ptmikheev
07 Nov 2020, 23:52
Forum: General Development
Topic: Lua scripting in OpenMW
Replies: 81
Views: 13177

Re: Lua scripting in OpenMW

It might be better for us to make modders deal with it. If you're writing a resource-hungry mod, maybe it should be your responsibility to spin the heavy lifting off into its own worker thread. That way, no one pays the complexity cost unless they're actually causing problems. Lua doesn't support t...
by ptmikheev
07 Nov 2020, 22:31
Forum: General Development
Topic: Lua scripting in OpenMW
Replies: 81
Views: 13177

Re: Lua scripting in OpenMW

Multithreading and Lua scripting Let's discuss the question "do we need a separate evaluation thread for lua scripting". Currently scripting (mwscript) works in the same thread as rendering and in most cases doesn't take a lot of time. Why would we want to run lua in a separate thread? Lua scriptin...
by ptmikheev
01 Nov 2020, 00:24
Forum: General Development
Topic: Lua scripting in OpenMW
Replies: 81
Views: 13177

Re: Lua scripting in OpenMW

Did some benchmarking. It turned out that sol3 has much better performance. Still don't understand how does it work (28K lines of template magic :shock: ), but it is twice faster.
Most probably I'll give up with the idea of custom lua wrapper, but it was worth to try.
by ptmikheev
30 Oct 2020, 15:59
Forum: General Development
Topic: Lua scripting in OpenMW
Replies: 81
Views: 13177

Re: Lua scripting in OpenMW

Problem solved... sol2/3 is just a another dep to download, we make sure our build system has access to it in include path, done. https://github.com/ThePhD/sol2/tags There is no need to pull it into /extern The problem is not only in CI builds. It also complicates setting up a development workflow....
by ptmikheev
30 Oct 2020, 12:34
Forum: General Development
Topic: Lua scripting in OpenMW
Replies: 81
Views: 13177

Re: Lua scripting in OpenMW

Using sol2 or sol3 would mean adding more than 20'000 lines of code to OpenMW repo. How is that? Is that just generated interface stuff? Or are you trying to import sol2/3 library into /extern ? Keep in mind, we can add more dep libraries as needed. sol2 and sol3 are header-only libraries. As I und...
by ptmikheev
30 Oct 2020, 05:59
Forum: General Development
Topic: Lua scripting in OpenMW
Replies: 81
Views: 13177

Re: Lua scripting in OpenMW

Here is a prototype of an interface between C++ and Lua: https://gitlab.com/-/snippets/2034622 Using sol2 or sol3 would mean adding more than 20'000 lines of code to OpenMW repo. My prototype uses Lua C API directly and has only 300 lines of code. It has not so many features as sol3, but it seems to...
by ptmikheev
21 Oct 2020, 23:58
Forum: General Development
Topic: Lua scripting in OpenMW
Replies: 81
Views: 13177

Re: Lua scripting in OpenMW

Absolutely follow this information if using sol (and definitely use sol3 over sol2). Also note that support for sol is currently offline as the developer handles some larger C++ community issues. Either way, if using sol expect your binary size to bloat extraordinarily. In my experience, contrary t...
by ptmikheev
18 Oct 2020, 18:14
Forum: General Development
Topic: Lua scripting in OpenMW
Replies: 81
Views: 13177

Re: Lua scripting in OpenMW

My favourite example is a mod that uses an external speech synthesis tool (let's image in a couple of year it has very good quality) to voice all dialogues in the game. Wouldn't be better to implement such a thing directly into the engine? Definitely no. Such tool is a big and complicated thing tha...