Jump to content

Help Please With Structs/F4SE Function


JigsJosh

Recommended Posts

Hey all. I can't figure out for the life of me how to use the F4SE function GetMiscComponents() to return the info I need. I was hoping someone experienced with papyrus could help.

MiscComponent[] Function GetMiscComponents() Native

Here is the syntax of the function.

MiscComponent[] Function CalcLooseModComps(MiscObject akTheMod)
	MiscComponent[] array = new MiscComponent[10]
	array = akTheMod.GetMiscComponents()	;something else needs to be done here
EndFunction

Here is the code I'm working on. This doesn't compile. MiscComponent is not a type, it's a MiscObject struct. So I assumed that because GetMiscComponents() is a MiscComponent[] Function that it would return an array of MiscComponent structs. But this is not the case. At least for how my code is set up.

The compiler error I get: "type mismatch while assigning to a jjrecyclerscript#misccomponent[] (cast missing or types unrelated)".

I tried to cast this a few different ways too but still nothing. I was hoping someone with more knowledge could help me out to get this code working. I honestly don't know much about structs so it's a bit confusing. And unfortunately there aren't any examples on the CK wiki of how to use this script.

 

 

Link to comment
Share on other sites

Thank you for the reply! I tried that out and it compiled! Kudos to you!

 

The compiled code:

MiscObject:MiscComponent[] Function CalcLooseModComps(MiscObject akTheMod)
	MiscObject:MiscComponent[] array = new MiscObject:MiscComponent[10]
	array = akTheMod.GetMiscComponents()	
	Return array 
EndFunction
Link to comment
Share on other sites

  • Recently Browsing   0 members

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