FiftyTifty Posted June 30, 2017 Share Posted June 30, 2017 As a bit of background, I've created a large (~500 lines) script for a follower framework that is very similar to what was in Skyrim, but with several RefCollection aliases to allow for multiple followers. Initially, I'd use a slew of if checks to determine which RefCollection to use for an NPC. But that's a right pain in the arse and super branchy. Much easier to have a function return the RefCollection I'm looking for, so I only have to call the same block of if checks. But Papyrus, far as I can tell, doesn't like returning RefCollectionAlias variables. This is one of the lines that throws an error: Function CreateRelaxMarker(Actor akActor) RefCollectionAlias refcollMarker = GetMarkerRefCollToUse(akActor) ... GetMarkerRefCollToUse() calls this code: Function GetMarkerRefCollToUse(Actor akActor) RefCollectionAlias refcollMarker RefCollectionAlias refcollFollower = GetFollowerRefCollection(akActor) if refcollFollower == AAAFyTy_FF_FollowerRefColl01 || iRefCollectionID == AAAFyTy_FF_SandboxRefColl01 refcollMarker = AAAFyTy_FF_RelaxMarkerRefColl01 ElseIf refcollFollower == AAAFyTy_FF_FollowerRefColl02 || iRefCollectionID == AAAFyTy_FF_SandboxRefColl02 refcollMarker = AAAFyTy_FF_RelaxMarkerRefColl02 ElseIf refcollFollower == AAAFyTy_FF_FollowerRefColl03 || iRefCollectionID == AAAFyTy_FF_SandboxRefColl03 refcollMarker = AAAFyTy_FF_RelaxMarkerRefColl03 EndIf refcollFollower = None Return refcollMarker EndFunction And Papyrus throws this error: G:\Temp\PapyrusTemp\FyTyFollowerFramework\AAAFyTy_FollowerFramework_QuestScript.psc(196,20): type mismatch while assigning to a refcollectionalias (cast missing or types unrelated) The problem, assuming I haven't f*#@ed something up, is that Bethesda's just half-assed their scripting system. I'd rather not have to compare integers again and again, with nested functions calling nested functions, so if there's something I'm just doing wrong here... Link to comment Share on other sites More sharing options...
Zebrina Posted July 1, 2017 Share Posted July 1, 2017 Are you missing the return type in your function declaration? In the code you pasted at least the GetMarkerRefColToUse function has no return type specified. Link to comment Share on other sites More sharing options...
FiftyTifty Posted July 1, 2017 Author Share Posted July 1, 2017 Are you missing the return type in your function declaration? In the code you pasted at least the GetMarkerRefColToUse function has no return type specified. That's probably it. The Papyrus docs on the wiki don't tell you how this is done, only that "return results the functions return type". In Pascal, you'd suffix a column and the variable type at the end of a function, but Papyrus? Nae idea. Link to comment Share on other sites More sharing options...
Zebrina Posted July 1, 2017 Share Posted July 1, 2017 It should be specified at the start of the function header, before "Function", or completely omitted if the function shouldn't return anything. Like this in your function: RefCollectionAlias Function GetMarkerRefCollToUse(Actor akActor) Link to comment Share on other sites More sharing options...
FiftyTifty Posted July 1, 2017 Author Share Posted July 1, 2017 It should be specified at the start of the function header, before "Function", or completely omitted if the function shouldn't return anything. Like this in your function: RefCollectionAlias Function GetMarkerRefCollToUse(Actor akActor) Yup, that did the trick. Much obliged man. Link to comment Share on other sites More sharing options...
Recommended Posts