Jump to content

Automatically open book


QuietusPlus

Recommended Posts

I have been looking for a solution to automatically open a book when a function is triggered. The creation kit website gives nothing useful on this subject, I was thinking THIS but the documentation is a little thin. Maybe something like below, however it gives an error that Active is not a function.

 

Scriptname BookScript extends ObjectReference

Book Property MyBook Auto

Function blabla ()
  MyBook.Activate(Game.GetPlayer())
EndFunction

 

Is this even possible?

 

 

Thanks

Link to comment
Share on other sites

ObjectReference Property MyBook Auto

 

I would like to open (or activate) a book while it is in your inventory. Using objectreference requires it to be in a cell doesn't it? That's why I wasn't sure the Activate function would be possible.

Edited by QuietusPlus
Link to comment
Share on other sites

You can't activate something that's not loaded. So you can't activate anything that's in something or somebody's inventory. When you select something in your inventory, you're actually sending an equip event, not activate.

 

Is this script on your book, or is it on something else? Check out the note on this page.

 

I have done a couple of tests with scripted objects in an inventory, and they are extremely unreliable unless they are persistent references.

Link to comment
Share on other sites

You can't activate something that's not loaded. So you can't activate anything that's in something or somebody's inventory. When you select something in your inventory, you're actually sending an equip event, not activate.

 

Is this script on your book, or is it on something else? Check out the note on this page.

 

I have done a couple of tests with scripted objects in an inventory, and they are extremely unreliable unless they are persistent references.

 

I see, thanks for that link... I currently have the script attached to the book, which can be changed if necessary (it would not break the mod). I'll read some more about persistent references. Do you mind sharing which tests you did and why it was unreliable?

Link to comment
Share on other sites

I posted my test results here. The results are reliable, the rest are just guesses at what the results mean. You'll have to form your own opinion.

 

Also, since the script is attached to the book itself, there is no need for a 'MyBook' property. For the activate function, you can just call it without prefixing it with anything.

 

Activate()

 

For any function that requires you to pass a parameter, just use 'Self'.

 

Game.GetPlayer().MoveTo(Self)

Edited by fg109
Link to comment
Share on other sites

So I did a little experimenting and this is what I got:

 

This is attached to an external script

((MyBook as Form) as ObjectReference).Activate(Game.GetPlayer())

 

MyBook (is Book Property) cannot be cast as a ObjectReference directly, which is why I am casting it as a Form first

 

The following is attached to MyBook

Event OnRead()
  ;some code
EndEvent

 

The code from the external script will activate the book and trigger the OnRead event. It does not however actually open the book (including the animation). I am pretty new to this so maybe I am doing something completely wrong. Any more help would be appreciated.

 

Scrap all that, I made a mistake with the script in my mod, this doesn't trigger the onread event -_-. I went another way with the mod I am making, if someone still found a way please share.

 

PS. Kudos to fg109 for helping me so far

Edited by QuietusPlus
Link to comment
Share on other sites

  • 1 month later...

I would like to open (or activate) a book while it is in your inventory.

 

I would think that this will only work if the player's inventory is open and the book is highlighted as the current inventory item (so that the "read" option is available). Note that in the inventory view, the book is represented by the Inventory Art model, which is a static model and can't be animated. When you read the book, it is replaced by the World Art model which has the "open" book animations in it. To open the book (without the player pressing the "E" key) I would think that you would have to call Activate(). Another possibility is to try calling "<book>.SetOpen(1)" although maybe this only works for doors? Alternatively, you could try "<book>.PlayAnimation("open") or whaterver the "open book" animation is called... Hopefully one of these might work, but I would expect that you will need to force open the player's inventory first "<actor>.OpenInventory(true)" and then you would need some way to highlight the book in the inventory (I'm not sure if there is a Papyrus function to do this) and then you can try to force the book open. Well it's worth a try...

Edited by steve40
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...