Jump to content

How do I call functions from a script that stores code snippets for the quest stages?


Recommended Posts

I have a script with fragments of the quest stages, and I'm adding a function enableObjectsAtFirstStop.

 

Scriptname QF_TXXI_DC_CarriageQuest_02002DAF Extends Quest Hidden

Function enableObjectsAtFirstStop()
	;some code
EndFunction


;BEGIN FRAGMENT Fragment_2
Function Fragment_2()
;BEGIN CODE
enableObjectsAtFirstStop()

;END CODE
EndFunction
;END FRAGMENT

;BEGIN FRAGMENT Fragment_0
Function Fragment_0()
;BEGIN CODE
SetStage(10)
;END CODE
EndFunction

If you try to compile the script from the quest scripts section, the script compiles successfully. But if I open the code of a specific stage of the quest and try to compile the code from there, I get an error: enableObjectsAtFirstStop is not a function or does not exist
How do I access this feature? (I've done this several times before, but I don't understand the principle of operation)

Link to comment
Share on other sites

Fragments are a special case. If you want separate functions you have to put them in a separate script. You can attach another script to the same quest then do: 

(GetOwningQuest() as YourScriptName).EnableObjectsAtFirstStop()

  • Like 1
Link to comment
Share on other sites

Indeed, it is generally best to put any non-fragment code in an additional script.   

That said, you could:

Put the extra function(s) at the very end of the fragments script, and

In the fragment, use Self.EnableObjectsAtFirstStop()

  • Like 1
Link to comment
Share on other sites

  • Recently Browsing   0 members

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