How do you reference an actor in a script that is attached t

Post » Wed Jun 20, 2012 6:29 am

I can't figure out how to do it. I have this script, and anywhere it says Creeper I want it to basically reference the actor that the script is attached to. Help?

Scriptname CreeperGetsThings extends ObjectReferenceActor Property PlayerRef  AutoEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)   int GoldMod = (akBaseItem.GetGoldValue() as int) * aiItemCount   int GoldInit = CFGold.getValue() as int   int ModdedGold = GoldInit + GoldMod   if akSourceContainer==Game.GetPlayer()	  CFGold.Setvalue(ModdedGold)   endIf	  RegisterforSingleUpdate(1)endEventevent OnUpdate()  if Creeper.GetActorValue("InventoryWeight") as int >=200	 ByeBye.Cast(Creeper)   endIfendEventGlobalVariable Property CFGold  AutoActor Property Creeper autoSpell Property ByeBye auto

Basically, it won't let me choose the actor that the script is attached to for the property creeper, so there must be some other syntax.
User avatar
sally R
 
Posts: 3503
Joined: Mon Sep 25, 2006 10:34 pm

Post » Wed Jun 20, 2012 5:42 pm

Replace 'Creeper' with 'Self'. And you don't need the property of course.

EDIT: You might want to change the script so that it extends Actor.
User avatar
Beast Attire
 
Posts: 3456
Joined: Tue Oct 09, 2007 5:33 am

Post » Wed Jun 20, 2012 4:03 pm

Replace 'Creeper' with 'Self'. And you don't need the property of course.

EDIT: You might want to change the script so that it extends Actor.


LOL. I had tried self, but I forgot it was extending ObjectReference. Thanks, I was wondering why self wasn't working.
User avatar
Crystal Clarke
 
Posts: 3410
Joined: Mon Dec 11, 2006 5:55 am

Post » Wed Jun 20, 2012 9:53 am

Hmmm. This compiled and everything, but isn't working as I'd hoped. I think it's because when Creeper (does anyone else remember creeper from morrowind?) would cast the spell he's currently got his inventory opened by the player, and I don't think the game knows how to "hold on" to that command and execute it when the menu closes.

Hmmm. Have to rethink this. Make there is an event for InventoryClose or something...
EDIT: There is an OnCLose, but I think thats meant for doors and not inventories. Heck, I'll try it. Also how would I do that? I can't attack a script to an inventory...
Hmph.
User avatar
adame
 
Posts: 3454
Joined: Wed Aug 29, 2007 2:57 am

Post » Wed Jun 20, 2012 4:01 pm

So everything is working right except for the OnUpdate? Did you check to make sure that the CFGold looks right?

According to the CK wiki, the update stuff pauses while you're in menu mode. So there's nothing that makes the game "let go" of the command and not execute it when the menu closes.
User avatar
Robert Garcia
 
Posts: 3323
Joined: Thu Oct 11, 2007 5:26 pm

Post » Wed Jun 20, 2012 5:05 pm

LOL Doesn't matter anymore. I just realized I can easily make it so that the PLAYER chooses when he goes back to town to sell loot, and it would be better than him doing it automatically. I'll just put the cast command in the end fragment of a new dialogue option and he'll take off and do what he does. The rest it automatically taken care of through scripts.

Oh, I don't know much about procedures though. It would look a lot less awkward if he actually did the motions of casting rather than just insta-teleporting away, and I know that I can do that with the UseMagic procedure.
I just don't know how to start procedures from scripts...
User avatar
Sophie Payne
 
Posts: 3377
Joined: Thu Dec 07, 2006 6:49 am


Return to V - Skyrim