Actor Target = MyAlias.GetReference() As Actor

Post » Sat Sep 14, 2013 5:22 pm

I have this in my ReferenceAlias Scripts for one of a dozen Alias in the same quest:

Event OnInit()
Actor Target = MyAlias.GetReference() As Actor
EndEvent
But how do you dynamically get the MyAlias part of this for each of the dozen possible Aliases ?
I tried SELF but that gave me an error as self is the script not the actor.
User avatar
Mariaa EM.
 
Posts: 3347
Joined: Fri Aug 10, 2007 3:28 am

Post » Sun Sep 15, 2013 1:14 am

How do you mean "dynamically"? Does the quest have multiple aliases?

Also OnInit() in a script attached to a quest will fire on the first game load the quest is present, regardless of whether the quest is started or not. That can cause issues for you.
User avatar
Sabrina Schwarz
 
Posts: 3538
Joined: Fri Jul 14, 2006 10:02 am

Post » Sun Sep 15, 2013 1:32 am

Any multiple fireing of the quest will not be problem as this quest is intended to fire on and off several times anyway.
But how do you get the MyAlias for EACH alias ?
GetReference() is useless without the Alias so I know there must be a way.
Wait, do you just use the property and change that property for EACH script instance in each Alias?
:facepalm:? of coarse that is it... sorry for the dumb question.
User avatar
Natasha Callaghan
 
Posts: 3523
Joined: Sat Dec 09, 2006 7:44 pm

Post » Sat Sep 14, 2013 7:11 pm

mmmmmm.... still something I am not getting right as I am now getting this error:

not a function or does not exist

User avatar
adame
 
Posts: 3454
Joined: Wed Aug 29, 2007 2:57 am

Post » Sat Sep 14, 2013 11:31 pm


Post your full script.
User avatar
Krystina Proietti
 
Posts: 3388
Joined: Sat Dec 23, 2006 9:02 pm

Post » Sat Sep 14, 2013 5:00 pm

This is the script in one of the REFERENCE ALIAS in the quest:

Scriptname aadpAliasSysActorTest extends ReferenceAlias
Actor Target
Alias Property MyAlias Auto
Event OnInit()
Target = MyAlias.GetReference() as actor
EndEvent
edit: missing extends ReferenceAlias
User avatar
Sweet Blighty
 
Posts: 3423
Joined: Wed Jun 21, 2006 6:39 am

Post » Sun Sep 15, 2013 6:12 am

Firstly you're missing the "extends ..." part, unless you haven't posted that.

Try this anyway

Actor TargetReferenceAlias Property MyAlias Auto  Event OnInit()	Actor kActor = MyAlias.GetReference() as actor 	Target = kActor EndEvent
Very often you'll have problems trying to cast different types of objects to eachother, like how you were. So it's best to create the variable first in the correct type (make the Actor variable), then cast that variable to your property. Rather than saying "Create an Actor from this Reference Alias guy and make him an actor in another thing", it's best to put it into stages like "Create an Actor from this Alias guy. Then, when you're done Mr Papyrus, make that actor my other actor".
User avatar
Facebook me
 
Posts: 3442
Joined: Wed Nov 08, 2006 8:05 am

Post » Sun Sep 15, 2013 3:53 am

sorry you are right I somehow lost that while cutting and pasting.

It is this:

Scriptname aadpAliasSysActorTest extends ReferenceAlias
Actor Target
Alias Property MyAlias Auto
Event OnInit()
Target = MyAlias.GetReference() as actor
EndEvent
The "not a function or does not exist" error is for GetReference() ....not the casting... but I will try your suggestion anyway thanks.
User avatar
Frank Firefly
 
Posts: 3429
Joined: Sun Aug 19, 2007 9:34 am


Return to V - Skyrim