Script seems to keep running after being removed

Post » Sat Mar 08, 2014 9:48 am

I have basically two errors I simply can't get rid from my scripts:

1. "Unable to call X - no native object bound to the script object, or object is of incorrect type"

2. "Cannot call X() on a None object, aborting function call"

For example, one script at certain point calls RegisterForSingleUpdate() and is not able to find the native object, thus the logged error #1.

The error #2 usually happens when I try to call a SetValue() on a Global Variable. The variable simply seems to not exist anymore at that point.

They always happen when the ActiveMagicEffect is removed from the player (for example, when I cast the spell again and the previous effect is overwritten). I believe the problem here is the script keeps ticking after being removed. That is, the effect seems to be dispelled , but anything running inside the OnUpdate() event keep running till find a null reference.

So, is there a solution for this?

Thanks.

User avatar
Daddy Cool!
 
Posts: 3381
Joined: Tue Aug 21, 2007 5:34 pm

Post » Sat Mar 08, 2014 11:33 am

yes, surround your code with a null check on the magic effect.

if (self)    ;do thingselse    returnendif

There's no solution for the problem, once a magic effect is removed any further script commands called on it will fail in the manner you describe.

User avatar
Marquis deVille
 
Posts: 3409
Joined: Thu Jul 26, 2007 8:24 am


Return to V - Skyrim