Passing Object Reference to Quest Script

Post » Thu Jun 21, 2012 10:34 am

How do you pass an object reference to a quest script?

Here's my script on the object reference:
Scriptname ABGrabTestScript extends ObjectReference  ABGrabTestQuestScript Property grabQuestRef AutoEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack,  bool abBashAttack, bool abHitBlocked)        ; should also check that source is spell        debug.notification("I've been hit")        if akAggressor == Game.GetPlayer()            grabQuestRef.curObject = self            debug.trace("Object: " + self)        EndIfEndEvent

I've confirmed that self has the reference I want. But when I test curObject in my quest script, it's always None.

Scriptname ABGrabTestQuestScript extends QuestObjectReference Property curObject Autofloat angleZEvent onInit()    registerForUpdate(0.1)endEventEvent onUpdate()    if (curObject != None)    ... rest of script ...

I've put some debugging statements in the onUpdate event and confirmed that curObject is never set.
User avatar
Cccurly
 
Posts: 3381
Joined: Mon Apr 09, 2007 8:18 pm

Post » Thu Jun 21, 2012 9:56 am

For this kind of stuff I prefer to use a "local way"
first create a function that set the object you want to store:

Scriptname ABGrabTestQuestScript extends QuestObjectReference curObject = noneFunction setcurObject(objectreference oRef)curObject = oRefendFunction

then call it in the objectReference script


Scriptname ABGrabTestScript extends ObjectReference  ABGrabTestQuestScript Property grabQuestRef AutoEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack,  bool abBashAttack, bool abHitBlocked)        ; should also check that source is spell        debug.notification("I've been hit")        if akAggressor == Game.GetPlayer()            grabQuestRef.setcurObject(self)            debug.trace("Object: " + self)        EndIfEndEvent
User avatar
Donald Richards
 
Posts: 3378
Joined: Sat Jun 30, 2007 3:59 am

Post » Thu Jun 21, 2012 3:57 am

Did you remember to set the value of grabQuestRef to your quest? Is OnUpdate actually running? Those are the only things I can think of.
User avatar
RaeAnne
 
Posts: 3427
Joined: Sat Jun 24, 2006 6:40 pm

Post » Thu Jun 21, 2012 7:33 am

For this kind of stuff I prefer to use a "local way"
first create a function that set the object you want to store:

Scriptname ABGrabTestQuestScript extends QuestObjectReference curObject = noneFunction setcurObject(objectreference oRef)curObject = oRefendFunction

then call it in the objectReference script


Scriptname ABGrabTestScript extends ObjectReference  ABGrabTestQuestScript Property grabQuestRef AutoEvent OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack,  bool abBashAttack, bool abHitBlocked)		; should also check that source is spell		debug.notification("I've been hit")		if akAggressor == Game.GetPlayer()			grabQuestRef.setcurObject(self)			debug.trace("Object: " + self)		EndIfEndEvent

I'll give that a try - thanks. I certainly like how explicit it is, so it will be easier to follow.

Did you remember to set the value of grabQuestRef to your quest? Is OnUpdate actually running? Those are the only things I can think of.

I was following the example http://www.creationkit.com/Variables_and_Properties_%28Papyrus%29. This isn't a quest result script. The first script is a script on an object reference. The second script is the quest script. OnUpdate is running. I had a debug.notification statement in there and it was firing regularly.
User avatar
sw1ss
 
Posts: 3461
Joined: Wed Nov 28, 2007 8:02 pm

Post » Wed Jun 20, 2012 10:38 pm

I'm not sure what you mean by a quest result script. I was just talking about http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Introduction_to_Properties#Hooking_up_the_message_boxes_to_the_properties_in_the_script to your grabQuestRef property.
User avatar
Ross Zombie
 
Posts: 3328
Joined: Wed Jul 11, 2007 5:40 pm

Post » Thu Jun 21, 2012 6:59 am

In that article that I linked, they didn't list that as being necessary. They only talked about assigning a quest variable when you were working with quest result scripts. I'll have a look at the properties and see what options there are. Thanks.
User avatar
Rob
 
Posts: 3448
Joined: Fri Jul 13, 2007 12:26 am


Return to V - Skyrim