Extending the CS's scripting language

Involved development of the OpenMW construction set.
Post Reply
User avatar
Liebranca
Posts: 2
Joined: 26 Jul 2019, 06:36

Extending the CS's scripting language

Post by Liebranca »

Hello,

Because I'm locked to 0.47 (long story), I have to do all my scripting in the CS's scripting language rather than Lua, at least for the time being. I find it a bit clunky, so I stayed up all night hacking together a way to extend it a bit; in essence, I added syntactic sugar, write files with the new syntax, and process these to create new files that I then paste into the CS.

What I used this hastily put together method for is defining functions to save me from manually inlining, unrolling loops and writing multi-line expressions, but I think further improvements should be possible. So, two things:

1) I could use a standalone version of the syntax check from the CS, that way my program can give error messages. Point me to the files if there isn't such a thing yet, I'll compile it myself.

2) Could there be a way to write the output script directly into an *.omwaddon/*.esp? Or alternatively, generate an *.esp containing the updated scripts? That would save me opening the CS and manually pasting in the expanded code. I mean, doing it manually is doable for one or two scripts, but anything large-scale would be nightmarish -- I'd much rather automate the process so I can simply write and compile from the terminal, which is what I'm used to. Again, point me to the files ;>

I'm glancing through the engine sources to try and figure out where I want to start reading, most likely the compiler/interpreter duo. We'll see.

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

Re: Extending the CS's scripting language

Post by psi29a »

You're locked in because tes3mp or locked in because 0.48 isn't yet released? :)
User avatar
Liebranca
Posts: 2
Joined: 26 Jul 2019, 06:36

Re: Extending the CS's scripting language

Post by Liebranca »

psi29a wrote: 16 Jul 2023, 09:50 You're locked in because tes3mp or locked in because 0.48 isn't yet released? :)
Guess I'll just answer all of my questions myself by digging into the code.
Last edited by Liebranca on 17 Jul 2023, 05:55, edited 1 time in total.
User avatar
psi29a
Posts: 5362
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Extending the CS's scripting language

Post by psi29a »

If you mean by extending mwscript, we've had PRs and MRs that attempted this and we've closed them. You can read up on those if you want.

We've concluded years ago to fossilize mwscript and not support mwse 1.0 additions. So if the intent was to help develop openmw further, just note it won't be accepted. If you're just hacking away for your own, we wish you success! :)

Perhaps someone else might want to chime in to help.
User avatar
Liebranca
Posts: 2
Joined: 26 Jul 2019, 06:36

Re: Extending the CS's scripting language

Post by Liebranca »

Excuse me?

This is an external tool that takes in files written in a new syntax, processes them, and outputs raw mwscript -- not even remotely subject to approval.

But perhaps "extending" is a misleading term. I'm not implementing new functionality to the language, just making it easier to write for the times one has no other choice, meaning: nothing needs to be changed, removed or added to openmw itself.

Anyway, what I'm trying to figure out is merely for convenience:

1) Having syntax checking outside of the CS, so my program can know if it's outputting correct code.

2) A way to write these output scripts into *.esp files directly, to avoid having to paste them in manually.

I came to see if anyone had some insight that could speed things up, but if not that's OK.
User avatar
AnyOldName3
Posts: 2678
Joined: 26 Nov 2015, 03:25

Re: Extending the CS's scripting language

Post by AnyOldName3 »

Long-term, we aim to have plugin support for our CS, so one day you'll probably be able to tack on your preprocessor into the CS with or without our approval.

As for your specific questions, it's probably theoretically possible to make a standalone tool out of our MWScript validator, but it's unlikely that that work's going to get done by us. There are at least a couple of libraries and tools like TES3CMD that let you edit Morrowind's variant of ESP files, so you could look into that.
Post Reply