Jump to content
ℹ️ Intermittent Download History issues ×

[LE] I have a script that works fine most of the time. On the 4th use, the script stops cold. (source gist included)


monsto

Recommended Posts

Alright so basically you're saying that it's risky, which I get.

 

Good thoughts. Thank you.

Not necessarily that it is risky, just that certain precautions need to be made when using it. As an example, I use similar code in some of my own mods with no ill effects.
Link to comment
Share on other sites

Yeah, a loop while not 3Dloaded is okay in *some* circumstances -- for example if it's in an event which *should* make the item load -- but because it can very easily not fire as expected, it's best to put a timer on the maximum time to wait *and* some kind of fail-gracefully exit method.

 

The reason to offload things from OnIniit() is that OnInit() code has two special properties:

 

1. While an OnInit() event is executing no external calls into the script can be made.

2. ... except from other script's OnInit() events.

 

This can cause unexpected behaviour and should generally be kept to stuff that is as fast and as minimal as possible, with a very short RegisterForSingleUpdate()/OnUpdate() pair to do the heavy lifting. States can be used to overload the functions and events to behave differently once the initialization is complete.

 

I am not certain from inspection what is causing the script lockup. Usual causes for the symptoms described are infinite loops or the script object getting garbage cleaned for some reason.

 

Ordinarily for doing a twinned disable/enable I would recommend linking them together in the editor with the mannequin as an enable-parent of the pedestal. However what ones are active appear to be dynamically defined, which makes that a no-go.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...