[post-1.0] Scripting enhancemnts

Everything about development and the OpenMW source code.
User avatar
raevol
Posts: 3093
Joined: 07 Aug 2011, 01:12
Location: Caldera

Re: [post-1.0] Scripting enhancemnts

Post by raevol »

pythonpythonpythonpythonpython
User avatar
silentthief
Posts: 456
Joined: 18 Apr 2013, 01:20
Location: Currently traversing the Ascadian Isles

Re: [post-1.0] Scripting enhancemnts

Post by silentthief »

maqifrnswa wrote:
psi29a wrote: 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
Something like meta commands? This would be something that the script compiler would look for in the first line, as a special comment that modifies the remainder of the script (which would mean that the script would be one type: as in only morrowind script,or only python, NOT mixed in the same script). Here is what I know about metacommands:

http://www.qb64.net/wiki/index.php?title=Metacommand

I played with this same thing in quickbasic (sadly, the extent of my programming skills to date, but it did help with making scripts work).

One idea of multiple scripting language use, I am sure that there are others.

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

Re: [post-1.0] Scripting enhancemnts

Post by maqifrnswa »

I started a reference implementation. I have the console intercepting commands and running them through a python interpreter and have created bindings to AiActivate (first in alphabetical order)

If I get a chance I need to test some more, but if others want to play:

https://github.com/maqifrnswa/openmw/tr ... -scripting

You need python-dev and swig installed to build. Normal building will work.

You can mess with the mwmygui console.CPP and insert your python in there (hardcode or write something to parse console input, right now it will run whatever you hard code when you enter "python-test" in the console). If you hard code in console.CPP, remember you're in python! You can also try import openmw, that will get you a binding to AiActivate.

It's just a proof of concept, but what scripting function is best for me to implement to continue testing?

Once I've demonstrated a simple script, I'll work on documenting how it works and how to use it.
User avatar
sjek
Posts: 442
Joined: 22 Nov 2014, 10:51

Re: [post-1.0] Scripting enhancemnts

Post by sjek »

what would be needed to activate several object in same cell at the same time

viewtopic.php?f=3&t=2554&p=28617 this goes as little bit more advances but would be roof of concept if would be able to call, say, every scamp on the cell and for the sake of simplicity with their each ID known so it's basically calling entities on a list to do something

thinking about army casting all invisibility to them and such mass behaviors (impossible at vanilla :D )

or make creature cast only visibility and so on althought dunno how much of these are already possible
http://www.fliggerty.com/phpBB3/viewtop ... =30&t=1798 (engine trustration)

if it's made with external handle does it work still when the optimisation takes place althought some blocks might go to moving would think that majority is in place depending how much script calling need to do ?
User avatar
sjek
Posts: 442
Joined: 22 Nov 2014, 10:51

Re: [post-1.0] Scripting enhancemnts

Post by sjek »

http://www.uesp.net/wiki/Tes3Mod:Alphab ... ction_List like really........ :shock: ^^
https://wiki.openmw.org/index.php?title ... g_(status)

yeah. which one would be good .?

http://www.uesp.net/wiki/Tes3Mod:AIActivate even with that one some activator to flying or running around and other one chasing without attacking ....
maqifrnswa
Posts: 180
Joined: 14 Jan 2013, 03:57

Re: [post-1.0] Scripting enhancemnts

Post by maqifrnswa »

quick reply - I pushed some commits, haven't tested them at all yet but if you type "test.py" into the openmw console, it will run the script "test.py" in the same directory as the openmw executible. Right now, it will only run the script if it is named "test.py" Apparently this might not work on windows at the moment, depending on how the python library was compiled. Windows support is very possible, but i'm on linux so it's easier for me to just worry about that for now.
https://github.com/maqifrnswa/openmw/tr ... -scripting

to test AiActiviate, make this test.py:

Code: Select all

from openmw import *
AiActivate("ACTORID","OBJECTID")
ACTORID and OBJECTID should be in quotes, and requests ACTORID to activate OBJECTID.
http://www.uesp.net/morrow/editor/mw_cs ... aiactivate

I haven't tested it and won't have time for a little while, I just wanted to put this out there in case others wanted to look at it
Last edited by maqifrnswa on 29 Dec 2014, 17:52, edited 4 times in total.
maqifrnswa
Posts: 180
Joined: 14 Jan 2013, 03:57

Re: [post-1.0] Scripting enhancemnts

Post by maqifrnswa »

sjek wrote:what would be needed to activate several object in same cell at the same time

viewtopic.php?f=3&t=2554&p=28617 this goes as little bit more advances but would be roof of concept if would be able to call, say, every scamp on the cell and for the sake of simplicity with their each ID known so it's basically calling entities on a list to do something

thinking about army casting all invisibility to them and such mass behaviors (impossible at vanilla :D )

or make creature cast only visibility and so on althought dunno how much of these are already possible
http://www.fliggerty.com/phpBB3/viewtop ... =30&t=1798 (engine trustration)

if it's made with external handle does it work still when the optimisation takes place althought some blocks might go to moving would think that majority is in place depending how much script calling need to do ?
for now i'm just implementing the morrowind script functions in python, but with python it is much easier to iterate over lists of things and have access to more data structures, it should be easier to script up
maqifrnswa
Posts: 180
Joined: 14 Jan 2013, 03:57

Re: [post-1.0] Scripting enhancemnts

Post by maqifrnswa »

IT'S ALIVE!
https://github.com/maqifrnswa/openmw/tr ... -scripting

I just played and ran a python script that set my bounty to 1 million dollars.

Code: Select all

PYTHONPATH=. ./openmw --start="Seyda Neen" --skip-menu
in the console I typed

Code: Select all

test.py
and I got owned!

for this to work, you place your python script named "test.py" in the same directory as openmw

here was my test.py:

Code: Select all

from openmw import *
SetPCCrimeLevel(1000000)
So if you'd like a get-out-of-jail free card, set the value to zero and walk around murdering people to your heart's content, then run test.py in the console ;-)

next step is to clean up the build system and to start brainstorming the best way to interface with the current scripting system (and how to track context/script ownership, get managed by the scriptmanager, etc.)
I'm thinking we'll intercept scripts and commands at scriptmanager->run and console->run
User avatar
psi29a
Posts: 5361
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: [post-1.0] Scripting enhancemnts

Post by psi29a »

maqifrnswa wrote:I'm thinking we'll intercept scripts and commands at scriptmanager->run and console->run
Do this, and you'll be my hero... again! :D

Seriously, this for me makes it all worth while. It doesn't break current scripting for those used to it, and adds a level of sophistication above that non-programmers can grasp and those with an software background can get right into making things work without having to deal with the rough edges of the original scripting language.

@Zini: You on board here? We don't want anyone to put time into something you'll reject. I'de rather get input from you (and others) now. :)
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: [post-1.0] Scripting enhancemnts

Post by Zini »

Sorry, I thought I made that clear already (a long time ago and multiple times).

Python is a no go in my opinion, because fully sandboxing it is very hard to impossible. Call me paranoid, but I see even the possibility of having viruses in OpenMW content files as a major disaster.

Also, I think it will be harmful to have more than one scripting language. It is a needless duplication of effort. We would not only have to maintain two languages, but also editor functions for two languages and debugging features for two languages.

Lastly, there is no need for a second language. The Python integration is an interesting experiment (and kinda impressive), but it does not actually moves us forward. The existing language (with a few enhancements and without all the bug-tolerance workarounds) will be doing fine.
Post Reply