script life cycle

General discussion regarding the OpenMW project.
For technical support, please use the Support subforum.
mirpa
Posts: 33
Joined: 12 May 2013, 17:01

script life cycle

Post by mirpa » 20 May 2013, 18:20

Hi,

could somebody elaborate a little bit about scripts? How do you handle them from text representation through compilation to execution or how do you intend to do it. I am not modder so I do not understand ESX/BSA file formats that well yet.

It seems to me, that script is stored in uncompressed binary format inside ESX and openmw uses compiler component just to translate console commands into bytecode so compiler component is mainly part of opencs.

In compiler there seems to be class for each syntactical unit (token) which handles everything from lexical analysis to code generation and error handling.

I didn't look at interpreter component yet. But I wonder how do you manage memory usage for script interpretation. In game there are big increases in memory usage around big cities like Balmora, Aldruhn... Game starts at ~400 MB Ram and it can reach 1 or 2 GB within 15 minutes or less.

Ps. Of course I have red Ghan's Morrowind Scripting for Dummies (briefly).

Btw. How do you study new classes - do you use some IDE feature or do you use (doxygen) documentation? I would appreciate more comments on design choices inside code on some places - but maybe it is because I am not used to OOP that much.

I always wondered if there is some design draft inside OSS projects. I intend to crawl through most of the code anyway so feel free to leave my post unanswered.

Thanks anyway.

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

Re: script life cycle

Post by Zini » 21 May 2013, 09:00

Vanilla Morrowind's CS compiled script into bytecode, which was stored in the ESX files and then executed by a VM in Morrowind. We do not support the same VM, but we do support the scripting language.

OpenMW compiles the scripts on the fly to bytecode for our own VM (the interpreter).

There are no memory issues regarding scripts (unless there is a bug we are not aware of; which is always a possibility). There is nothing to manage. Compiled scripts (except for dialogue scripts) are stored for later use, but this stuff is tiny.

The compiler works by first translating the character stream into tokens and then sending them to the parser. We have indeed separate parser classes for the different levels of syntactic constructs.

IIRC there was a memory leak in 0.23.0 (not sure how far it is going back) regarding graphics resources. That should be fixed in 0.24.0 though. Would be interesting to see if you are still getting this huge memory usage. We had also reports of memory usage problems related to the 32 bit version of OpenMW. Not sure what the state of that is, but are you running under 32 bit?

mirpa
Posts: 33
Joined: 12 May 2013, 17:01

Re: script life cycle

Post by mirpa » 21 May 2013, 13:08

64-bit Linux, recent version from git/master.

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

Re: script life cycle

Post by Gez » 21 May 2013, 14:28

Zini wrote:Vanilla Morrowind's CS compiled script into bytecode, which was stored in the ESX files and then executed by a VM in Morrowind. We do not support the same VM, but we do support the scripting language.

OpenMW compiles the scripts on the fly to bytecode for our own VM (the interpreter).
There is at least one Morrowind mod (cdcooley's Companion Teleportation 1.1 IIRC) which only kept the byte code for the scripts to make the mod smaller. (Actually, it had like ten near-identical copies of the same script with different IDs, and only the first had kept its source code, with the text file explaining how to recreate the source code for the other scripts if you wanted to change stuff and recompile.)

So it might be a good idea, on the long term, to support reading the vanilla bytecode and translating it to OpenMW's bytecode format if the source code is missing.

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

Re: script life cycle

Post by Zini » 21 May 2013, 14:32

While I wouldn't reject a code contribution that does that (if done cleanly), personally I would see that as a waste of time. It would be quicker to just fix that plugin. I doubt there are many of these around. I don't see how it would even be possible to create something like this with the TES-CS.

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

Re: script life cycle

Post by Gez » 21 May 2013, 22:35

Zini wrote: I don't see how it would even be possible to create something like this with the TES-CS.
He used the Enchanted Editor to do that.

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

Re: script life cycle

Post by Zini » 22 May 2013, 09:17

Yeah. Sorry, but we do not support 3rd party binary extensions/tools/modifications to MW in any way. IMHO a plugin as this should simply be classified as broken.

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

Re: script life cycle

Post by Tarius » 22 May 2013, 18:30

Zini wrote:Yeah. Sorry, but we do not support 3rd party binary extensions/tools/modifications to MW in any way. IMHO a plugin as this should simply be classified as broken.
However, lacking the ability to edit stuff like Enchanted editor would be a big drawback. This would be in the realm of the CS though and you wouldnt need another tool.
I am a bigger fan of tons of control rather than taking the "user-friendly" approach.
-Okulo

User avatar
sirherrbatka
Posts: 2118
Joined: 07 Aug 2011, 17:21

Re: script life cycle

Post by sirherrbatka » 22 May 2013, 19:26

Enchanted editor is here for doing crazy hacks around the engine mostly so is it a case?

claudekennilol
Posts: 51
Joined: 01 Aug 2012, 20:48

Re: script life cycle

Post by claudekennilol » 28 May 2013, 15:52

I used Enchanted Editor almost exclusively. It was much easier than loading up the CS and clunking around in there. I never did anything with it that couldn't be done with the CS though (disregarding editing saves as that wasn't esp/esm manipulation). Obviously this is in regard to scripting, and basic object manipulation, object placement was better in the CS.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests