How to run script on quest alias object?

Post » Thu Jun 21, 2012 6:24 pm

Feel like I am missing something stupid here. I am doing some testing on dynamically adding scripts to objects using quest aliases. So far I have been able to get that to work, however I don't know how to get the script to actually run automatically. I don't see any events that can be run on a object reference that would automatically kick off once the script gets attached, what am I missing?

For example, say I want the object to do function XYZ(), I can attach a script to the quest alias that runs this function when the player grabs the object like so:

Scriptname myScript extends ReferenceAliasevent onGrab()	XYZ()endEvent()
But what if I want XYZ() to run on the object the instant this object gets assigned to the quest alias? I've tried onLoad() but that didn't work. What I need is the equivalent to a Main() function.
User avatar
Nikki Lawrence
 
Posts: 3317
Joined: Sat Jul 01, 2006 2:27 am

Post » Thu Jun 21, 2012 4:50 am

See the wiki notes for http://www.creationkit.com/OnInit.
User avatar
W E I R D
 
Posts: 3496
Joined: Tue Mar 20, 2007 10:08 am

Post » Thu Jun 21, 2012 5:21 pm

Thanks, that appears to be exactly what I am looking for!

One more quick question, I can't seem to figure out how to run object reference functions on my object using this quest alias method. For example this doesn't compile:

Scriptname myScript extends ReferenceAliasevent onInit()	 int x = self.GetPositionX()endEvent

I've even tried creating an object reference variable and setting it to "self as ObjectReference" but the compiler doesn't like that either. Again, I know I am missing something stupid...
User avatar
Heather Stewart
 
Posts: 3525
Joined: Thu Aug 10, 2006 11:04 pm

Post » Thu Jun 21, 2012 7:31 pm

Alias.GetReference()
or for actors
Alias.GetActorReference()
User avatar
Céline Rémy
 
Posts: 3443
Joined: Sat Apr 07, 2007 12:45 am

Post » Thu Jun 21, 2012 3:04 pm

Thanks!
User avatar
(G-yen)
 
Posts: 3385
Joined: Thu Oct 11, 2007 11:10 pm


Return to V - Skyrim