CopyObject() and Variables

Howdy, all. I’ve been playing with CopyObject() and I’ve noticed that local variables saved on the parent object are not copied over to the child object. Was this always the case, or is this a bug introduced by a patch? I know that CopyItem() has a bCopyVars parameter, but I thought that CopyObject() did it by default. Was I wrong?

If it matters, I’m running v79.8193.5.

I don’t know, I never thought that CopyObject() would copy local variables, is it stated anywhere?
I always assumed it didn’t.

EDIT: Found this at https://nwnlexicon.com/index.php?title=CopyObject

Variables on the object are only copied to the new object for items, but not if copying a creature.

Are you trying to copy a creature by any chance? Because if you are copying an item, you can just switch to CopyItem() instead.

1 Like

I don’t think CopyObject() has ever done variables. The lexicon does say it should for items but I’ve not checked that specifically. It doesn’t for other object types. I don’t remember seeing that it did for items in the past …ah, that part is not in the offline lexicon so is why I had missed it before.

Switching to CopyItem is not always right since you lose some control over where it goes. But in many cases it can work.

Edit: fixed grammar :slight_smile:

1 Like

D’oh! I don’t know how I missed that. After testing, I can confirm the variables are copied for items, but apparently not for other object types.

Trying to copy a waypoint, actually. The function’s documentation is wrong: it works on object types other than creatures and placeables.

Thanks, I was worried that was the case.