Jump to content

How to detect if ObjectReference has lost it's reference without getting an error?


Recommended Posts

Posted (edited)

Hey ppl,

In the Mod I am currently working on, I may, from time to time stumble upon an ObjectReference which has lost it's reference, thus giving the "no native object bound to the script object, or object is of incorrect type" if I try to manipulate it.

The issue is that it cannot be just checked against with a comparison to NONE, checking if IsBoundGameObjectAvailable also does not detect the issue. Other method calls would trigger the error.

Checking if 3d is loaded, or waiting for 3d to load also triggers the error. It usually shows up as a <nullptr form>.

In C# I would use a Try/Catch to handle this properly. But I can't in here. Is there some method that I am missing?

Maybe some trick I can do to detect it without triggering the issue?

Thanks,

OldBard.

Edited by SameOldBard
Improving a bit the explanation
Link to comment
Share on other sites

Check against nullptr without any error in vanilla Papyrus? I can't think of any "tricks" that don't log an error. You can try ( If Game.GetForm(NullptrRef.GetFormID()) != None ). In theory, this would only post one error and GetForm would return None.

Link to comment
Share on other sites

Thanks LarannKiar. That did indeed help with detecting it. But yes, it wouldn't avoid an error, but it let's me manage it.

Though this mod is giving me so much trouble that I'm tempted to give it some time before finishing it. It feels like I've been almost finishing it for a month (sure, I only have an hour or two per day to work on it, but still).

Anyway. Thank you for providing a way to handle the situation. I do have another question, with the current problem I have, but it is not related to the topic. I guess I should create a new topic instead.

Thanks again,

OldBard

Link to comment
Share on other sites

  • Recently Browsing   0 members

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