Editing Scripting Tutorial: Spell Tome

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 2: Line 2:


With that in mind, let's get started!
With that in mind, let's get started!
{{Tools|req0=[[The Elder Scrolls Construction Set|Construction Set]]}}


==Starting off==
==Starting off==
Line 30: Line 29:
       set buttonpressed to 1
       set buttonpressed to 1
   else
   else
       Message "You have already learned what you can from this Tome"
       Message "You have already learn what you can from this Tome"
   endif
   endif
end
end
Line 71: Line 70:
   else
   else
       ;Tell the player that they have got the spell already.
       ;Tell the player that they have got the spell already.
       Message "You have already learned what you can from this Tome"
       Message "You have already learn what you can from this Tome"
   endif
   endif
end
end
Line 119: Line 118:


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.
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.
==Book==
If you want the book to open so you can read it, it's simple enough just type Activate after the OnActivate
<pre>
begin onActivate
  Activate
  begin onActivate
  if doonce == 0
      MessageBox "Would you like to learn the Spell of Frost Damage?", "Yes please", "No way, maybe later"
      set doonce to 1
      set buttonpressed to 1
  else
      Message "You have already learned what you can from this Tome"
  endif
end
</pre>
Now you will be able to read the book.


===Homework===
===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 can only be made once.
A similar method can be used on a scroll, using a scripted enchantment instead. This also has the benefit of ensuring that the addition can only be made once.
----
==IronSpine Supplemental - If the script doesn't work?==
I precisely followed the instructions of this tutorial, however (for me) the script never triggered. This was not resolved regardless of mode or other minor changes I made trying to figure out why it didn't.
I examined the script of a DLC Tome for comparison. Using that as a template along with the information here I immediately had a successful custom Tome of Alliance with custom spell, in my case a powerful multi-effect spell to cast on friendly NPC for 5min of prolonged assistance in battle.
Use the content of the tutorial and if your script doesn't seem to execute (as mine did not), use the following as a template and see if it starts working.
<pre>
scn AMLLSpellTomeOfAlliance
short buttonPressed
short isDone
Begin OnEquip Player
If isDone == 0
  MessageBox "(OnEquip Block) - Would you learn the ways of the Alliance?", "I would.", "No, I would not."
EndIf
End
Begin OnActivate
Activate
If isActionRef Player == 1 && isDone == 0
  MessageBox "(OnActivate Block) - Would you learn the ways of the Alliance?", "I would.", "No, I would not."
EndIf
End
Begin MenuMode
Set buttonPressed to GetButtonPressed
If buttonPressed > -1
  If buttonPressed == 0
  ;Add to SpellBook.
  Player.AddSpell AMLLAlliedDefenderMinorSpell
  PlaySound SPLAlterationCast
  Set isDone to 1
  EndIf
EndIf
End</pre>
In my case (and perhaps yours) it's '''OnEquip''' that triggers, not '''OnActivate'''. This is confirmed by the block prefix I added so I could see which is actually being triggered.
Based on my testing, this executes as wanted. Once Yes is selected, subsequent reading of the Tome is just that. Reading. Also, dropping the Tome and picking it back up just yeilds a standard auto read, with take option, and back in inventory just normal reading.
Note the scripts don't appear case-sensitive generally so it's up to you, but for easier reading out of habbit I use Pascal Casing due to my background.
Thanks to the original author of this article for the general knowledge. Tomes open up a hugely interesting way to add true custom spells to the game in a way that feels right and perfectly fits in with the mechanics. Instead of simply using a code to get the object you can of course go stuff it into a bookshelf, chest or anything else and "go get it properly" in-game ''':)'''
- IronSpine
----


[[Category:Tutorials]]
[[Category:Tutorials]]
[[Category:Scripting Tutorials]]
[[Category:Scripting Tutorials]]

Please note that all contributions to the Oblivion ConstructionSet Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see CSwiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Template used on this page: