Jump to content

SetRefVariable on Player NPC


Demeggy

Recommended Posts

Afternoon,

 

So I've had a gander around the internet, and seem to have come up blank.

 

Basically I'm trying to set the reference of a player cloned NPC via NVSE withina quest script.

 

Attempting to use the following breaks the script;

ref playerBody

set playerBody to 00000007       ;should in theory spawn the player NPC clone (I have a feeling this is where it breaks)
player.placeAtMe playerBody
playerBody.setRefVariable "clonedBodyRef" questNameHere

Any suggestions would be much appreciated!

 

D

Link to comment
Share on other sites

That's not the way I used SetRefVariable. I used that when I buildref something, not when I had to refer to something inside my own mod. Am I missing something?

 

I can't quite find any clear info on what parameters the setrefvar uses. From what I can establish;

 

nameofReftoModifyhere.setRefVariable "refNameIwantHere" nameofquestthisScriptRunsInHere

 

The last parameter (quest) I'm dubious about...

 

It should basically create a new ref for the player clone, as I eventually want to be able to utilise multiple clones of the player, each with their own unique ref (I'll be storing these ref's in an array).

 

Thanks, D

Link to comment
Share on other sites

The player doesn't use a script, therefore that variable doesn't exist anywhere. You will have to store the clones' references in some other script.


The quest parameter is optional, and should only be used if the target variable is in a quest script.

Link to comment
Share on other sites

 

That's not the way I used SetRefVariable. I used that when I buildref something, not when I had to refer to something inside my own mod. Am I missing something?

It should basically create a new ref for the player clone, as I eventually want to be able to utilise multiple clones of the player, each with their own unique ref (I'll be storing these ref's in an array).

 

Thanks, D

 

 

Then as Tomm says you don't need that.

You just Let MyCloneRef := PlaceAtMe 7 1 and then Let MyArray[someindex] := MyCloneRef

Link to comment
Share on other sites

 

 

That's not the way I used SetRefVariable. I used that when I buildref something, not when I had to refer to something inside my own mod. Am I missing something?

It should basically create a new ref for the player clone, as I eventually want to be able to utilise multiple clones of the player, each with their own unique ref (I'll be storing these ref's in an array).

 

Thanks, D

 

 

Then as Tomm says you don't need that.

You just Let MyCloneRef := PlaceAtMe 7 1 and then Let MyArray[someindex] := MyCloneRef

 

 

That's so beautifully simple, it's bound to work :)

 

Thanks, I'll give it a shot and post back my findings!

 

D

Link to comment
Share on other sites

When reading function descriptions on GECK wiki, NVSE docs or whatever, when a parameter is in italics then it means it's optional. For NVSE there are a LOT of functions that can be called two ways:

 

reference.FunctionName param1 param2

 

reference and param2 are in this case probably interchangeable. if you call it in the form:

reference.FunctionName param1

then you're calling it on a reference in the manner of say:

refVar.SetWeaponAmmo Ammo10mm

If you say:

FunctionName param1 param2

then you're calling it in the way of:

SetWeaponAmmo Ammo10mm WeapNV9mm

The first way is called "Calling by reference" and has a few extra rules. The second is "Calling by base" and applies to all forms of that type, the base form.

 

When calling by reference, you have a few methods to work with. You can call by ref variable from a quest script or some other object script, or you can call from a script that runs on the object.

 

http://www.gribbleshnibit.com/projects/NVSEDocs/#Function_Calling_Convention

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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