[post-1.0] Scripting enhancemnts

Everything about development and the OpenMW source code.
User avatar
heilkitty
Posts: 143
Joined: 11 Aug 2011, 07:57
Location: Vivec City, MW
Contact:

Re: [post-1.0] Scripting enhancemnts

Post by heilkitty » 13 Apr 2012, 16:40

Some kind of signals would be a nice enhancement. Because scripts executing every frame and most of the time doing nothing but checking if they should run is, well, ultra gay.
In Soviet MoЯЯowind, Almalexia kills YOU!!

Tarius
Posts: 574
Joined: 24 Oct 2011, 19:29

Re: [post-1.0] Scripting enhancemnts

Post by Tarius » 14 Apr 2012, 00:05

heilkitty wrote:Some kind of signals would be a nice enhancement. Because scripts executing every frame and most of the time doing nothing but checking if they should run is, well, ultra gay.
Well, then they would have to check if they have received the signal.
You always tell a script, that is based on another script being triggered, to run in the first script that gets triggered anyway. When you a need a script, it should never be running except when possibly needed. It mostly comes down to the person who wrote the script to do a good job on it and make sure it doesnt take more resources than nesessary.
I am a bigger fan of tons of control rather than taking the "user-friendly" approach.
-Okulo

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

Re: [post-1.0] Scripting enhancemnts

Post by Chris » 14 Apr 2012, 01:08

Tarius wrote:Well, then they would have to check if they have received the signal.
The point of signals is that they're called only when the signal is generated. For example:

Code: Select all

void onHit(ActorRef attacker)
{
    ...
}
The onHit method here would only ever run when the engine detects a hit on the actor with the script, and implicitly provides it with who attacked. The script doesn't have to do any checking for a hit because this method would only ever be called when there was a hit. The script never needs to be called if there wasn't a hit because there's nothing else for it to do (and if there is, the method for that would only be called as needed, completely ignoring the onHit method).
When you a need a script, it should never be running except when possibly needed.
Precisely, and that's the biggest flaw in Morrowind's scripting engine. The script will run every logic frame. It has no choice unless it's a global script that can be disabled (and even then, there's not much flexibility there). If you're waiting for a specific action to happen, then your script will be running for (tens of) thousands of frames where that action never happens, so you have to check for that action every time the script is run. That's very wasteful and creates convoluted scripts as they have to each reimplement a basic state machine. Instead of the script being "put to sleep", and only being woken up by the engine to run the specific method that needs to run at the appropriate time, the entire thing needs to run through from beginning to end and the script itself has to manage what should be run and when. If the scripts takes too long to process, the whole game suffers.

However, if we take something like what Bethesda did with Papyrus in Skyrim, these problems are solved. You can define specific methods to be called on specific events, and your script will never be run outside of those events. You can schedule updates so the script won't be called again until that update time expires. You can go to sleep, so if you need to wait for a result, you don't have to put in a bunch of checks and branches to keep code from running at inappropriate times. You can do complex calculations because the script's processing will be preempted if you take too long, and pick up where it left off next frame.

User avatar
heilkitty
Posts: 143
Joined: 11 Aug 2011, 07:57
Location: Vivec City, MW
Contact:

Re: [post-1.0] Scripting enhancemnts

Post by heilkitty » 14 Apr 2012, 05:57

To be fair, there is some kind of signals (EDIT: I meant events) in Morrowind, it's just underdeveloped, inefficient and encourages to write big messy code.
Last edited by heilkitty on 18 Apr 2012, 02:55, edited 1 time in total.
In Soviet MoЯЯowind, Almalexia kills YOU!!

User avatar
heilkitty
Posts: 143
Joined: 11 Aug 2011, 07:57
Location: Vivec City, MW
Contact:

Re: [post-1.0] Scripting enhancemnts

Post by heilkitty » 15 Apr 2012, 11:37

Nevermind, I reckon, signals would depend on function-script feature, so, if implemented, they would be post-2.0 feature or something, so it's too early to talk about this now.
In Soviet MoЯЯowind, Almalexia kills YOU!!

asmageddon
Posts: 4
Joined: 26 Apr 2012, 08:43

Re: [post-1.0] Scripting enhancemnts

Post by asmageddon » 26 Apr 2012, 08:55

Just registered to throw in my two cents.

I also believe that MW scripting language is very poor and all attempts to improve will only make it slightly more bearable but never good.

I vote for using an existing VM instead, probably Lua due to how simple it is to embed it in a game (although I personally would vote for Python because it's my favorite language) and simply compile existing MW scripts into that language.

If we're dropping scripting compatibility with original scripting language, we might as well completely redesign or even replace it.

Compiling it to another language should be quite trivial as MWscript is a very small subset of any sane language

User avatar
Zini
Posts: 5537
Joined: 06 Aug 2011, 15:16

Re: [post-1.0] Scripting enhancemnts

Post by Zini » 26 Apr 2012, 09:16

The problems that have shown up here in this thread seem to go beyond the scripting system and we will discuss them when we start planning post-1.0 development.

I just want to correct one point. Nowhere in my proposal there is anything about breaking compatibility with the original scripting language. I don't know where this nonsense come from. The purpose is exactly the opposite; keeping language compatibility at max (while still being able to extend the language).

Tarius
Posts: 574
Joined: 24 Oct 2011, 19:29

Re: [post-1.0] Scripting enhancemnts

Post by Tarius » 26 Apr 2012, 19:35

Yea, there is no way that compatability will be broken otherwise you might as well call this Open Game Engine because it no longer works with Morrowind because every quest in the game would be broken.
I am a bigger fan of tons of control rather than taking the "user-friendly" approach.
-Okulo

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

Re: [post-1.0] Scripting enhancemnts

Post by Chris » 27 Apr 2012, 02:56

Tarius wrote:Yea, there is no way that compatability will be broken otherwise you might as well call this Open Game Engine because it no longer works with Morrowind because every quest in the game would be broken.
What we, or at least I, mean by "breaking compatibility" is that the new additions (which would be optionally enabled by the script writer) would not necessarily work with existing script functionality. I don't mean that the script compiler as a whole will fail to compile Morrowind's scripts, just that Morrowind's scripts may not work when those extensions are enabled on the script.

But really, the main reason I want to move away from extending Morrowind's scripting language (beyond that which to support MWSE and whatever MGE/MGE XE have done), is to fix the ludicrous syntax choices Bethesda made, and make it cleaner to work with signals and events.

Tarius
Posts: 574
Joined: 24 Oct 2011, 19:29

Re: [post-1.0] Scripting enhancemnts

Post by Tarius » 27 Apr 2012, 04:10

Chris wrote:
Tarius wrote:Yea, there is no way that compatability will be broken otherwise you might as well call this Open Game Engine because it no longer works with Morrowind because every quest in the game would be broken.
What we, or at least I, mean by "breaking compatibility" is that the new additions (which would be optionally enabled by the script writer) would not necessarily work with existing script functionality. I don't mean that the script compiler as a whole will fail to compile Morrowind's scripts, just that Morrowind's scripts may not work when those extensions are enabled on the script.

But really, the main reason I want to move away from extending Morrowind's scripting language (beyond that which to support MWSE and whatever MGE/MGE XE have done), is to fix the ludicrous syntax choices Bethesda made, and make it cleaner to work with signals and events.
Well actually I was replying to asmageddon.
On further thoughts, you would also have to take into account all the mods that have been made.

Anyway, I wouldnt call added functionality as breaking it. I would call it as enhanced or something.
I am a bigger fan of tons of control rather than taking the "user-friendly" approach.
-Okulo

Post Reply