IHLAL42 Posted November 9, 2021 Share Posted November 9, 2021 I've recently had a question on how exactly scripts run.I think there are too many scripts to run fully one at a time.So I speculate they are executed based on priority and time sharing.And it leads me more questions. 1. Does papyrus VM make something similar to PCB and mange scripts with it? 2. What happen if I update a script in the middle of a playthrough?The VM runs script where it remembers? or distinguish whether the script is revised or not then execute at the first line? Link to comment Share on other sites More sharing options...
niston Posted November 9, 2021 Share Posted November 9, 2021 The Papyrus VM gets a few milliseconds (2.4 milliseconds by default) per frame to process scripts.How exactly the VM schedules scripts for processing within this per-frame timeslice is unknown/undocumented.But what this means is, more FPS = more Papyrus timeslices per second. That's why Papyrus performance is worse on Consoles (30FPS) than on PC (60FPS or more).I don't know what PCB refers to in your question. PCB means Printed Circuit Board to me. You can update a script in the middle of a playthrough. There is even a console command to reload a script while the game is running.What's going to happen on a mid-playthrough update depends on the script. Running loops in a script will be stored on the stack and persisted to the save. This part of code will NOT update until it finishes executing. As long as a loop is running it will be on the stack and in the save. In fact, not even completely removing the PEX from your game will stop the loop. This is why unbound loops can very easily destroy savegames. All other parts of the script will reload from the updated PEX file.If you delete a property from a script, the VM will complain during load that the property doesn't exist anymore on that particular script and that it won't try to load it's value from the save.If you add a property, it will get initialized to it's default value, or to none or 0 or an empty string. When using the reloadscript console command, updated base classes of derived scripts will NOT reload and the command will work unreliable in these cases and might even cause a CTD. This is not a problem when reloading the entire game. Link to comment Share on other sites More sharing options...
IHLAL42 Posted November 9, 2021 Author Share Posted November 9, 2021 Thank you for your answer!It is really helpful.And I was saying PCB as Process Control Block in OS. Link to comment Share on other sites More sharing options...
niston Posted November 9, 2021 Share Posted November 9, 2021 Ah. Yeah, I don't think the scheduler is that sophisticated:For example, there is no way to set script priority. It's also exceedingly difficult -ie impossible- to force terminate a running script (such as a script that entered an unbound loop). It's possible these things exist under the hood, but if they do, they are certainly not accessible to the script programmer. Link to comment Share on other sites More sharing options...
Recommended Posts