[post-1.0] Scripting enhancemnts

Everything about development and the OpenMW source code.
qqqbbb
Posts: 19
Joined: 29 Aug 2012, 14:18

Re: [post-1.0] Scripting enhancemnts

Post by qqqbbb » 21 Jul 2015, 12:02

Let's say we have 2 scripts:

Code: Select all

Begin script1
short done
if ( done == 0 )
   ; lots of lines of code
   set done to 1
endif
end

Code: Select all

Begin script2
short done
if ( done == 1 )
   return
endif
; lots of lines of code
set done to 1
end
In vanilla game script2 takes less CPU time than script1. What about OpenMW?

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

Re: [post-1.0] Scripting enhancemnts

Post by Zini » 21 Jul 2015, 21:21

You could measure ... ;)

But the performance is probably about the same between script1 and script2.

Envy123
Posts: 45
Joined: 23 Aug 2013, 16:26

Re: [post-1.0] Scripting enhancemnts

Post by Envy123 » 06 Aug 2015, 12:00

In later TES games, any object can have their own references and they can be set Initially Disabled. This is much more performance friendly than having a start up script disabling the references.

Would it be possible to have this, post 1.0?

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

Re: [post-1.0] Scripting enhancemnts

Post by Zini » 06 Aug 2015, 13:27

That has nothing to do with scripting. Currently the content file format does not contain a flag for instance (reference) enable/disable. Adding one is an option post 1.0. Not for performance reasons though (that should hardly matter), but for improving the content development process.

Envy123
Posts: 45
Joined: 23 Aug 2013, 16:26

Re: [post-1.0] Scripting enhancemnts

Post by Envy123 » 06 Aug 2015, 19:43

Zini wrote:That has nothing to do with scripting. Currently the content file format does not contain a flag for instance (reference) enable/disable. Adding one is an option post 1.0. Not for performance reasons though (that should hardly matter), but for improving the content development process.
Well, it does say scripting improvements and I interpreted it as improvements to the scripting workflow and the performance of the mod.

I always had to disable certain items every frame (or in a starting script) or Morrowind would mess up something (in my experience). I just wish I didn't have to do that because it's performance heavy. Having a flag to enable or disable a reference would reduce the need for all those pesky workarounds.

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

Re: [post-1.0] Scripting enhancemnts

Post by Zini » 07 Aug 2015, 10:09

I always had to disable certain items every frame (or in a starting script) or Morrowind would mess up something (in my experience). I just wish I didn't have to do that because it's performance heavy. Having a flag to enable or disable a reference would reduce the need for all those pesky workarounds.
That is something you should avoid, if you are aiming for OpenMW only (and probably in general). Morrowind.esm does something similar and we have some workarounds in place to reduce the impact, but it is still bad for performance (even worse compared to vanilla MW, because internally OpenMW works quite a bit differently).

For now the correct way to disabling things on startup is to place a script on a local object within the respective cell that disables the required objects on first run.

User avatar
sjek
Posts: 429
Joined: 22 Nov 2014, 10:51

Re: [post-1.0] Scripting enhancemnts

Post by sjek » 01 Nov 2015, 00:29

if there's not much difference than behaviour of getinterior script command (getwindspeed to detect interior as exterior) and so on. could it be done with good ingame speed via ?cell function which would return asked variables from within code / file format, be it average windspeed, weather pattern, name, id, item list, npc's, etc.

or separate it to subcategories.

Code: Select all

short doonce
if (doonce == 0)
  cell, balmora (coordinates optional)::getref::npc::randomcount x -> addtopic "where's that guar"
  cell, balmora (coordinates optional)::getref::weapon -> set::damage 0 
endif
or

Code: Select all

short doonce
if (doonce == 0)
  cell, balmora (coordinates optional), getref, npc, randomcount x -> addtopic "where's that guar"
  cell, balmora (coordinates optional), getref, weapon -> set, damage 0 
endif
don't know if marking :: or something would be reguired as can the getaipackagedone, AIwander search for AIwander part be extended freely to function / list search instead of variables or does it differ?

adding :: is more readable but then again it would be possibly only usability improvement as old style would still be used.

with :: or , it would handle getting interior, exterior, worldspace or anything what someone wants to implement with cell flag.

Code: Select all

