Difference between revisions of "Scripting Tutorial: Spell Tome"

no edit summary
imported>Grosie
imported>Grosie
Line 88: Line 88:
       elseif button == 0 ;has the player decided to learn the spell?
       elseif button == 0 ;has the player decided to learn the spell?
         set buttonpressed to 0 ;tell the script we have finished checking buttons
         set buttonpressed to 0 ;tell the script we have finished checking buttons
         player.AddSpell StandardFrostDamageTarget1Novice ;add the spell
        ;add the spell (change the name to the EditorID of your spell)
         player.AddSpell StandardFrostDamageTarget1Novice
         Message "Use this knowledge wisely" ; confirm the player's choice
         Message "Use this knowledge wisely" ; confirm the player's choice
       endif
       endif
Line 94: Line 95:
end
end
</pre>
</pre>
==Putting it all together==
Now all we must do is wrap the whole lot up together, so let's do it.
Open up your book's editing window and set the script drop-down to the name of your script (it should be at the top). If you cannot find it, edit your script and make sure that you have set the script type to 'object' and that you have saved your script (without generating any errors)
At this point, you can also add text to the book to describe what the book does or tell the player something. Bear in mind that they will read this ''after'' deciding whether they want the spell or not.
Click OK on the window and save you mod
==Testing==
First you must make sure that your Mod is saved, then you need the FormID of your new Spell Tome.Once you have done this, open up the oblivion splash screen and click on datafiles. Make sure that your file is checked and close the window.
Once in game, open up the console and type:
player.addItem [YOURFORMID] 1
replacing [YOURFORMID] with the form ID that you found earlier. Open the book and view the results
==Extra==
===Problems===
The GameMode block will not execute when the menus are opened. The best way around it would be to automatically give the player the spell (as the OnAvtivate block does run in menus), however, I wanted to show how to use a message box in this context.
The Script doesn't take into account whether the player has the spell already or not, this could be changed by instead of using the 'doonce' variable, checking if the player has the spell.
===Homework===
A similar method can be used on a scroll, using a scripted enchantment instead. This also has the benefit of ensuring that the addition acn only be made once.


''This article is currently being written, please do not change it yet!''
''This article is currently being written, please do not change it yet!''
Anonymous user