[answered] What is the execution order of scripts?

General discussion regarding the OpenMW project.
For technical support, please use the Support subforum.
Post Reply
User avatar
asmo
Posts: 229
Joined: 18 Sep 2014, 21:20

[answered] What is the execution order of scripts?

Post by asmo » 14 Sep 2015, 10:29

Hello,

is there a algorithm / rule which determines which script is executed first and when the other?

Right now I have a use case where script B shall only be executed when a condition is met in script A. It looks like that works when I'm accessing a status variable of script A at the very beginning of script B to check if the rest of B shall be executed.
However, that it works here doesn't mean that is works for other players.
So, is the execution order predictable? Maybe they are executed by name or by object type they are attached to. I remember that I read that all addons content is merged with the game data...

Thanks in advance!
Last edited by asmo on 14 Sep 2015, 17:51, edited 2 times in total.
gentoo Linux - rolling release

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

Re: What is the execution order of scripts?

Post by Zini » 14 Sep 2015, 14:11

Within a frame local scripts are executed first, then the global scripts. There is no other guaranteed order beyond that. What ever order you are seeing beyond that may change at any time and you certainly should not write scripts that depend on it.

User avatar
asmo
Posts: 229
Joined: 18 Sep 2014, 21:20

Re: What is the execution order of scripts?

Post by asmo » 14 Sep 2015, 14:36

Zini wrote:Within a frame local scripts are executed first, then the global scripts. There is no other guaranteed order beyond that. What ever order you are seeing beyond that may change at any time and you certainly should not write scripts that depend on it.
I see - then this has to be arranged by accessing status variables of the other script.
Thanks :!:
gentoo Linux - rolling release

wheybags
Posts: 207
Joined: 21 Dec 2012, 19:41

Re: [answered] What is the execution order of scripts?

Post by wheybags » 22 Sep 2015, 21:00

I hope there's not piles of mods that depend on some arbitrary sorting vanilla did ;_;

User avatar
asmo
Posts: 229
Joined: 18 Sep 2014, 21:20

Re: [answered] What is the execution order of scripts?

Post by asmo » 22 Sep 2015, 21:06

I'd like to know this as well:

script A contains

Code: Select all

 startscript B
Is B executed in the same frame where A came across that command or only in the next one?

Respectively script A contains

Code: Select all

PlaceAtPC my_NPC
and my_NPC has a script B. Is B executed in the same frame where my_NPC is placed or only in the next one?

Is both unpredictable or may the implementation change?
gentoo Linux - rolling release

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

Re: [answered] What is the execution order of scripts?

Post by Zini » 23 Sep 2015, 08:31

Is B executed in the same frame where A came across that command or only in the next one?
Could be either way. You can not rely on a specific behaviour here.
and my_NPC has a script B. Is B executed in the same frame where my_NPC is placed or only in the next one?
Same.

User avatar
asmo
Posts: 229
Joined: 18 Sep 2014, 21:20

Re: [answered] What is the execution order of scripts?

Post by asmo » 23 Sep 2015, 08:37

OK, thanks
gentoo Linux - rolling release

Post Reply