Jump to content

Converting between not compatible types?...


blank_v

Recommended Posts

Posted

Hello !...

 I'm Tobi :3...

 

So let's say that i have Object that i created with PlaceAtMe Function

 It's ofc. Light Base Object, but i need two Reference types to that Object

 

i need it as ObjectReference so i can use ObjectReference Functions on it

 but i also need it as Light Reference so i can use Light Functions on it...

 

however... You can't just do Object as Light when you did Object = x.placeatme( a ) as ObjectReference

Papyrus refuse to compile that Script because types are not compatible...

 

 

I know about FormLists... it works like "Any Pointer" so i can do easly List.GetAt( 0 ) as ObjectReference and then List.GetAt( 0 ) as Light etc.

it will work fine... but... well... Auto* / Void* etc. is never good option i think... so im looking for better option to do it :/...

 

So how i can Convert ObjectReference to Light Reference?...

Posted

You can only write "x.PlaceAtMe() as Foo" if Foo is a subclass of ObjectReference. The problem you're having is because Light inherits from Form.  The object reference you have is an instance of that light, and you can't convert that back to the base just by casting.

 

What you can do is

 

light light_obj = light_ref.getBaseObject() as Light

 

That will get you the Light form that defines the reference. The problem you'll have then is that changing that light definition will change all the light references that depend on it, which might not be what you want.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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