SKYRIM
Bookshelves Updated SKSE Script by mdr
Skyrim » Immersion
Added: 11/01/2014 - 11:08AM
Updated: 17/07/2016 - 04:58AM

2,105 Endorsements

1.3.1 Latest version

12,689 Unique D/Ls

18,389 Total D/Ls

92,875 Total Views

Uploaded by eventHandler

Description

Last updated at 4:58, 17 Jul 2016 Uploaded at 11:08, 11 Jan 2014

Two immediate issues I've noticed: Placing a book with no bounds will place it on top of the previous book, which will make things go crazy as the books try to work out the physics of two objects occupying one point in space = paradox (AFT Readme book for example has no boundary info). The other issue is about the end book, it's meant to have physics disabled so it stays standing, but for some reason I must have been testing other ways and left the physics enabled so the books topple over IF the end book is not "large" (4.0+ bounds on I forget which axis).

I will add a safety check for books with no boundary info, and those will just get returned to the player. I will fix the end book toppling over by disabling the physics on that book again.


These issues are fixed in 1.3.1, with the caveat that if you manually remove the left most book, then you will wind up having a duplicate copy when you open the bookshelf container. As always, if you manually remove the right most book, there is nothing to keep the other books from falling over for the most part. (By manually remove, I mean activating the book itself and taking it instead of going into the bookshelf as a container to take it.)

Maybe I will add a book-end object that can be placed and moves with the books when one in taken out, especially the far end book.

I've also noticed the books seem to topple in the Unlimited Bookshelves script, so I will look at making my script compatible once its working as intended again.

Status Update on July 14th, 2016: I haven't been playing Skyrim for the past two years, ever since my 2TB storage drive with all my hundreds of cleaned/sorted/patched mods failed. I've gotten interested in playing again this month, so I will look this over and see if I can fix any issues. I'm still surprised how many people have used and endorsed this simple script I made for what I thought wasn't something most other people cared about, so that's really cool to know other people like their books to stay on the shelves too. Someone even called this an "elegant" solution, which made me laugh but is also appreciated.

I've seen that Unlimited Bookshelves is back, so I expect everyone is using that now. I will keep this around for people who just want books fixed, but by no means do I want to deter people from using that much more exhaustive bookshelf mod. I haven't used it yet, but I will be trying it out myself this week.

