ObjectReference and Actor - Which difference?

Post » Tue Jun 19, 2012 5:25 pm

Hi,

Does someone know what's the difference between Actor and ObjectReference in scripts? I saw on the Wiki that an Actor property returned the reference of the Actor, so what's the big deal between this and ObjectReference? Why do some functions only work for Actor or ObjectReference?
User avatar
Josh Sabatini
 
Posts: 3445
Joined: Wed Nov 14, 2007 9:47 pm

Post » Tue Jun 19, 2012 6:52 pm

objectReference it's link on the actor or any object if you write a new script you using objectreference that is properties
User avatar
James Wilson
 
Posts: 3457
Joined: Mon Nov 12, 2007 12:51 pm

Post » Tue Jun 19, 2012 3:41 pm

There is a script for actors and another one for objectreferences. If you wan't your actor to use the functionalities of object references, you must make a cast handle it as an object reference, while as actor is it's natural type, you don't need to make any conversion to use on it functionalities from actor script.
User avatar
Lisa Robb
 
Posts: 3542
Joined: Mon Nov 27, 2006 9:13 pm

Post » Tue Jun 19, 2012 2:23 pm

Actor is an extension of ObjectReference, basically Actor has everything ObjectReference has, and then extra stuff. I believe you can use ObjectReference functions with an Actor object, without doing anything special to the Actor object. However if a function asks for an ObjectReference, you need to pass it an ObjectReference, not an Actor.

Its like ObjectReference is milk, and Actor is chocolate milk. Chocolate milk has everything milk has, plus chocolate :o
If you drink chocolate milk, you get the same stuff as milk, plus chocolate, but if someone asks you for a glass of milk, you have to give them milk, not chocolate milk.
User avatar
Micah Judaeah
 
Posts: 3443
Joined: Tue Oct 24, 2006 6:22 pm

Post » Tue Jun 19, 2012 2:15 pm

Actor is an extension of ObjectReference, basically Actor has everything ObjectReference has, and then extra stuff. I believe you can use ObjectReference functions with an Actor object, without doing anything special to the Actor object. However if a function asks for an ObjectReference, you need to pass it an ObjectReference, not an Actor.

Its like ObjectReference is milk, and Actor is chocolate milk. Chocolate milk has everything milk has, plus chocolate :o
If you drink chocolate milk, you get the same stuff as milk, plus chocolate, but if someone asks you for a glass of milk, you have to give them milk, not chocolate milk.
Very close - because http://www.creationkit.com/Actor_Script extends http://www.creationkit.com/ObjectReference_Script, you can call any ObjectReference functions on an Actor without any issues. However, it is possible to use an Actor in place of an ObjectReference without casting, as an object can be http://www.creationkit.com/Cast_Reference#Cast_to_Object to a parent object.

Cipscis
User avatar
Kara Payne
 
Posts: 3415
Joined: Thu Oct 26, 2006 12:47 am

Post » Tue Jun 19, 2012 2:30 pm

Mh okay guys, thank you for all those informations! Now, to make it clear:
While I play, I see an average NPC whose ID is used for more than once ingame. He's called "Skyrim Inhabitant".

What is stored in his ObjectReference VS Actor?
How do I pass Actor as ObjectReference and the contrary?

EDIT: thanks Cipscis!
User avatar
Jade
 
Posts: 3520
Joined: Mon Jul 10, 2006 6:42 am

Post » Tue Jun 19, 2012 3:46 pm

Because http://www.creationkit.com/Actor_Script extends http://www.creationkit.com/ObjectReference_Script, they're sort of ObjectReferences as well. This isn't technically true, as they don't have the ObjectReference type, but because they can be auto-casted to it they can be treated as though they did.

If a function returns a reference that is always an Actor, then its return type will be Actor. If its return type is a reference that may be an Actor, then its return type will be ObjectReference. In this case, you can detect whether the returned object is an Actor by trying to cast it to type Actor:
RetVal as Actor
If the returned object is an Actor, then the result of this cast will be an object of type Actor. If the returned object is not an Actor, then the result of the cast will be None.

When an object is of type Actor instead of type ObjectReference, it has access to the functions of the http://www.creationkit.com/Actor_Script. Even if it can be cast to Actor, if its type is ObjectReference then the compiler will give an error if you try to call any of these functions on it.

Cipscis
User avatar
Stephani Silva
 
Posts: 3372
Joined: Wed Jan 17, 2007 10:11 pm

Post » Tue Jun 19, 2012 1:27 pm

Okay, so I'm making a mod where you can open your horse's inventory through a Perk with an Activate Choice; its Papyrus fragment is this:

ObjectReference MyHorse = akTargetRefActor MyHorseActor = MyHorse as ActorMyHorseActor.OpenInventory(true)

It seems to compile so I guess it will work? :biggrin:
User avatar
Andrew Perry
 
Posts: 3505
Joined: Sat Jul 07, 2007 5:40 am

Post » Tue Jun 19, 2012 8:17 am

Yep, that looks like it should work. It's also worth noting that, if you don't need to reuse the information you've stored, then you can use shorthand like this:
(akTargetRef as Actor).OpenInventory(true)

Cipscis
User avatar
Chloe Mayo
 
Posts: 3404
Joined: Wed Jun 21, 2006 11:59 pm

Post » Tue Jun 19, 2012 4:47 pm

Thank you everyone :)
User avatar
BRAD MONTGOMERY
 
Posts: 3354
Joined: Mon Nov 19, 2007 10:43 pm


Return to V - Skyrim