SetOutfit error on Alias script

Post » Thu Jun 21, 2012 9:05 pm

So I'm trying to use setoutfit on an NPC that activates my bed, but I am getting this compile error:

c:\steam\steamapps\common\skyrim\Data\Scripts\Source\temp\SeeYouSleepAliasScript.psc(25,14): SetOutfit is not a function or does not exist

Here is the relevant code:

Scriptname SeeYouSleepAliasScript extends ReferenceAlias   Outfit Property DefaultSleepOutfit AutoEvent OnActivate(ObjectReference akActionRef)        if AkActionRef == Game.GetPlayer()        FadeToBlackHoldImod.ApplyCrossfade(2.0)        Utility.Wait(2)        ActivatorDelay()    Else;NPC activated   	 AkActionRef.SetOutfit(DefaultSleepOutfit)    EndifEndEvent
User avatar
Sweets Sweets
 
Posts: 3339
Joined: Tue Jun 13, 2006 3:26 am

Post » Thu Jun 21, 2012 4:53 pm

(akActionRef as Actor).SetOutfit(DefaultSleepOutfit)

akActionRef is an Objectreference, but SetOutfit() is an Actor's method, so you need to cast akActionRef to an Actor.
User avatar
A Boy called Marilyn
 
Posts: 3391
Joined: Sat May 26, 2007 7:17 am

Post » Thu Jun 21, 2012 8:27 pm

Ok so how would I go about doing that? I tried this but I got an error:
I defined an actor property NPCRef Auto, then replaced this code in the above script:
AkActionRef.SetOutfit(DefaultSleepOutfit)

with this:

   	 NPCRef = AkActionRef        NPCRef.SetOutfit(DefaultSleepOutfit)

and I get this compile error: type mismatch while assigning to a actor (cast missing or types unrelated)
User avatar
Christine
 
Posts: 3442
Joined: Thu Dec 14, 2006 12:52 am

Post » Thu Jun 21, 2012 7:28 am

Actually I posted code for it - it must have looked too much like a quote, sorry. But with an NPCRef variable (no need for a property) you would do this:

Actor NPCRef = AkActionRef as Actor
NPCRef.SetOutfit(DefaultSleepOutfit)
User avatar
kirsty williams
 
Posts: 3509
Joined: Sun Oct 08, 2006 5:56 am

Post » Thu Jun 21, 2012 12:09 pm

That compiled great, thanks! I should have known as I've seen code like that before, but in all the source code examples they never used it that way in their syntax, I guess I assumed that anything activating an object reference would be an actor.
User avatar
m Gardner
 
Posts: 3510
Joined: Sun Jun 03, 2007 8:08 pm


Return to V - Skyrim