Talk:Extending Scripts (Papyrus)

Revision as of 01:10, 5 July 2018 by imported>Qazaaq

Using constant scripts and inheritance overrides

If you extend a script, and your extended script is of type Const. Any functions you override are ignored.

Scriptname DisableCheck extends ObjectReference Const
Function Disable(Bool abFade = false)
    ; Do Cleanup here
    Parent.Disable(abFade)
EndFunction
ObjectReference[] LinkedRefs = SomeObject.GetLinkedRefChildren()

int i = 0
while(i < LinkedRefs.Length)
   LinkedRefs[i].Disable()
   i +=1 
endwhile


For example, let's say you have the example above, your Disable function will not be called unless you explicitly cast the object as that type in a call to disable. If instead you remove Const, when the native Disable function is called, it will use your override version as expected. If a DisableCheck object was among those, the overridden version of Disable() will be called. As long as DisableCheck is not a Const type. Scrivener07 (talk) 2018-07-05T01:06:38 (EDT)

Return to "Extending Scripts (Papyrus)" page.