Go into your Item (an Amulet for instance)
Down in the right corner, there is a scripts window
Click Add
Double Click on [New Script]
Now you get a window, which allows you to name the script.
Dont worry about the Extends ObjectReference bit yet - I think this basically tells you what sort of object you will be working with or something?
Name your script, and click ok.
It probably just closed the Script window, and your like?
What???
It has created the script file, now you need to create the Input arguments that will be used within the script.
You do this via double clicking on the script in the same script window,
then Add Property
A window will appear where you can select the 'type' of property.
Which pretty much means, any of the data types available in Skyrim.
Int values, string values ,as well as spells, items, weather etc....
If for example, you want to add a spell to a player when they equip the item, you would set the Property to be 'Spell'
Name it something like MyLittleSpell
(this is just the name of the variable, not the name of the spell itself)
Dont worry about the initial value, as it tends to stay as a text box for the time being.
Close the window, after having made your spell property.
Now, if you select the property you just made, you will be able to select 'Edit Property' or 'Set Value'
When you do that, a Context sensitive dropdown can appear, which lists all of the spells in the Game (in your mod).
You can then select the spell, and click ok.
So...
That is the 'PRE' script work done.
You have told the script what spell to use..
Now you need to tell it how to use it...
This is the bit im not too sure on...
Correct me if needed.
* Right Click on the script in the window, and select Edit Source
* Compile it once you are finished with your script
Scriptname BaaleosOnEquip extends ObjectReference
Spell Property EyesProperty auto <----- This is your property that you made. it appears in your script like this. Yours would be named MyLittleSpell
Event OnEquipped(Actor AkActor)
Game.GetPlayer().AddSpell(EyesProperty) <------ You can see, that we are feeding in EyesProperty (the spell) into the AddSpell function.
EndEvent
Event OnUnequipped(Actor AkActor)
Game.GetPlayer().RemoveSpell(EyesProperty) <------- The same with the RemoveSpell function
EndEvent
Spell Property EyesProperty auto <----- This is your property that you made. it appears in your script like this. Yours would be named MyLittleSpell
Event OnEquipped(Actor AkActor)
Game.GetPlayer().AddSpell(EyesProperty) <------ You can see, that we are feeding in EyesProperty (the spell) into the AddSpell function.
EndEvent
Event OnUnequipped(Actor AkActor)
Game.GetPlayer().RemoveSpell(EyesProperty) <------- The same with the RemoveSpell function
EndEvent
Anyway..
Compile your script, close the item, save your mod, and load up skyrim, and equip your item, and hopfully, your OnEquip script will fire.
Pro's and Con's with the new Scripting system
Alot of advanced scripters like being able to dive in and get their hands dirty with textual editing of the script, while that is still there via 'Right Click and Edit Source', the method of adding arguments and such, seems a little complicated.
Infact, I dont know how to reference a Spell in the script, without adding it as a propert first?
I liked it when you could simply type in the editor ref..... I dont know if you can do that anymore?
Anyhow... Hope this example helps people.