Difference between revisions of "Talk:Script File Structure"
Jump to navigation
Jump to search
imported>Qazaaq (→Imports with global import via inheritance: new section) |
imported>Qazaaq |
||
| Line 23: | Line 23: | ||
</source> | </source> | ||
<source lang="text"> | |||
global function MyGlobalFunction cannot be called on an object | |||
Error while trying to typecheck script MyNamespace:Object: Index (zero based) must be greater than or equal to zero and less than the size of theNo output generated for MyNamespace\Object.psc, compilation failed. | |||
</source> | |||
The error above goes away and can be imported if the globals are relocated to a script outside the `Objects` inheritance. | The error above goes away and can be imported if the globals are relocated to a script outside the `Objects` inheritance. | ||
Revision as of 15:15, 6 August 2017
Imports with global import via inheritance
I may have found a quirk when importing global functions from another script. If the global functions you're importing are from a direct parent via inheritance, the compiler cannot resolve the global function.
Papyrus
Scriptname MyNamespace:ObjectBase
Function MyGlobalFunction() Global
{Global Function}
EndFunction
Scriptname MyNamespace:Object extends MyNamespace:ObjectBase
import MyNamespace:ObjectBase
Event OnInit()
MyGlobalFunction()
EndEventglobal function MyGlobalFunction cannot be called on an object
Error while trying to typecheck script MyNamespace:Object: Index (zero based) must be greater than or equal to zero and less than the size of theNo output generated for MyNamespace\Object.psc, compilation failed.
The error above goes away and can be imported if the globals are relocated to a script outside the `Objects` inheritance.
Scriptname MyNamespace:Other
Function MyGlobalFunction() Global
{Global Function}
EndFunction
Scriptname MyNamespace:Object extends MyNamespace:ObjectBase
import MyNamespace:Other
Event OnInit()
MyGlobalFunction()
EndEventScrivener07 (talk) 2017-08-06T16:13:12 (EDT)