Scripting Help - addperk

Post » Wed Jun 20, 2012 6:30 am

Can anyone give me a hand? I've been hacking away at this for an hour and I can't seem to get it to work.

This script is attached to my player. I know my Perk works and I know the OnItemAdded() works. However, I can't seem to pass the specific perk I want to add to the script. I have a feeling I'm doing something with the property incorrectly. Guidance! I need guidance, Thanks in advance,

Scriptname MyScript extends ObjectReference  Perk Property MyPerk autoEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)		Actor player=Game.GetPlayer()		If(akBaseItem=="MyItem")	player.AddPerk(MyPerk)  	EndIf	endEventEvent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)		Actor player = Game.GetPlayer()	If (akBaseItem=="MyItem")		player.RemovePerk(MyPerk)  	EndIf	endEvent

Any help at all would be greatly appreciated.
User avatar
Allison C
 
Posts: 3369
Joined: Mon Dec 18, 2006 11:02 am

Post » Tue Jun 19, 2012 8:30 pm

After you add a script to something, you can double-click the script to bring up the properties window. There, you should assign your perk to the property "MyPerk".
User avatar
Breanna Van Dijk
 
Posts: 3384
Joined: Mon Mar 12, 2007 2:18 pm

Post » Wed Jun 20, 2012 4:42 am

Right, so I had tried that as well. It now looks like this:


Scriptname MyScript extends ObjectReference  Perk Property MyPerk = MyCreatedPerk AutoEvent OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)				Actor player=Game.GetPlayer()				If(akBaseItem=="MyItem")		player.AddPerk(MyPerk)  		EndIf		endEventEvent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)				Actor player = Game.GetPlayer()		If (akBaseItem=="MyItem")				player.RemovePerk(MyPerk)  		EndIf		endEventPerk Property MyPerk = MyCreatedPerk Auto

This is what happens now:

Data\Scripts\Source\temp\MyScript.psc(25,25): no viable alternative at input 'MyPerk'
User avatar
Elisha KIng
 
Posts: 3285
Joined: Sat Aug 18, 2007 12:18 am

Post » Wed Jun 20, 2012 5:32 am

Here is your problem:

Perk Property MyPerk = MyCreatedPerk Auto

Revert that line back to
Perk Property MyPerk Auto
and then get out of the script. Right-click the script, go to Properties, and then assign a value through that interface.
User avatar
Flutterby
 
Posts: 3379
Joined: Mon Sep 25, 2006 11:28 am

Post » Tue Jun 19, 2012 5:00 pm

Ah, I see. Unfortunately, I have just arrived at work so I won't be able to try that until tonight. Is this always true of Properties, they must be assigned in that interface and not in the script? Or is this only true for certain property types?
User avatar
Madeleine Rose Walsh
 
Posts: 3425
Joined: Wed Oct 04, 2006 2:07 am

Post » Wed Jun 20, 2012 2:22 am

Is this always true of Properties, they must be assigned in that interface and not in the script?

Yes... sad, but true :(
User avatar
Sammykins
 
Posts: 3330
Joined: Fri Jun 23, 2006 10:48 am

Post » Tue Jun 19, 2012 4:52 pm

I find it easier to add the property in the interface rather than the script. The CK adds an auto prorperty line to your script automatically.
User avatar
emily grieve
 
Posts: 3408
Joined: Thu Jun 22, 2006 11:55 pm

Post » Tue Jun 19, 2012 11:21 pm

You can assign Properties directly in the script, then fill them with the interface. If you have many, many Properties to define it goes faster to copy/paste in the script.
User avatar
Flesh Tunnel
 
Posts: 3409
Joined: Mon Sep 18, 2006 7:43 pm

Post » Wed Jun 20, 2012 6:21 am

...and then get out of the script. Right-click the script, go to Properties, and then assign a value through that interface.

Thanks, GraniteDevil. I was searching this forum for help on casting a spell in a script. I thought I was doing everything right, but when I followed your suggestion, I saw that the Edit Properties interface ties the name declared in the script to the ID of the spell itself. In short order, I had my script running. Thanks, again.
User avatar
matt white
 
Posts: 3444
Joined: Fri Jul 27, 2007 2:43 pm


Return to V - Skyrim