Calling an external function in a dialogue fragment?

Post » Sun May 18, 2014 7:28 am

Hi everyone,

I was wondering, whether it is possible to call a function declared in a library-script in Quest B in a dialogue fragment of Quest A. This is the function:

Spoiler

Function AddKnowledgePoint()

if !(NQ02_NewHorizons.IsObjectiveCompleted(5))
_00E_NQ02_KnowledgeGathered.SetValue(_00E_NQ02_KnowledgeGathered.GetValue() + 1)
NQ02_NewHorizons.UpdateCurrentInstanceGlobal(_00E_NQ02_KnowledgeGathered)
int CurrentCount = _00E_NQ02_KnowledgeGathered.GetValueInt()

if CurrentCount >= 50
NQ02_NewHorizons.SetObjectiveCompleted(5, 1)
ElseIf CurrentCount < 50
NQ02_NewHorizons.SetObjectiveCompleted(5,0)
NQ02_NewHorizons.SetObjectiveDisplayed(5, True, True)
EndIf

EndIf

EndFunction

I tried importing it into the Quest-Fragment script attached to Quest A, but that doesn't seem to work. Is there a way to do this?

Thanks! :)

All the best,

Nicolas

User avatar
April D. F
 
Posts: 3346
Joined: Wed Mar 21, 2007 8:41 pm

Post » Sun May 18, 2014 12:28 am

You have two options:

- Create a property with the type set to be the name of the library script

SCRIPTNAME Property VARIABLENAME AutoVARIABLENAME.AddKnowledgePoint()

- Create a quest property and cast the property as the name of the library script

Quest Property VARIABLENAME Auto(VARIABLENAME as SCRIPTNAME).AddKnowledgePoint()
User avatar
Cassie Boyle
 
Posts: 3468
Joined: Sun Nov 05, 2006 9:33 am

Post » Sun May 18, 2014 12:40 am

^what he said. Also, if it really is just a library type function, you could create a script that extends quest, and then use that script as the base for both quests. So both quests have access to the additional functions
User avatar
Charity Hughes
 
Posts: 3408
Joined: Sat Mar 17, 2007 3:22 pm

Post » Sun May 18, 2014 6:36 am

And if you end up extending quests, then you need to remember that properties carry over from the parent script to the child script.

User avatar
Aman Bhattal
 
Posts: 3424
Joined: Sun Dec 17, 2006 12:01 am

Post » Sat May 17, 2014 11:40 pm

Okay, so I need to attach that property to the quest script? :)

User avatar
Stay-C
 
Posts: 3514
Joined: Sun Jul 16, 2006 2:04 am

Post » Sun May 18, 2014 10:24 am

No, the property should be added to the dialogue fragment in quest A.

User avatar
Veronica Flores
 
Posts: 3308
Joined: Mon Sep 11, 2006 5:26 pm

Post » Sun May 18, 2014 5:28 am

Ah! Fair enough. And I suppose I have do to that through the editor? (Edit Source), don't I? I have never added Script variables. :)

User avatar
M!KkI
 
Posts: 3401
Joined: Sun Jul 16, 2006 7:50 am

Post » Sun May 18, 2014 2:02 am

You can either do it by editing the script itself or by opening the Properties window for the dialogue fragment. If you edit the script itself, then I think you need to add the property at the very bottom of the script as the compiler doesn't like it if you put the declaration somewhere inside the area surrounded by comments stating not to edit anything between them.

User avatar
Shaylee Shaw
 
Posts: 3457
Joined: Wed Feb 21, 2007 8:55 pm

Post » Sun May 18, 2014 12:01 am

Hm! I did exactly what you said, but nothing happens, even though it all compiles fine. He doesn't even call the function - I checked that via Debug-Trace. This is the property I attached:

_00E_NQ02_NewHorizons_Library Property HorizonLibrary Auto

... and this is the code of the fragment:

HorizonLibrary.AddKnowledgePoint()

Like I said, it compiles, but nothing happens. Did I overlook something?

User avatar
Ashley Hill
 
Posts: 3516
Joined: Tue Jul 04, 2006 5:27 am

Post » Sun May 18, 2014 12:33 am

Have you filled the property as well? It should be filled with the quest you have the library script attached to. I suspect CK can find the script and the function or it wouldn't have compiled. However the problem may be that CK doesn't know which instance of the script to use.

User avatar
Gemma Archer
 
Posts: 3492
Joined: Sun Jul 16, 2006 12:02 am

Post » Sun May 18, 2014 10:40 am

Yep, I have filled it. Weird! Does the Library script need to extend anything? This is what it looks like:

Spoiler

Scriptname _00E_NQ02_NewHorizons_Library

Function AddKnowledgePoint()

Debug.Notification("Function called")

if !(NQ02_NewHorizons.IsObjectiveCompleted(5))
_00E_NQ02_KnowledgeGathered.SetValue(_00E_NQ02_KnowledgeGathered.GetValue() + 1)
NQ02_NewHorizons.UpdateCurrentInstanceGlobal(_00E_NQ02_KnowledgeGathered)
int CurrentCount = _00E_NQ02_KnowledgeGathered.GetValueInt()
Debug.Notification("Variable set to" + _00E_NQ02_KnowledgeGathered.GetValueInt())

if CurrentCount >= 50
NQ02_NewHorizons.SetObjectiveCompleted(5, 1)
ElseIf CurrentCount < 50
NQ02_NewHorizons.SetObjectiveCompleted(5,0)
NQ02_NewHorizons.SetObjectiveDisplayed(5, True, True)
EndIf

EndIf

EndFunction

Quest Property NQ02_NewHorizons Auto
GlobalVariable Property _00E_NQ02_KnowledgeGathered Auto

User avatar
Joey Bel
 
Posts: 3487
Joined: Sun Jan 07, 2007 9:44 am

Post » Sun May 18, 2014 12:16 pm

You could try making the script extend the Quest script. I've had a few problems in the past with scripts, which didn't extend ReferenceAlias, attached to ReferenceAliases and I had to change it. Might be a similar problem.

User avatar
Gavin boyce
 
Posts: 3436
Joined: Sat Jul 28, 2007 11:19 pm

Post » Sun May 18, 2014 4:39 am

Okay, I found the problem. I actually did forget to fill in the value of the property - Once I said it to the quest the dialoge fragment was a part of, it all worked like a charm. Thanks for your help! :)

User avatar
Jennifer May
 
Posts: 3376
Joined: Thu Aug 16, 2007 3:51 pm


Return to V - Skyrim