Jump to content

Compile error when adding a function to an existing vanilla script


Recommended Posts

Greetings

So, I'm practicing the use of functions to handle properties to get a better code structure (suggested in this post https://forums.nexusmods.com/topic/13494349-how-to-avoid-this-excessive-number-of-ifelseif-statements/).

But i'm getting these compile errors when adding a function to an existing vanilla script:

mismatched input 'Function' expecting ENDFUNCTION
missing EOF at 'EndFunction'

 


image.png.5e4ec1c0233dc5330ebc2db71cad84e0.png

Edited by SlyraksL
adding tags
Link to comment
Share on other sites

You can't add your own functions to fragments because fragments are already their own function and you can't add functions inside of other functions in papyrus. A common thing for fragments though is to call your code somewhere else. For example, add a script to the quest that the fragment is on. 

Scriptname MyQuestScript Extends Quest 

Function SameAmount() 

EndFunction 

 

Then in your fragment you can do: 

(GetOwningQuest() as MyQuestScript).SameAmount()

Link to comment
Share on other sites

20 minutes ago, dylbill said:

You can't add your own functions to fragments because fragments are already their own function and you can't add functions inside of other functions in papyrus. A common thing for fragments though is to call your code somewhere else. For example, add a script to the quest that the fragment is on. 

Scriptname MyQuestScript Extends Quest 

Function SameAmount() 

EndFunction 

 

Then in your fragment you can do: 

(GetOwningQuest() as MyQuestScript).SameAmount()

It worked, Thank you!

Link to comment
Share on other sites

  • Recently Browsing   0 members

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