if (get, interior == 1)
if (get, exterior == 1)
if (get, worldspace ==1)
------------------------------------------------------------------------------------------

writing if can feel cumbersome after doing a while but without any coding it hard to tell from operators and syntax if it's if, set, get, while, etc. just 2 cents. messing with nested if endif extravaganza there's possibility for syntax highlighting fortunately

other way around long ifs could be lines after if / while statement making it possibly even more readable although long

Code: Select all

if cell 
{
     balmora
     getref
     npc
     randomcount x
} -> addtopic "where's that guar"
this would take advantage or differentiating special case from one function per line rule.


then again with springs lightly same method could be used

Code: Select all

if  ( cell, balmora == 1 )
    function (getref, npc, randomcount x) -> addtopic "where's that guar"
    function (getref, weapon) -> setdamage 0
endif
which if possible could use same underplaying mechanics.

PS...................

Basically how to counter writing if clauses for every condition in the future or is there possibility for shortcuts ( some are in the document )

don't know alternatives to nested if clauses
1
2
3
2
3
4
2
3
1
2
3
1
than ui and code writing
..writing a spell that summons cushions under feet to act as a stairs and keeping the numbers in 2 with setdelete all in global script. also gotta try with move variables
Last edited by sjek on 07 Nov 2015, 13:27, edited 1 time in total.
"life is crazy"
"craziness has beauty which only crazies understand" some movie clip in the head.
https://wiki.openmw.org/index.php?title=Testing

User avatar
sjek
Posts: 429
Joined: 22 Nov 2014, 10:51

Re: [post-1.0] Scripting enhancemnts

Post by sjek » 01 Nov 2015, 10:48

.... now looking at it, there's really not much difference in c++ and mwscript :D

details of caurse, but how it's written.
return act also as incode messagebox, variable / function allocation is inside include files, etc..
also built in mwscript return handling or apsence of it, it seems. making little bit harder to read but more flowing.

data being loaded from openmw/components and used in openmw/apps/openmw gattered around based on game mechanics could indeed make subcategory based reference search hard to implement.

so it's more restricted to what is used as classes...... ?
basically needing to use those, writing cpp and hpp to components to look out for classes made in other files and then referring to that in apps/openmw or referred? folder to handle the script with wanted code syntax.
to keep code clean from references.

otherwise just getting, get ?/?weapon like search list to what make function upon, which works kinda well with current syntax.

later would be possibly deprecated with getref, type function

Code: Select all

if (doonce == 0)
if cell, balmora (coordinates optional) == 1
  if get ?/?npc == 1 
    searchrandom (parameters) -> addtopic "where's that guar"
that wouldn't handle the multiple if line problem thought.

Code: Select all

instead could lined function be possible 
if (x == 1) ----> (y == 2 ) ----> ( z == 0,5 ) ..............

[b][u]then again with springs or list [/u][/b]
if ( x || y || z) == (1 || 2 || 0,5) 
handling it better without massive oneliners.
Last edited by sjek on 07 Nov 2015, 13:28, edited 1 time in total.
"life is crazy"
"craziness has beauty which only crazies understand" some movie clip in the head.
https://wiki.openmw.org/index.php?title=Testing

User avatar
sjek
Posts: 429
Joined: 22 Nov 2014, 10:51

Re: [post-1.0] Scripting enhancemnts

Post by sjek » 07 Nov 2015, 13:25

one idea what comes to mind is the possibility to define vectors in script. (possibly mentioned somewhere)

this would play with getangle, setangle and rotate functions defining arbitrary axis and possibly also with move.
making it possibly to make any kind of rotation, if two or more be possibly to pinpoint to one object.

also list / vectors working with variables could allow numerical calculations or simulations ingame x) ,which should be basically possible already besides direct matrices as the variables can be used with world / object axis in existing functions
solaris math mod http://mw.modhistory.com/download-45-11653
possibly being expanded. defining in the code would only bring performance gains / making it more sophisticated.

on the referencing this possibly needs on the fly creating duplicate unique referenced and also deleting / discarding them after runtime

to sum up:
should the vector definition be individual or read a list as vector at proper places?
is the reference duplicate or engine created dummy object with desired mesh better?
"life is crazy"
"craziness has beauty which only crazies understand" some movie clip in the head.
https://wiki.openmw.org/index.php?title=Testing

Post Reply