SunDoWneR667 Posted June 22, 2014 Posted June 22, 2014 Hey, I got a little problem with scripting and the CK wki page isn't helping anymore / I can't find the correct way. My goal: Custom container opens a menu (Open, Sort, Cancel). On "Open" -> it Opens the container. On "Sort" it sorts (e.g.) all keys from the player inventory to the container. On "Cancel" ... you know. I get it to work with Formlists, but I don't like formlists that much, because if the player is using mods which add (e.g.) keys to the game, they won't get sorted because they are not on the list. Here is my "FormList" script for another Container:Scriptname SND_S_JournTrigMenu extends ObjectReferenceActor Property PlayerREF AutoMessage Property SND_JournalChestMenuMsg AutoObjectReference Property SNDContainer_NotesRef AutoObjectReference Property SNDContainer_JournalsRef AutoFormList Property SND_FL_Notes AutoFormList Property SND_FL_Journals AutoEvent onActivate(objectReference akActionRef) Menu()EndEventFunction Menu(int aibutton = 0) aiButton = SND_JournalChestMenuMsg.show() If aiButton == 0 ;Open Note Container getLinkedRef().activate(Game.GetPlayer(), true) ElseIf aiButton == 1 ;Store Journals String Failure = "No Journals to store" String Success = "All Journals stored" Int Succeed = 0 Int IoPJ = 0 IoPJ = PlayerREF.GetItemCount(SND_FL_Journals) If (IoPJ >= 1) PlayerREF.RemoveItem(SND_FL_Journals,IoPJ,True,SNDContainer_JournalsRef) Succeed = 1 EndIf If Succeed == 1 Return Debug.Notification(Success) ElseIf Succeed == 0 Return Debug.Notification(Failure) EndIf ElseIf aiButton == 2 ;Store Notes & Journals String Failure = "Nothing to store" String Success = "All Journals & Notes sorted" Int Succeed = 0 Int IoPN = 0 IoPN = PlayerREF.GetItemCount(SND_FL_Notes) Int IoPJ = 0 IoPJ = PlayerREF.GetItemCount(SND_FL_Journals) If (IoPN >= 1) PlayerREF.RemoveItem(SND_FL_Notes,IoPN,True,SNDContainer_NotesRef) Succeed = 1 EndIf If (IoPJ >= 1) PlayerREF.RemoveItem(SND_FL_Journals,IoPJ,True,SNDContainer_JournalsRef) Succeed = 1 EndIf If Succeed == 1 Return Debug.Notification(Success) ElseIf Succeed == 0 Return Debug.Notification(Failure)EndIf ElseIf aiButton == 3 ;Cancel EndIfEndFunction As you see ... FormLists work fine, but if another (e.g.) Journal or Note is added to the game, it won't get sorted, so it only works with the "vanilla" items. I had to create 2 FormLists for the example above, because there arent any in the vanilla game for Notes and Journals. Is there any way to "Query" an items "Model" (e.g. clutter/books/note01.nif) and get the script working?I also can't get it working with Keywords, which would help sorting keys, bacause all keys (exept 2 from DLC1) have the Keyword "VendorItemKey". Any Ideas? Cheers, Sunny
Mattiewagg Posted June 23, 2014 Posted June 23, 2014 You could try using this: GetKeyword It requires SKSE though.
SunDoWneR667 Posted June 24, 2014 Author Posted June 24, 2014 Hey, thx for the reply, but ... I still need the name of the item if I want to use something like .GetKeyword, which I can do either with an ObjectRefference[] (array) or a FormList. Maybe I have to do something like OnInit -> Build a Formlist of Items or something like that. anyone another tip ?
IsharaMeradin Posted June 24, 2014 Posted June 24, 2014 Here is what I do with mod added items that I have not yet provided support for: Allow the user to manually store any item that fits the criteria of the container.Take the akBaseItem from the OnItemAdded event and with proper checks ensure that it is of the appropriate type.Then add the akBaseItem to the formlist if it is not already on the formlist. This allows future instances of the item in question to transfer whenever the formlist is used.
Recommended Posts