Adding Lua and VMs

Everything about development and the OpenMW source code.
Post Reply
AosSi
Posts: 5
Joined: 30 Mar 2019, 19:07

Adding Lua and VMs

Post by AosSi » 30 Mar 2019, 20:23

I've read this discussion thread from almost a year ago: viewtopic.php?f=6&t=5224 regarding openMW scripts. Zini mentions (viewtopic.php?f=6&t=5224&start=90#p56284) that they will start looking into integrating lua into openMW, but I was unable to find any further discussion on the subject (feel free to link the relevant threads).

In particular, after reading that thread I was wondering what path are you decided or leaning to implementing. I can think of several options here:

1. Using separate VMs for MWscript (the one currently used in openMW) and the standard LuaVM for lua scripts. Then the question is how do you plan to expose the openMW VM state to the LuaVM and vice versa? Or don't bother with that at all?

2. Reimplementing openMW VM in lua.

3. Adding a compiler of the MWscript to LuaVM bytecode.

4. Expanding existing openMW VM to interpret lua bytecode.

5. Using entirely separate VM (like LLVM for example) and adding the corresponding compiler for MWscript.

User avatar
AnyOldName3
Posts: 1582
Joined: 26 Nov 2015, 03:25

Re: Adding Lua and VMs

Post by AnyOldName3 » 31 Mar 2019, 01:54

The plan right now is to base things on TES3MP's server-side Lua scripting system. We're not yet sure how similar things are going to be in the end - TES3MP does work pretty well right now, so things could be very similar, but we have to anticipate what mod authors are going to want decades in the future when we've become the dominant way of playing TES VI.

As for long term plans for MWScript, we're intending on writing a MWScript to Lua transpiler, which will take an existing MWScript script and output an equivalent, readable Lua script.
AnyOldName3, Master of Shadows

AosSi
Posts: 5
Joined: 30 Mar 2019, 19:07

Re: Adding Lua and VMs

Post by AosSi » 31 Mar 2019, 03:14

So that makes it option #1 in my list. That still leaves the question of what are the thoughts on interacting between 2 different VMs. From a brief look at tes3-mp, I understand the "server-side" lua scripts don't know anything about the client side mwscript environment.

And I can see it causing issues in a single player too. Let's say you want to make a new mod using lua script, that uses some old mod written in MWscript. Then you would likely need to have access to internal variables of the MWscript of the old mod.

User avatar
AnyOldName3
Posts: 1582
Joined: 26 Nov 2015, 03:25

Re: Adding Lua and VMs

Post by AnyOldName3 » 31 Mar 2019, 03:19

Usually, MWScript variables are only available within the scope they're used (e.g. per function/script instance) or are properties of the object the script is attached to. There isn't really anything that can be shared between two MWscript instances that wouldn't be immediately available to Lua.
AnyOldName3, Master of Shadows

AosSi
Posts: 5
Joined: 30 Mar 2019, 19:07

Re: Adding Lua and VMs

Post by AosSi » 31 Mar 2019, 23:13

And in what state is the lua integration at the moment? Is there a working branch where it is being added or is it postponed until the potential merge with tes3mp?

User avatar
AnyOldName3
Posts: 1582
Joined: 26 Nov 2015, 03:25

Re: Adding Lua and VMs

Post by AnyOldName3 » 01 Apr 2019, 00:15

Unless David's been doing some experiments separately, you should view TES3MP as the only prototype so far. We're going to implement Lua either immediately before or immediately after the 1.0 release, and TES3MP is probably going to get merged at some point after that. That might mean that TES3MP ends up stripping out its existing scripting system and replacing it with a similar OpenMW one, but both projects are in close communication, so if that ends up happening, it won't be too disruptive.
AnyOldName3, Master of Shadows

Post Reply