SWIG Scripting Extensions project

Everything about development and the OpenMW source code.
Posts: 7
Joined: 04 Dec 2015, 20:51

Re: SWIG Scripting Extensions project

Post by melrief » 06 Dec 2015, 17:26

I don't think creating/extending a programming language should be taken that easily. It is a quite complex task and theory behind PLs is huge. Instead of creating your own language you should really let people who did it for decades write it and then just use it. To answer the comment
metatables could be implemented as archive scripts
or you could just use what other languages have and has been tested extensively. We were talking about the problem of maintainability but now we are discussing about adding new feature that other languages already have. I'm not sure to follow but let me reiterate: PLs are difficult topics, they look easy but they are difficult.
https://en.wikipedia.org/wiki/First-class_function seems like would be same as "function" running strings as commands althought more fine revined would maybe need extra parameters?
No it's not that. It's about passing or returning functions from/to functions. You can "emulate" it in that way but still it's not the same.
https://en.wikipedia.org/wiki/Information_hiding that would need it's own block naturally at least on mwscript
MWScript doesn't look like a language that could support this easily.
https://en.wikipedia.org/wiki/Associative_array that looks like list but more general approach. extra array functions and such would need to be script based with only those
Associative arrays are not lists! Access element in associative arrays is constant time while in a list is always linear if you don't know the position in the list.
for loops:
"while condition do" would be handy

"repeat" both are basically same as while or xwhile which would have feature stopping at call before running whole script and determining how many times even if condition doesn't fullfil. ( details... )

"for i = first,last,delta do ;delta may be negative, allowing the for loop to count down or up"
that could be implemented as is
Probably you don't want for-loops in a scripting language where each script run once per-frame. Loops are naturally expressed already. The main reason I see to use loops is to go through a collection and do something with each element. You can do the same with an index that you increment every frame.

Anyway, I see that a lot of people want to play with MWScript and that's ok but what about supporting both? That looks like a good idea to me.

Posts: 6
Joined: 29 Sep 2014, 09:12

Re: SWIG Scripting Extensions project

Post by rlilewis » 06 Mar 2016, 09:52

Sorry guys, appreciate this is one of the older threads but I'd like to weigh in here.

IMO Oblivion with OBSE was the golden era of Elder Scrolls modification from a scripting point of view (not that I liked the game itself). Having to go back to MW scripting even with that extender application is so damn clunky and limiting, so for me the extension of the CS and scripting is one of the most critical parts of OpenMW.

In OBSE you could do things like:

* Arrays
* User defined functions (although you had to have them in their own separate script which kinda sucked) (Skyrim added functions within the same script and could pass/return variables - very nice)
* Labels and Goto commands (can't remember if these were in MW)
* Event handlers (stuff like OnHit immediately spring to mind - these were much easier to use than Skyrim's implementation IMO)
* REF walking (so you could "dynamically" run scripts against actors in cell even if you didn't know they would be there)
* While and For loops (although from what I remember MW also had at least while loops)
* Keyboard stuff (read in user input!)
* PrintToConsole (very handy for debugging your mods, supported output of variables)

So i'm not sure if i'm asking for a new language or simply more commands in the existing language. Skyrim introduced the new papyrus system and people learned that without too much difficulty including me so I'm up for whatever.

Posts: 10
Joined: 14 Apr 2015, 03:11

Re: SWIG Scripting Extensions project

Post by nif » 22 Mar 2016, 03:15

Just some input from an amateur programmer who would love to hack on OpenMW but knows neither C++ nor MWScript.

It would be great to have an API that can be called from my favorite (any) language. Similar I think to what maqifrnswa was working on here.

https://wiki.openmw.org/index.php?title ... n#Overview
https://github.com/maqifrnswa/openmw/tr ... -scripting

maybe though it could be implemented in such a way that it is language agnostic. Like a web server style API. So I can do an API call, get some data - manipulate that in whatever language I want - and send back data which will modify the game world in some way. Possible?

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

Re: SWIG Scripting Extensions project

Post by psi29a » 09 Oct 2018, 19:56

Calling Mr. maqifrnswa... your time has come sir, Lua won the bet. :)

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

Re: SWIG Scripting Extensions project

Post by maqifrnswa » 10 Oct 2018, 19:41

Hello all!
psi29a found me and pinged me to come back and say hi! My IRL job took off in a good way, but it also meant I don't get much time to hack or code at work or for fun anymore. I do keep watching release videos, this is still my favorite "fun" open source project, what you all have done is amazing.

I think psi29a gave the link to the source code:
https://launchpad.net/~showard314/+arch ... pa2.tar.xz

I used SWIG before (I think) so I could do both Python and LUA. This thread documents everything, and in the end I think I got it working 100% but don't remember for sure. The key was a tool I wrote that converted the existing openmw scripting source code to generate the template files and the SWIG code (it's in the above linked source code). Then you just had to do relatively small hacks to the scripting interpreter to accept mwscript, lua, or python.

I'll keep checking in, and maybe if I get time help with some coding for old-times sakes. I heard you are looking in to sol2 for LUA, that looks cool too!

Post Reply