Description of the mod:
The mod re-does the way bookshelves work to allow placement of up to 48 books. In practice this number is usually never reached, because depending on book size, usually less than 30 fit in the wide bookshelves (otherwise they'd be on the floor). So you can use the entire bookshelf now is the end result.

The books appear in the order they are put into the shelf, and are added left to right when another book is placed. Unfortunately, this means you have to take every book out first in order to place books to the left side of the current placed books. I will see if there is some way to possibly pick where to put books in the shelf order, but I am new to papyrus and skse's features and limits.

Requirements:
SKSE is required. This mod will work with or without any dlc, and it should work with almost all mods. It only alters two scripts, and is only called when you activate a bookshelf or remove a book from it by reading and taking without opening the shelf itself.

Mods which place new bookshelves or alter existing bookshelves may or may not work as intended. I have tested Dev Aveza and the bookshelves on board are not working with this mod. The reason, from what I can tell, is that these are normal shelves which have had the special bookshelf displays placed over them, and they don't have the trigger script for removing books by "reading + take" instead of opening the bookshelf and taking it from the container. As long as you don't take books directly off the shelf, they should otherwise work fine.

Installing: Extract the folder Scripts of the 7zip file to your SkyrimData folder. You should have 2 files with .pex extensions to move to SkyrimDataScripts. The optional source folder is not needed for the mod (.psc extension) and can be deleted if you don't plan on modifying the scripts yourself. You can leave books on any bookshelves you own if you are using either vanilla or mcguffin's scripts, and the new scripts will seamlessly handle the transition. I think.

If you are using a different mod, first remove all books from any bookshelves, save, and follow the uninstall instructions for that mod. Then install this one and start placing your books as desired.

Updating: Overwrite the old files in the same way as before, and there is no need to remove books from the bookshelf first.

Uninstalling: First remove all books from any bookshelves you are using and save the game.
Next delete the files "playerbookshelfcontainerscript.pex" and "PlayerBookShelfTriggerSCRIPT.pex" from SkyrimDataScripts

Also delete the two optional source files "playerbookshelfcontainerscript.psc" and "PlayerBookShelfTriggerSCRIPT.psc" from SkyrimDataScriptsSource if you moved them there.

Now you can load the game and it will use the old bookshelf system or any other modded system you install.

The two .psc files are included for anyone who wants to edit the scripts, and can safely be deleted at any point while using the mod because they are not used by the game.

Recommended mods:
Book Covers Skyrim by DanielCoffey at http://skyrim.nexusmods.com/mods/35399/?
The important reason to get this mod is to fix the book boundary values (which are missing or wrong on a lot of books) so that the books will fit appropriately against each other and occupy the right amount of shelf space. The added benefit is that this mod makes books look really fantastic (I recommend desaturated colors). When I first heard about it, I thought it would be adding tacky covers to the book the way they do with modern books (glossy, ugly things taped on with flashy pictures that hide the actual book), but that isn't what it does as it turns out. It makes the books look more unique and detailed, and stylish (legible) titles on the covers/spines. It changes notes and letters as well, adding many interesting varieties. This mod should be placed near the end of your load order to ensure no book fixes are overwritten.

Dragonborn Book Bounds Fix by lessens at http://skyrim.nexusmods.com/mods/39671/?
Book Covers Skyrim fixes many book boundaries, but it doesn't touch Spell Tome boundaries. That's where this mod comes in, as it has fixes on spell tomes that are useful if you plan to place them on bookshelves. Place this mod before Book Covers Skyrim in your load order or you will lose the improved book cover models/textures on many books. These fixes are in USLEEP (Unofficial Skyrim Legendary Edition Patch), and everyone should already have that as your first mod to download.

Issues:
  • Sometimes the last book to the right doesn't show up if the remaining space is a close to maximum and its size is barely able to fit, but it still is treated as having fit by the code that returns books to the player, so I will work on that..
  • Sometimes the normal/smaller books (which have dynamic physics enabled) will lean into larger books which are static, and clip slightly into it. This is only a small amount, and its not as bad as would happen in the previous script when the books would sometimes "fuse together" into inseparable blobs of books.

Suggestions:
  • You can try opening a closing the bookshelf to get different results if the books shift the wrong way during rendering. Sometimes the big books fall wrong and then don't drop to the shelf before the physics is altered, so they need reset. I will try to find a way to check for whether or not they are a certain distance higher than the other books and move them automatically. With the normal/small books, you can drag them and nudge them around since they have the havok re-enabled after loading up, but it can be mixed results and mess them up worse. You only need to open and close the shelf to try again..
  • Try to find a large book with good bounds and put it after any smaller books and before any larger books (which tend to have the least accurate bounds it would seem). The normal size books tend to lean to the right, but fortunately they don't lean into the other normal/small size in most cases. The bounds + physics enabled seems to keep the normal sized books properly supported against each other, but unfortunately they lean into books set static. The problem is that the large books become distorted when they are set to use dynamic physics; the covers pop out and crease in the bidnings and the pages try to escape into the adjacent books. I am not sure if this could be fixed by adjusting the bounds on the larger books or by playing with the physics more, but I am looking into it.

Update 1.3.0: Improved the physics by treating large books as thin boxes, so there should be no clipping as smaller books lean against them and the large books can be moved by the player grabbing them (plus they fall down to proper height if they are higher than they should be from a glitch with the papyrus MoveTo() function). The same is done for the end book, so now it shouldn't fall over but it can still be moved by the player* (I was wrong, the end book does still tip over, but its not really noticeable if its a large book so use a large book on the end for now.)

Note: The books are 1 unit above the shelf because that is where Bethesda put the invisible marker that tells the physics the surface is, so if I move the books down to the real surface they will just pop up to the current spot when physics is enabled (or sooner if they move before the disable script runs when placing the books). This could probably be fixed in the CK by editing the bookshelf model.

The script won't have to be changed if that is fixed, because it places the books on whatever spot is set as the surface, so it would just be a separate .esp to be loaded.

More on Bookshelves
The bookshelf has a container part like any normal chest which is where the books are held (references to the books that can be used to load them into your inventory to be more precise). The the game collects the model information from the books in this container using magic and renders them on the shelf, but essentially the book (if it were a tangible object) is still safe in a chest while another copy of it is sitting proudly on display. So even if a book isn't showing up on the shelf, it's still going to be in that container and able to be retrieved by opening/activating it. Any book not actually able to be displayed (no more room for it on the shelf) should return to the player's inventory. Books that do show up on the shelf can either be picked up normally by using it or retrieved by activating the chest to look in the container. I think that's accurate information, but I'm making assumptions from looking at code and trying out things in the game.

Other notes:
Sometimes you will get an error in papyrus logs which I've posted at the bottom of this description, but it only means the script is not finishing loading a book before trying to modify the book's physics. This will happen when you have other scripts taking up resources, and isn't anything harmful aside from books possibly moving out of position. If some books fall too much and look out of place, just try opening and closing the bookshelf again until it works right. I've tried to find a balance between waiting long enough to ensure the book has rendered and not waiting too long for the book to fall out of place.

The script disables the physics of each book shortly after rendering the book, then renders the next book. After all books have been rendered, each book from left to right has its physics re-enabled (so they will appear to jump up and down a bit and shift into usually a better fit). I have decided to keep the physics on large books disabled, because they tend to distort and mess up themselves and the books around them; its best to group large books together and preferably at the end of a row. The right end book is also kept static so that it doesn't fall and acts as a bookend.

This script was tested in Breezehome, so if you have shelves it doesn't work well on, please post a comment. If the boundaries of a book are incorrect, it will possibly overlap other books or have a large gap around it depending on the amount of error. Please report any books with issues that are not covered by the recommended mods in the comments and I will try to make a patch for them.

Please post any issues in the comments, since I have only tested it on my own save game and only in Breezehome. I am using 200+ mods and a number of them are scripted, so it should work for most people. I will release any further tweaks I make to improve positioning of books or patches for book bounds/sizes or bookshelf bounds.

This error can be ignored.
Error: (FF001C6B): has no 3d, and so cannot have its motion type changed.
stack:
[ (FF001C6B)].ObjectReference.SetMotionType() - "<native>" Line ?
[ (00102A81)].playerbookshelfcontainerscript.UpdateBooks() - "PlayerBookShelfContainerScript.psc" Line 328
[ (00102A81)].playerbookshelfcontainerscript.OnActivate() - "PlayerBookShelfContainerScript.psc" Line ?