Jump to content

Creation Kit Manual Is Wrong?


Recommended Posts

I'm following this page for arrays manipulation in papyrus. In particular, there's this line of interest there:

BugArrayHolder holder = ((self.placeAtMe(arrayHolder) as Form) as BugArrayholder)

Where the "BugArrayHolder" is defined as

Scriptname BugArrayHolder extends Form

String[] Property stringArray auto

So it is a child for the Form script. Now, the reason I'm asking is this page about type casting. In explicitly says:

 

Only other objects can be cast to objects, and only if that object is a direct child or parent of the one being cast. If you are casting from the parent object to the child one, the cast may fail if it isn't actually an instance of the child object, in which case the result will be None.

 

 

Which is why I believe the code for arrays from above will never work: it created an object of type Form and that's definitely not the BugArrayHolder (btw, don't ask about the typo in this name, it's like that in the original page)

 

I tried of course with the exact result as I describe. I separated two type casts like this:

    Form referenceObject = (objectFactory.placeAtMe(arrayHolder) as Form)
    if referenceObject == None
        ; cast to <Form> failed, that would be unexpected
        return None
    endif
    
    ArrayHolder holder = (referenceObject as ArrayHolder)
    if holder == None
        ; cast to <ArrayHolder> failed, but cast to <Form> succeeded, that is expected as described in this post
        ; This means that the page for type casting tells the truth and I have no idea about how Arrays page code is supposed to work
        return None
    endif

The code predictably goes into the second <If> meaning that the type cast to a child subtype fails. Obviously, two questions:

 

  • Is the arrays page code a valid one and so there is a way to make it work?
  • If it is a valid code, why could it be that the cast fails? My <ArrayHolder> is extending <Form> as it should according to example (and common sense)
Edited by Dellecross
Link to comment
Share on other sites

  • Recently Browsing   0 members

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