Jump to content
  • entries
    8
  • comments
    3
  • views
    2,285

CHAPTER 5: Interesting capabilities of the script engine.


GenioMaestro

564 views

One of the most interesting points in the Skyrim scripting engine is the ability to suspend the scripts. This ability is used in each frame, but is used in other situations.
Each time a script makes an external call, the script is suspended and this means that the script is not executed for ALL the assigned time of 1.2 or 1.6 milliseconds.
For example, a script gets the execution status and immediately calls another script. At that time, the game stops the main script and places the called script in the execution queue.
In the next frame, the game executes the called script and when it finishes, it puts the main script back in the execution queue.
This means that, normally, a script does not run for ALL the assigned time of 1.2 or 1.6 milliseconds, but it also means that a script may need several frames to run.
This ability guarantees that the game can execute many scripts at the same time, because many of them can be in a suspended state, but the bad part is the number of frames needed to execute it.
 

Using this system, the ability of the game is really impressive because you can run hundreds and hundreds of scripts at the same time.
But this number can reach thousands when a mod has problems.
You can see a recent post from a user that reports 6600 active scripts. And I've seen more ... many more ...
Of course, those are games with problems because that is not normal. But it is really impressive.
 

Spoiler

actives26k.png.38c083ee07ced9c8045d9b4f3c3a6196.png

 

I mentioned the execution queue before and it's another very interesting thing in the Skyrim script engine. It seems that this execution queue has priorities.
And this means, for example, that some scripts are executed before other scripts. This is a common technique in the programming of multi-threaded systems.
The priority determines when a script should be executed and this priority is used by the game to have a good response time.

 

When a script request a update in 5 seconds the game put that script in the exact position of the execution queue for be called in the exact moment.
In the same way, when a mod have some events registered the game call the scripts related to the events inmediately in the next frame.
That events are for example, magic effect, animation events, inventory management... all the events that must react to actions in the game.
When an npc launch a spell the asociated script can not wait and must be executed ASAP and the Script Engine put it in the execution queue inmediatelly.
In that way, some scripts are executed before others, because the execution queue is filled first whit the calls from new events.

 

But not everything is good because the ability to suspend the script is executed in the opposite way. Think a little and maybe you have the answer.
Yes, the script of a magic effect can start running immediately, but ... What happens when another function is called? Yes, the script is suspended and it loses its priority.
And the script should wait for the return of the called script. And for that reason, in some bad situations you can have thousands and thousands of active scripts.
Especially if the game calls the script again before the script finishes executing. In that situation, the count of active scripts can begin to grow to incredible points and cause problems to the game.

0 Comments


Recommended Comments

There are no comments to display.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use