Jump to content

RegisterForKey from a inventory item?


Recommended Posts

Yes, you have your solution.

 

The single master book idea with core scripting in the quest instead of on the books is definitely the way to go. It's what I was going to suggest. Don't worry about whether the player can take the master book. You can just attach a script to it with an OnContainerChanged event to send it home if it ends up in the player's inventory. (Alternately MoveTo or AddItem can be used to send it back to a location or container of your choice even if it is in the player's inventory since it will be a persistent reference.)

 

Using a Misc. item would certainly be the easiest way to handle the update problem. As far as I know the game itself introduces a fixed delay when opening books. I don't think there's any way to override that.

 

Unfortunately scrolls can't have scripts attached or I would recommend using them. The Misc. category is so cluttered already it's a shame to add even more there. But if you're interested I know how to create a config.txt file for SkyUI that would display them with a book or note icon and group them with your own subcategory label even within in the Misc. category.

 

And you probably want to do your own rename option. Since you'll be working with object references it's as easy as calling the SetDisplayName function with a string of your choice (although you'll have to do something to force the inventory display to refresh if you call it while the object is in inventory).

Link to comment
Share on other sites

Wait, moveto can take the reference out of the player imventory? Didnt know that, definitely useful.

 

The config for skyui would be great, the main problem of using misc item in my head was the icon they'd get with skyui.

I thought about adding a quill and inkwell to the inventory model to sort of make it clearer that this one is writable or maybe just a quill and require inkwells, inkwell consumption may be too much requirements though. Anyway, a book icon on it and being put with the books would be great. Is there a documentation page on that or something?

 

Yeah renaming would be a nice addition, i use jaxonz's myself but aim just thinking that an integrated renaming could offer automatic title page, with book and player name, not so much for journals but if you want to write books...

Refresh inventory would closing menu?

Link to comment
Share on other sites

You can close and reopen the inventory menu or even just add and remove a single gold coin. Basically any inventory change.

 

Long ago schlangster documented how to customize SkyUI, but I think I may have been the only one to ever use it. The old method doesn't even work in the new crafting system because schlangster couldn't remember how it worked. :)

 

I released a version for my recent Ring Swapper mod and I'm thinking of creating a mod page specifically for SkyUI configuration setups. Right now the version I added to Ring Swapper also gives my wearable containers from Storage Helpers a little bag icon so they stand out. I think Forteverum will be adding an improved version to his Immersive Jewelry and now you could use one too. If everyone starts distributing custom configuration files it's going to be a real pain for users to merge the bits together.

 

The important part is that all of your custom "books" will need to have some unique keyword that can identify them as books. It can be something you create in your mod or one of the existing game's keyword.

Link to comment
Share on other sites

Ah i see, i'd prefer to keep it compatible if possible. The icon they get is based on keywords? so if without any special configuration files i give the misc items a book keyword they will get book icon?. I guess there is a vendoritembook or something like that, but if i remember right books and notes have the same keywords, how does skyui know if it's a book or a note?. Even if they are within all the misc mess just the different icon would make them easier to identify at least.

 

Also found that there appears to be a ini settign for book opening speed, haven't tested but i guess i could make instant opening by changing the setting at runtime as an alternative to get rid of the double animation while keeping them as actual books.

Edited by FrankFamily
Link to comment
Share on other sites

So, one question, not sure if it's dumb but i'm not clear on this:

 

if i setup something like this (which first of all, looks right?) DoStuff registers on the quest or on the caller object reference? and "self" within the Dostuff function is the quest of object reference that called it?

 

If this registers on the caller objref then i need to make it so that it does it on the quest...

Scriptname itemscriptextends ObjectReference

quest property myquest auto

Event OnEquipped(Actor akActor)
(myquest as questscript).DoStuff(self)
EndEvent
--------------------------------------------------------
Scriptname questscript extends quest

int property mykey auto

Function dostuff(objectreference caller)
RegisterForKey(mykey)
RegisterForMenu("Book Menu")
self.whatever
EndFunction
Edited by FrankFamily
Link to comment
Share on other sites

Yes, that's the basic idea. You'll probably end up with something more like this though. Using more specific types instead of the generic Quest and ObjectReference means you don't have to cast them later.

Scriptname WritableBookScript extends ObjectReference

WriteableBookQuestScript property WriteableBookQuest auto

string property book_title = "Blank Journal" auto
string property book_data = "" auto
; ....

Event OnEquipped(Actor akActor)
    WriteableBookQuest.OpenWriteableBook(self)
EndEvent
Scriptname WriteableBookQuestScript extends Quest

int property mykey auto
ObjectReference property MasterWriteableBookRef Auto
ObjectReference property TitleReplacerObjectRef Auto

WritableBookScript CurrentWritableBook
Function OpenWriteableBook(WriteableBookScript caller)
    RegisterForKey(mykey)
    RegisterForMenu("Book Menu")
    CurrentWritableBook = caller
    TitleReplacerObjectRef.SetName(CurrentWritableBook.book_title)
    ; update other properties and force quest update of variables and open the master book
    ; since caller is copied to CurrentWritableBook you can access it's variables in other events
EndFunction

Event OnMenuClose(String MenuName)
    UnregisterForMenu(MenuName)
    UnregisterForAllKeys()
    MasterWritableBookRef.MoveToMyEditorLocation()
    ; update any other variables as needed
EndEvent

Ah i see, i'd prefer to keep it compatible if possible. The icon they get is based on keywords? so if without any special configuration files i give the misc items a book keyword they will get book icon?. I guess there is a vendoritembook or something like that, but if i remember right books and notes have the same keywords, how does skyui know if it's a book or a note?. Even if they are within all the misc mess just the different icon would make them easier to identify at least.

 

Books and scrolls are distinguished by a special property for real books. Unfortunately the basic configuration doesn't expect books in the Misc. category, so there aren't any pre-defined settings to show a book icon in that category. If you end up using fake books, you would need a custom configuration file to display them. To give distinct keywords if you wanted different icons for different items, but it's entirely possible to come up with a fairly generic set that other people could use. The custom keyword trick can assign new keywords and relabel the sub-type but it can't move things between categories. Still I think book, note, or scroll icons in the misc. category would stand out and if they get a new sub-category would be easy to sort together.

 

One of the reasons I'm now thinking of creating a new mod page for a SkyUI config file is that mods like yours, mine, and Forteverum's could set the keywords and I can create a master config file that supports all of them. The worst that happens if someone doesn't use a custom configuration file is that the various items get their default icons and labels. But this is all something that can wait until you have a working mod. :)

Link to comment
Share on other sites

The custom types and movetomyeditorlocation are some of the improvements over what i started writing. I placed a xmarker to move it back lol, thats better.

Today im kind of busy so i'll try to get all the string handling done tomorrow and then i'll worry about inventory classification.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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