Where to use RegisterForSingleUpdateGameTime

Post » Tue Jun 19, 2012 6:02 pm

I have a script that updates a quest status after 2 in game days but I'm not sure where to place it. My goal is to have an NPC tell the player I need 2 days to research X, come back later. Initially I tried it as a custom script in the Quest Scripts tab

Scriptname myDelayScript extends ReferenceAliasFunction StartResearch()  ; Tell us when 2 days have passed in game  RegisterForSingleUpdateGameTime(24 * 2)EndFunctionEvent OnUpdate()  If GetOwningQuest().getStage() == 10    GetOwningQuest().setStage(20)  EndIfEndEvent

The dialog that leads to this delay sets the quest stage to 10, I've tried toI add a papyrus fragment to the code that runs when that stage starts

SetObjectiveDisplayed(10)myDelayScript.StartResearch()

but attempts to compile that result in the follow error


: cannot call the member function StartResearch alone or on a type, must call it on a variable

I've tried placing it against the actor alias who's dialog it will impact with the same result. If someone could point out what I'm doing wrong, or point me to a quest/script in the game I could use an an example I would appreciate it.

Also, is there a way to search the existing game for function calls? I've tried "Find Text" but regardless what I search for the scripts result is always blank.

Thanks!

edit: fixed indention
User avatar
Claire Lynham
 
Posts: 3432
Joined: Mon Feb 12, 2007 9:42 am

Post » Tue Jun 19, 2012 10:37 am

I don't have the CK on this machine, so consider this "pseudo code," a correct approach but you may need to tweak the code a bit.

First in the quest scripts tab you'd want a quest that extends Quest:

Scriptname myDelayScript extends QuestEvent OnUpdateGameTime()  If GetOwningQuest().getStage() == 10    GetOwningQuest().setStage(20)  EndIfEndEvent

Then in the player dialogue, when your NPC says they'll need the two days, create an end fragment that is simply something like:

(GetOwningQuest() as myDelayScript).RegisterForSingleUpdateGameTime(24 * 2)

You could also do it closer to how you had it setup originally--put the register in a function in the quest script, that you call. Mainly a matter of preference. The things to note are mainly that a quest script should extend Quest and that there is a separate OnUpdateGameTime event that you'll want to catch.
User avatar
emily grieve
 
Posts: 3408
Joined: Thu Jun 22, 2006 11:55 pm

Post » Tue Jun 19, 2012 4:37 pm

Thanks DreamKing, that was exactly what I needed to know to get my script working.
User avatar
Sophie Payne
 
Posts: 3377
Joined: Thu Dec 07, 2006 6:49 am


Return to V - Skyrim