WhiteWolf424242 Posted August 8, 2021 Share Posted August 8, 2021 Hello, Is it somehow possible to manipulate the displayed text of Books with a script? I mean something like this (with a made-up SetText function): Book Property aBookFromCK Auto function some_function() aBookFromCK.SetText("This is the new text for the book") endfunction And then after calling the function, when the book is opened in-game, from here on it should show the "This is the new text for the book" string. So far I haven't found any option for this. I've checked SKSE, papyrusUtil and powerofthree's papyrus extender, but none of them seem to have such a function for Books.Is the perhaps some other extender I don't know of, that might support such dynamic text replacement somehow? Thanks Link to comment Share on other sites More sharing options...
dylbill Posted August 9, 2021 Share Posted August 9, 2021 There is a way. Use reference alias filled with a dummy object and display the alias in the book. So example in your book put <Alias=MyAlias>. This will display the name of the dummy object in your book. Then to change text you can do: MyAlias.GetRef().GetBaseObject().SetName("Some Text.") to have "Some Text." displayed in the book. This requires closing and opening the book for the changes to reflect though. If anyone knows how to update the book text with the book menu open, that would be good to know. I've been trying to work that out myself. Edit: Your book also has to be in another reference alias in the same quest. The book alias must be below the dummy object alias. Also your dummy object alias must have the Stores Text box checked. Link to comment Share on other sites More sharing options...
WhiteWolf424242 Posted August 9, 2021 Author Share Posted August 9, 2021 Thanks dylbill, that's a huge step forward :smile: However, this wouldn't allow to "let go of the alias", right? What I mean is that even if I leave "Clears name when removed" unchecked, after making the edit, I can't just remove the book from the alias.In the context where I want to use this, the number of books that would have to be edited (with strings randomly selected in the script) is not defined, because it is up to player actions. So ideally, the editing of the text should be permanent so that the book reference doesn't have to be stored in aliases forever.But here, since the actual underlying text of the book is an alias text replacement, it always has to be inside a uses-stored-text alias if I'm right. So that's not exactly usable for this I'm afraid :sad:Yeah, also the thing that it requires the player to close the book before taking effect is a rather big inconvenience. I don't know... would you say it's realistic to write a standalone extender for this?I mean, I took a few glances at tutorials for skse dll's, and they don't seem like impossible-to-learn black magic.And the text of the book must be stored somewhere as some form of string, so I think there may a chance to be able to edit it... Alternatively, my workaround for my context would be to change the feature so that the player action only edits the name of the book, and the inside text stays generic. That should be possible, since just the name change through the alias should be permanent with the "Clears name when removed" unchecked, and it doesn't have to be stored forever. But the actual text edit would be the great version... :D So if it's not a known impossible task to do, and it's not yet been done anywhere, I might take my shot at it. Worst case scenario is that it doesn't work. Link to comment Share on other sites More sharing options...
NexusComa2 Posted August 9, 2021 Share Posted August 9, 2021 Idk what you're doing but I'm assuming you have a book that will change what it is saying off some trigger. If that is the case you could make multiple books then swap them with each other.That should be very easy to do. Link to comment Share on other sites More sharing options...
SeraphimKensai Posted August 9, 2021 Share Posted August 9, 2021 They kinda did similar with the Power of the Elements book for the Destruction Ritual Quest. Mine you I'm almost certain they used multiple versions of the same book with different text in it and ran a removeitem/additem script during the quest for it. Link to comment Share on other sites More sharing options...
dylbill Posted August 9, 2021 Share Posted August 9, 2021 Looking in the CK, the Power of the Elements book is 4 different books that they swap out. Setting book text and updating while the book menu is open would require an skse plugin. I would suggest using UI.SetString, but I've already tried that with no luck. The problem is "Book Menu" is the .swf menu you can access, but this only contains the BookBottomBar.As, where as the "Book" .swf you can't access with skse by default which contains the BookMenu.as which is where you would set the book text string. Link to comment Share on other sites More sharing options...
WhiteWolf424242 Posted August 9, 2021 Author Share Posted August 9, 2021 Idk what you're doing but I'm assuming you have a book that will change what it is saying off some trigger. No.In a nutshell, the player interacts with an NPC, any NPC, and this spawns in a book with some text, including the name of the NPC.The player can thus spawn any number of such books, so they cannot possibly be all stored in aliases forever. Since the text of the book should include the name of an NPC, which is dynamic information based on who the player interacted with, it cannot be made by swapping premade books and tricks similar to that, hence my question about actually managing to replace the text of the book dynamically. EDIT: I would suggest using UI.SetString, but I've already tried that with no luck. The problem is "Book Menu" is the .swf menu you can access, but this only contains the BookBottomBar.As, where as the "Book" .swf you can't access with skse by default which contains the BookMenu.as which is where you would set the book text string. I see. Well... that's going to be an obstacle then, if it's not accessible with default skse. :/ Link to comment Share on other sites More sharing options...
dylbill Posted August 9, 2021 Share Posted August 9, 2021 I found a workaround that doesn't require an SKSE plugin. Using the same method I described above, using a reference alias to display text in the book, you can have the script close the book menu, then re-open it. Here's the scripts: Scriptname CustomDynamicBookScript extends ObjectReference String Property akString Auto ;string that's displayed in this book. MiscObject Property MyDummyObject Auto ;this object's name is displayed in this book ReferenceAlias Property BookAlias auto Event OnRead() If MyDummyObject.GetName() != akString BookAlias.ForceRefTo(Self) ;force the book alias to this book objectreference so it can display the akString MyDummyObject.SetName(akString) ;display the akString in the book Input.TapKey(1) ;esc, close book menu Utility.WaitMenuMode(0.05) Self.Activate(Game.GetPlayer()) ;re open book menu Endif EndEventMake sure the book reference alias has the Optional Flag set. Then to create a book you can do this: Book Property CustomDynamicBook Auto ;CustomDynamicBookScript is on this book. Function CreateBook() ObjectReference akBook = Game.GetPlayer().PlaceAtMe(CustomDynamicBook) ;book must be placed first so it has an ObjectReference. (akBook as CustomDynamicBookScript).akString = "Custom String" ;change Custom String to string you want displayed in book. Utility.WaitMenuMode(0.1) Game.GetPlayer().AddItem(akBook) ;add the book objectreference to the player EndfunctionI tested it out and it does work. Link to comment Share on other sites More sharing options...
NexusComa2 Posted August 9, 2021 Share Posted August 9, 2021 Was going to say other than that some type of reference alias could do this. If you did it like how you do other blind alias's. It would appear bill knows his alias's better than Bethesda. Nice work. Link to comment Share on other sites More sharing options...
WhiteWolf424242 Posted August 9, 2021 Author Share Posted August 9, 2021 That's wicked :laugh: Unfortunately it'll take me a few days before I can get back in front of the CK again to try it out, but this looks perfect. Thanks very much for the help :) Link to comment Share on other sites More sharing options...
Recommended Posts