EPHHall Posted February 4, 2017 Share Posted February 4, 2017 I'm trying to get a spell tome (Mayhem in this case) to add two spells to the player: the default spell and another spell of my choosing. To do this, I tried adding a spell to the player via a script attached to the spell tome, but it isn't working and I'm not sure why. Here's my script: Scriptname TeachSpellBook extends ObjectReference {Adds a spell when the player reads a book} Spell Property SpellLearned Auto Event OnActivate(ObjectReference akActionRef) Game.getplayer().addspell(SpellLearned)EndEvent It compiles fine, so do I need to extend something different maybe? Or am I just using the wrong commands? I'm new to Papyrus, so I would love to learn what's going on here. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted February 4, 2017 Share Posted February 4, 2017 You could try OnRead instead of OnActivate. OnEquipped may also be a viable alternative. OnActivate tends to be for objects that are meant to be interacted with outside of player inventory. Which may very well explain why it isn't doing anything for you. However, I am not certain if events will be triggered by a spell tome. Spell tomes are hardcoded to be removed from the player inventory when the player reads them to learn the spell. This may or may not interfere with the script processing. If changing the events do not help, you might want to try creating a normal book that adds both spells via script instead. Link to comment Share on other sites More sharing options...
Masterofnet Posted February 4, 2017 Share Posted February 4, 2017 (edited) That is not it. I use OnActivate for the same thing. 1. Did you fill the properties of the script?2. If you use on activate and you pick the book up it will fire.3. If the book does not have a reference it may not work either. How did you place the book in the cell? Edited February 4, 2017 by Masterofnet Link to comment Share on other sites More sharing options...
EPHHall Posted February 4, 2017 Author Share Posted February 4, 2017 (edited) Thank you Ishara, OnEquipped works perfectly as far as I can tell. And Masterofnet, I'll keep those things in mind next time I make a spell. Thank you both. Edited February 4, 2017 by EPHHall Link to comment Share on other sites More sharing options...
Masterofnet Posted February 4, 2017 Share Posted February 4, 2017 (edited) Can I ask you how you placed the book in the cell? This is interesting. IsharaMeradin may have found a way to get an event to fire on a book without it being an object referecne. Edited February 4, 2017 by Masterofnet Link to comment Share on other sites More sharing options...
cdcooley Posted February 4, 2017 Share Posted February 4, 2017 Yes, OnRead runs whenever a book is read whether it was in the game world or in some container (including the player's inventory). I assume the book was originally placed in a container (possibly a merchant chest so the player could purchase it) rather than being placed as a unique item in the game world. Link to comment Share on other sites More sharing options...
Masterofnet Posted February 4, 2017 Share Posted February 4, 2017 Yes, OnRead runs whenever a book is read whether it was in the game world or in some container (including the player's inventory). I remember reading a thread you were involved in regarding someone wanting to keep track of every book a player read and someone saying it could not be done because if the book was not an object reference On Read would not fire. I had to use On Activate because for some reason On Read would not fire a function(). Link to comment Share on other sites More sharing options...
cdcooley Posted February 4, 2017 Share Posted February 4, 2017 The problem in that other thread was the fact that even though the book can get the OnRead event you can't determine which book is firing the script if the book doesn't have an actual reference. If you attach the same script to a large number of different books (which is what the other mod was doing) then functions like GetBaseObject and any attempts to use self will fail, so the only way to know which book was read would be to add a property to each book script to identify it. The author of that mod didn't want to have to individually fill properties for every book. This case is about a script on a very specific spell tome not trying to attach it to all spell tomes. Although this does mean that this mod will have a conflict with that other one if both are trying to add scripts to the same book. Link to comment Share on other sites More sharing options...
Masterofnet Posted February 5, 2017 Share Posted February 5, 2017 Thanks for the information. Link to comment Share on other sites More sharing options...
EPHHall Posted February 5, 2017 Author Share Posted February 5, 2017 (edited) I just added the spell tome via console. Nothing special as far as I know. Edited February 5, 2017 by EPHHall Link to comment Share on other sites More sharing options...
Recommended Posts