[post-1.0] Scripting enhancemnts

Everything about development and the OpenMW source code.
grigi
Posts: 2
Joined: 21 Jan 2014, 06:23

Re: [post-1.0] Scripting enhancemnts

Post by grigi » 21 Jan 2014, 12:38

sirherrbatka wrote:We do not aim at MWSE compatibility.
Ah, I see now more the point of this conversation.
Updated my previous post to remove erroneous MWSE assumptions.

User avatar
Okulo
Posts: 672
Joined: 05 Feb 2012, 16:11

Re: [post-1.0] Scripting enhancemnts

Post by Okulo » 21 Jan 2014, 14:46

*raises finger*

I have a question for purposes of learning about languages. Suppose, hypothetically, that OpenMW would use Lua. Would it be possible to define or alias certain statements in Morrowind-script so they get translated to Lua? You know, kinda like how in the preprocessor part of C code you can go '#define CITY "place"'?

For OpenMW that would then be (pseudocode) '#define "set $foo to $bar" "$foo = $bar"', for example. So if a Morrowind script would get imported and it says 'set DaysPassed to 0', it will be run past that definition and OpenMW would then see it as 'DaysPassed = 0' and handle it as Lua code or something?

wheybags
Posts: 207
Joined: 21 Dec 2012, 19:41

Re: [post-1.0] Scripting enhancemnts

Post by wheybags » 21 Jan 2014, 15:37

What you're talking about is a cross compiler, and yes it is possible, but would ofc be a lot of work.

Chris
Posts: 1566
Joined: 04 Sep 2011, 08:33

Re: [post-1.0] Scripting enhancemnts

Post by Chris » 22 Jan 2014, 05:03

Okulo wrote:*raises finger*

I have a question for purposes of learning about languages. Suppose, hypothetically, that OpenMW would use Lua. Would it be possible to define or alias certain statements in Morrowind-script so they get translated to Lua? You know, kinda like how in the preprocessor part of C code you can go '#define CITY "place"'?

For OpenMW that would then be (pseudocode) '#define "set $foo to $bar" "$foo = $bar"', for example. So if a Morrowind script would get imported and it says 'set DaysPassed to 0', it will be run past that definition and OpenMW would then see it as 'DaysPassed = 0' and handle it as Lua code or something?
I don't see the point, honestly. Having pre-processor macros to automatically convert Morrowind syntax to something else won't help you learn that other language. And if you're going to use another language, it's best to learn and use it properly.

Besides, a proper scripting language would be so different from the mess that MW's script is, a pre-processor-driven conversion would likely not work. Your define example, for instance, would not be possible. It'd take a dedicated conversion routine to do it, and mixing old and new script syntaxes would be extremely impractical to properly convert.

User avatar
Okulo
Posts: 672
Joined: 05 Feb 2012, 16:11

Re: [post-1.0] Scripting enhancemnts

Post by Okulo » 22 Jan 2014, 12:36

Chris wrote:I don't see the point, honestly. Having pre-processor macros to automatically convert Morrowind syntax to something else won't help you learn that other language. And if you're going to use another language, it's best to learn and use it properly.
The point is that people would start using the newer language (Lua in this example) while still having backwards compatability with Morrowind scripts.

User avatar
Ace (SWE)
Posts: 834
Joined: 15 Aug 2011, 14:56

Re: [post-1.0] Scripting enhancemnts

Post by Ace (SWE) » 22 Jan 2014, 13:21

Keeping the old script system and having that 100% compatible with Morrowinds scripting syntax is all good. We like that.
Adding a second type of scripts you can create too (Using Lua/Python/other scripting language) is also good, having one doesn't mean you can't keep the other.

Gez
Posts: 37
Joined: 21 May 2013, 14:20

Re: [post-1.0] Scripting enhancemnts

Post by Gez » 23 Jan 2014, 12:50

If you have to have support for several different scripting languages, it's better to keep them separate rather than try to make One Grand Unified Script VM which would automatically identify the language and interpret it correctly.

De la même fashion, es ist more simple to verstehen une phrase written dans un seul language plutôt que in a mix of viel langues.

To take an example, Doom sourceport ZDoom has for backward compatibility purposes support for four different scripting languages, one of which exists in three different bytecode formats while another exists in two slightly different binary formats and two different raw text formats. There are bridges between them, but they do not mix directly.

User avatar
Logitech
Posts: 13
Joined: 01 Feb 2013, 03:59

Re: [post-1.0] Scripting enhancemnts

Post by Logitech » 05 Feb 2014, 19:53

I'd like to suggest some scripting features that would enhance the Morrowind scripting language:
- Reference Variables - already mentioned by Zini, but still worth looking at how it works in other TES games,
- do not replicate awful engine oddities that do not have any advantages and result in huge performance hits. The most annoying thing for me is probably this one:
Spoiler: Show
- if for whatever reason fixing the above problem is impossible please consider expanding the Begin command to accept additional block types and parameters.
- add some basic functions that are missing in Morrowind like checking actors BASE stats and skills, birgtsigns, gender etc. Take a look at vanilla Oblivion functions (marked as CS) in this page: http://cs.elderscrolls.com/index.php?ti ... _Functions
- allow to change actors race, gender, name, level (which should automatically change stats if actor has 'autocalculate' flag set in CS) etc. on the fly (so we could for example generate random actors with just one reference added into leveled lists).

edit: removed scripting language complain.
Last edited by Logitech on 12 Apr 2018, 20:19, edited 1 time in total.

maqifrnswa
Posts: 180
Joined: 14 Jan 2013, 03:57

Re: [post-1.0] Scripting enhancemnts

Post by maqifrnswa » 28 Dec 2014, 02:20

psi29a wrote:Another thought came to mind, leave the API exposed and let other people use whatever language they want? If people want to write python, lua, javascript, ruby or whatever... they just need an API against it. Leave it up to the modder to pick the language they feel comfortable with.
leveling up my thread necromancy skills...

I've been looking into learning the inner guts of openmw, and actually have been playing around with exactly that: using SWIG to create generic interfaces for any langauge supported by SWIG (java, python, lua) to the normal morrowind functions defined in apps/openmw/mwscripts/

I know a bit about embedding python in c++ so I started there. The strategy is:
1) Embed a python interpreter in openmw (really easy)
2) Extend the embedded python interpreter with the "normal" MW script calls in apps/openmw/mwscripts/ (as of now, really hard - but there might be an easy trick somwhere)
3) python script starts with "import openmw" which will connect to the bindings
4) Interpretter is extended to detect if a script is a python script, and if so run it through the embedded python interpreter which has bindings to the existing scripting functions

you gain all the power of python, address a lot of the features zini wanted in the first post, and can maintain a canonical set of "functions" with backwards compatibillity that are accessible by both MW and Python scripting. New script functions can be added and be available to all right away.

This is tricky right now with how the interpretter and extensions are implemented, I'm still trying to figure out how it works now (I'd appreciate pointers, there are no script function templates in the extension headers, that makes it hard to automate). I'd also appreciate thoughts on this approach - using a standard embedded python interpreter to interact with the existing functions.

EDIT: or expose the functions in mwmechanics instead of mwscript

User avatar
psi29a
Posts: 4720
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: [post-1.0] Scripting enhancemnts

Post by psi29a » 28 Dec 2014, 10:25

Awesome! :D

If you code it, they will come...

Post Reply