A script to stop the player from reading a book?

Post » Fri May 04, 2012 9:50 am

Hi all,

I'm trying to write a script that will prevent the player from reading a book if his/her speechcraft skill is less than 25. It looks like this and is attached to the book object in the CS:

begin onActivate
if ( player.GetAV Speechcraft < 25 ) && ( IsActionRef player == 1 )

Messagebox "You are not sufficiently skilled in Speechcraft to read this book"
endif
end
begin onEquip
if ( player.GetAV Speechcraft < 25 ) && ( IsActionRef player == 1 )

Messagebox "You are not sufficiently skilled in Speechcraft to read this book"
endif
end

This works fine when the book is a reference in the world, but when it's already in the player's inventory it doesn't seem to do anything. Is this because clicking a book in the inventory doesn't really 'equip' it as such? Is it possible to write a script that prevents the book from 'opening' from the inventory menu?

Thanks! :biggrin:
User avatar
Dean
 
Posts: 3438
Joined: Fri Jul 27, 2007 4:58 pm

Post » Fri May 04, 2012 2:44 pm

The problem is the use of IsActionRef in the OnEquip block. IsActionRef only works in OnActivate blocks. Try this script instead:

begin onActivate Playerif ( player.GetAV Speechcraft < 25 ) Messagebox "You are not sufficiently skilled in Speechcraft to read this book"endifendbegin onEquip Playerif ( player.GetAV Speechcraft < 25 )Messagebox "You are not sufficiently skilled in Speechcraft to read this book"endifend

^That should get you the desired results.
User avatar
Danii Brown
 
Posts: 3337
Joined: Tue Aug 22, 2006 7:13 am

Post » Fri May 04, 2012 11:58 am

Thanks for the help, but this doesn't seem to work either - I get the message box, but when I use a book in my inventory I still get the open book as well, which I am free to read when I close the message. I'm beginning to think this might be a bust. I've been poking around in the CS as I was sure that there were books in the vanilla game that the player was unable to read, but they seem to have been misc items instead. For example, Fingers of the Mountain from the Chorrol Mages Guild Recommendation is a misc item instead of a book, but there is also a book version in the CS with a script similar to mine, that doesn't get used in the game, maybe suggesting that some dev tried my approach first and found out that it doesn't work. I would guess (from my position of almost total ignorance) that there's something about the way books work - opening a menu rather than being 'equipped' - that makes scripts like mine unable to stop them from opening...

Hmmm... well thanks for the reply anyway! : )
User avatar
Michelle davies
 
Posts: 3509
Joined: Wed Sep 27, 2006 3:59 am


Return to IV - Oblivion