The Future of OpenMW Scripting

Everything about development and the OpenMW source code.
User avatar
psi29a
Posts: 5355
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: The Future of OpenMW Scripting

Post by psi29a »

Fair enough, but it's also nothing to sneeze at. Then there is this, non-complete, list:
https://en.wikipedia.org/wiki/Category: ... ideo_games

That being said, I wouldn't consider C# a scripting language but a full blown programming language which also explains why it's huge (in terms of community and in library size). I mean, someone really motivated could just re-write OpenMW in C#.

Is C# really necessary for our needs?

I was under the expression that newscript (API) would be exposed in the console.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: The Future of OpenMW Scripting

Post by Zini »

C# sounds very much like overkill. Let's at least try to keep this simple.

Regarding the console: Maybe a user setting to toggle between the two languages. Or a new UI element in the console window. We'll figure something out.
User avatar
Jemolk
Posts: 237
Joined: 20 Mar 2017, 02:12
Location: Sadrith Mora

Re: The Future of OpenMW Scripting

Post by Jemolk »

Lua honestly sounds best to me. I'd also have to learn a new language, but Lua has several very important things going for it, by the sounds:

1: Can be sandboxed well. Really important to Zini, so really important for getting it applied.
2: Extensive, easy-to-find documentation and answers to questions of newbies
3: An easy way to implement at least partial cross-compatibility with MWSE 2.x
4: NullCascade has already offered their services in getting it implemented

AngelScript sounds like it's missing all but the first. C# is just way overkill. Same with Python, or any other full programming language, as C#. And a lot of people absolutely hate Java's guts.
User avatar
wareya
Posts: 338
Joined: 09 May 2015, 13:07

Re: The Future of OpenMW Scripting

Post by wareya »

2 and 3 are red herrings.
User avatar
AnyOldName3
Posts: 2666
Joined: 26 Nov 2015, 03:25

Re: The Future of OpenMW Scripting

Post by AnyOldName3 »

Personally, I think 2 is the most important of all the points. Inexperienced programmers like googling '<language name> how to <do a thing>' and getting a working implementation off StackOverflow.
User avatar
Thunderforge
Posts: 503
Joined: 06 Jun 2017, 05:57

Re: The Future of OpenMW Scripting

Post by Thunderforge »

According to the TIOBE Index, Lua is currently the 25th most popular programming language. TIOBE does track AngelScript, but it's not in the top 100. It's also ranked number 22 on the IEEE Spectrum Top Programming Languages of 2017 (free registration required to view).

As best I can tell, the only language in the top 25 of either list that have any sort of sandboxing capability is Lua. The Python language used to support it with PyPy, but the documentation says it's no longer maintained.

If sandboxing is a must (and I think that's reasonable), then Lua is the most popular language available. Also, it's designed explicitly for the purpose of being embedded into apps, and only adds less than two hundred kilobytes to the app. None of the other 24 more popular language have this as a design goal. Versions after 5.0 are also released under the MIT license, so it should be no problem for the GPL.
User avatar
Jemolk
Posts: 237
Joined: 20 Mar 2017, 02:12
Location: Sadrith Mora

Re: The Future of OpenMW Scripting

Post by Jemolk »

wareya wrote: 06 Jul 2018, 21:59 2 and 3 are red herrings.
Only if you don't care about de facto limiting modding OpenMW to experienced programmers and those who don't mind becoming so for the sake of a hobby. Sorry, but 2 will make a huge real-world difference, and so will 3. If we couldn't make these things work, that would be one thing and we could reasonably do our own thing, but we can make them work quite easily, meaning there's really no excuse for ignoring such considerations.

While we're at it, the only Lua oddity I've seen mentioned is starting arrays at 1 rather than 0. I'd just like to point out that there's a pretty good reason one might want to do this -- arrays starting at 0 may be what programmers expect, but it's quite unintuitive to others without that background. I say this as someone who recently took an introductory programming course because I want to do some stuff with FOSS projects as a hobby, even though my primary passion is philosophy.
User avatar
wareya
Posts: 338
Joined: 09 May 2015, 13:07

Re: The Future of OpenMW Scripting

Post by wareya »

No special-purpose sandboxed embeddable language is going to have general documentation useful for more than incredibly simple things like syntax and how to write an if statement (to exaggerate things). Every last bit of truly useful functionality is going to be defined by how it's hooked into the engine or what libraries it's allowed to access.

Lua has a bunch of standard libraries, but they're optional and they do very straightforward things; OpenMW would even actively want to not integrate avoid some of them, like the IO and OS libraries, things that OpenMW would have to give its own cherrypicked alternatives to.

That leaves the math, table, and string libraries, each of which are spartan enough that they could be explained with tooltips in OpenCS itself, and would need to be extended.

Hypothetically, let's say you want to split a string by some delimiter, and OpenMW exposes a function that does that. What are you going to find if you google how to split a string in Lua? This: http://lua-users.org/wiki/SplitJoin , which is crazy. On the other hand, if you learned to check the OpenMW-specific documentation first, you would have found that OpenMW already gives a function to split strings.
User avatar
gus
Posts: 390
Joined: 11 Aug 2011, 15:41

Re: The Future of OpenMW Scripting

Post by gus »

I just stumbled upon a serie of videos on how to embed LUA in C++ and figured it might have some use here
https://www.youtube.com/watch?v=xrLQ0OX ... HaXgNX0Itk
User avatar
Thunderforge
Posts: 503
Joined: 06 Jun 2017, 05:57

Re: The Future of OpenMW Scripting

Post by Thunderforge »

wareya wrote: 09 Jul 2018, 00:33 Hypothetically, let's say you want to split a string by some delimiter, and OpenMW exposes a function that does that. What are you going to find if you google how to split a string in Lua? This: http://lua-users.org/wiki/SplitJoin , which is crazy. On the other hand, if you learned to check the OpenMW-specific documentation first, you would have found that OpenMW already gives a function to split strings.
That seems to be in favor of Lua; while built in string split functions are sub-optimal, they are well-documented, so we don't have any additional work. Writing our own documentation for an addon library is less work than writing documentation for everything.

Regardless, the question remains: if we're not using Lua, what's the better option? The only things I've seen proposed that meet our requirements are oldscript+ and AngelScript. The former seems rather unappealing and is increasingly niche, the latter isn't in the top 100 programming languages used. Plus, Lua is already used in TES3MP and MWSE. Lua isn't perfect, but if we're not using it, we'll need to pick a better option.
Locked