Zylice Posted May 18, 2015 Share Posted May 18, 2015 (edited) I'm making an auto-sort system that will only allow you to store food items and nothing else. Acceptable keywords are: VendorItemFood & VendorItemFoodRaw. I'm having trouble excluding the rest of the keywords without having issues with the enabling of certain items when the're placed in the container. I have managed to exclude keywords except the ones that I mentioned above, but it is preventing certain static items from enabling when they're supposed to and is there a way to exclude multiple keywords? Here's the script I attempted: ;======================= ;PROPERTIES ;======================= Keyword Property VendorItemFood Auto ;Misc Potion Property FoodBread01A Auto Potion Property FoodApple Auto Potion Property FoodApple02 Auto Potion Property FoodCabbage Auto Potion Property FoodCarrot Auto Potion Property FoodCheeseWedge01 Auto Potion Property FoodCheeseWedge02 Auto Potion Property FoodCheeseWheel01A Auto Potion Property FoodCheeseWheel02A Auto Potion Property FoodGourd Auto Potion Property FoodLeek Auto Potion Property FoodPotato Auto Potion Property FoodTomato Auto ;Drink Potion Property FoodBlackBriarMead Auto Potion Property FoodHonningbrewMead Auto Potion Property FoodMead Auto Potion Property FoodWineAlto Auto Potion Property FoodWineAltoA Auto Potion Property FoodWineBottle02 Auto Potion Property FoodWineBottle02A Auto ;Meat Potion Property FoodBeef Auto Potion Property FoodChicken Auto Potion Property FoodGoatMeat Auto Potion Property FoodHorkerMeat Auto Potion Property FoodRabbit Auto Potion Property FoodSalmon Auto Potion Property FoodVenison Auto ;====================== ;OBJECT REFERENCE PROPERTIES ;====================== ;Misc ObjectReference Property WSRefStaticApple Auto ObjectReference Property WSRefStaticBread Auto ObjectReference Property WSRefStaticApple02 Auto ObjectReference Property WSRefStaticCabbage Auto ObjectReference Property WSRefStaticCarrot Auto ObjectReference Property WSRefStaticCheeseWedge01 Auto ObjectReference Property WSRefStaticCheeseWedge02 Auto ObjectReference Property WSRefStaticCheeseWheel01A Auto ObjectReference Property WSRefStaticCheeseWheel02A Auto ObjectReference Property WSRefStaticGourd Auto ObjectReference Property WSRefStaticLeek Auto ObjectReference Property WSRefStaticPotato Auto ObjectReference Property WSRefStaticTomato Auto ;Drink ObjectReference Property WSRefStaticBlackBriarMead Auto ObjectReference Property WSRefStaticHonningbrewMead Auto ObjectReference Property WSRefStaticMead Auto ObjectReference Property WsRefStaticAltoWine Auto ObjectReference Property WSRefStaticAltoWineA Auto ObjectReference Property WSRefStaticWine02 Auto ObjectReference Property WsRefStaticWine02A Auto ;Meat ObjectReference Property WSRefStaticBeef Auto ObjectReference Property WSRefStaticChicken Auto ObjectReference Property WSRefStaticGoat Auto ObjectReference Property WSRefStaticHorker Auto ObjectReference Property WSRefStaticRabbit Auto ObjectReference Property WSRefStaticSalmon Auto ObjectReference Property WSRefStaticVenison Auto ;======================= ;EVENTS ;======================= Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If akBaseItem.HasKeyword(VendorItemFood) ;I want to add the VendorItemFoodRaw keyword as well ;Misc ElseIf akBaseItem == FoodBread01A ; Enable WSRefStaticBread.enable() ElseIf akBaseItem == FoodApple ; Enable WSRefStaticApple.enable() ElseIf akBaseItem == FoodApple02 ; Enable WSRefStaticApple02.enable() ElseIf akBaseItem == FoodCabbage ; Enable WSRefStaticCabbage.enable() ElseIf akBaseItem == FoodCarrot ; Enable WSRefStaticCarrot.enable() ElseIf akBaseItem == FoodCheeseWedge01 ; Enable WSRefStaticCheeseWedge01.enable() ElseIf akBaseItem == FoodCheeseWedge02 ; Enable WSRefStaticCheeseWedge02.enable() ElseIf akBaseItem == FoodCheeseWheel01A ; Enable WSRefStaticCheeseWheel01A.enable() ElseIf akBaseItem == FoodCheeseWheel02A ; Enable WSRefStaticCheeseWheel02A.enable() ElseIf akBaseItem == FoodGourd ; Enable WSRefStaticGourd.enable() ElseIf akBaseItem == FoodLeek ; Enable WSRefStaticLeek.enable() ElseIf akBaseItem == FoodPotato ; Enable WSRefStaticPotato.enable() ElseIf akBaseItem == FoodTomato ; Enable WSRefStaticTomato.enable() ;Meat ElseIf akBaseItem == FoodBeef ; Enable WSRefStaticBeef.enable() ElseIf akBaseItem == FoodChicken ; Enable WSRefStaticChicken.enable() ElseIf akBaseItem == FoodGoatMeat ; Enable WSRefStaticGoat.enable() ElseIf akBaseItem == FoodHorkerMeat ; Enable WSRefStaticHorker.enable() ElseIf akBaseItem == FoodRabbit ; Enable WSRefStaticRabbit.enable() ElseIf akBaseItem == FoodSalmon ; Enable WSRefStaticSalmon.enable() ElseIf akBaseItem == FoodVenison ; Enable WSRefStaticVenison.enable() ;Drink ElseIf akBaseItem == FoodBlackBriarMead ; Enable WSRefStaticBlackBriarMead.enable() ElseIf akBaseItem == FoodHonningbrewMead ; Enable WSRefStaticHonningbrewMead.enable() ElseIf akBaseItem == FoodMead ; Enable WSRefStaticMead.enable() ElseIf akBaseItem == FoodWineAlto ; Enable WSRefStaticAltoWine.enable() ElseIf akBaseItem == FoodWineAltoA ; Enable WSRefStaticAltoWineA.enable() ElseIf akBaseItem == FoodWineBottle02 ; Enable WSRefStaticWine02.enable() ElseIf akBaseItem == FoodWineBottle02A ; Enable WSRefStaticWine02A.enable() ElseIf RemoveItem.(akBaseItem, aiItemCount, True, akSourceContainer) ;Restrict debug.messagebox("Invalid item") EndIf EndEvent Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) ;Misc If akBaseItem == FoodBread01A ;Disable WSRefStaticBread.disable() WSRefStaticBread.disable() ElseIf akBaseItem == FoodApple ;Disable WSRefStaticApple.disable() ElseIf akBaseItem == FoodApple02 ;Disable WSRefStaticApple02.disable() ElseIf akBaseItem == FoodCabbage ; Disable WSRefStaticCabbage.disable() ElseIf akBaseItem == FoodCarrot ;Disable WSRefStaticCarrot.disable() ElseIf akBaseItem == FoodCheeseWedge01 ; Disable WSRefStaticCheeseWedge01.disable() ElseIf akBaseItem == FoodCheeseWedge02 ; Disable WSRefStaticCheeseWedge02.disable() ElseIf akBaseItem == FoodCheeseWheel01A ; Disable WSRefStaticCheeseWheel01A.disable() ElseIf akBaseItem == FoodCheeseWheel02A ; Disable WSRefStaticCheeseWheel02A.disable() ElseIf akBaseItem == FoodGourd ; Disable WSRefStaticGourd.disable() ElseIf akBaseItem == FoodLeek ; Disable WSRefStaticLeek.disable() ElseIf akBaseItem == FoodPotato ; Disable WSRefStaticPotato.disable() ElseIf akBaseItem == FoodTomato ; Disable WSRefStaticTomato.disable() ;Meat ElseIf akBaseItem == FoodBeef ;Disable WSRefStaticBeef.disable() ElseIf akBaseItem == FoodChicken ;Disable WSRefStaticChicken.disable() ElseIf akBaseItem == FoodGoatMeat ;Disable WSRefStaticGoat.disable() ElseIf akBaseItem == FoodHorkerMeat ;Disable WSRefStaticHorker.disable() ElseIf akBaseItem == FoodRabbit ;Disable WSRefStaticRabbit.disable() ElseIf akBaseItem == FoodSalmon ;Disable WSRefStaticSalmon.disable() ElseIf akBaseItem == FoodVenison ;Disable WSRefStaticVenison.disable() ;Drink ElseIf akBaseItem == FoodBlackBriarMead ;Disable WSRefStaticBlackBriarMead.disable() ElseIf akBaseItem == FoodHonningbrewMead ;Disable WSRefStaticHonningbrewMead.disable() ElseIf akBaseItem == FoodBlackBriarMead ;Disable WSRefStaticBlackBriarMead.disable() ElseIf akBaseItem == FoodMead ;Disable WSRefStaticMead.disable() ElseIf akBaseItem == FoodBlackBriarMead ;Disable WSRefStaticBlackBriarMead.disable() ElseIf akBaseItem == FoodWineAlto ;Disable WSRefStaticAltoWine.disable() ElseIf akBaseItem == FoodWineAltoA ;Disable WSRefStaticAltoWineA.disable() ElseIf akBaseItem == FoodWineBottle02 ;Disable WSRefStaticWine02.disable() ElseIf akBaseItem == FoodWineBottle02A ;Disable WSRefStaticWine02A.disable() EndIf EndEvent Edited May 18, 2015 by Zylice Link to comment Share on other sites More sharing options...
Mattiewagg Posted May 18, 2015 Share Posted May 18, 2015 If akBaseItem.HasKeyword(VendorItemFood) || akBaseItem.HasKeyword(VendorItemFoodRaw) Link to comment Share on other sites More sharing options...
Zylice Posted May 18, 2015 Author Share Posted May 18, 2015 If akBaseItem.HasKeyword(VendorItemFood) || akBaseItem.HasKeyword(VendorItemFoodRaw)Thanks. But do you have any idea why the static items won't enable yet they would before I attempted excluding certain keywords? Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted May 18, 2015 Share Posted May 18, 2015 I see a problem with the Gourd in your food items, it doesn't contain a keyword, so it will fail to add to the container even though it is food and you have it in your list. Maybe use IsFood() instead of HasKeyword().This way you can still let food items that you don't have statics for into the container along with other food items that you have statics for, while still keeping non food items out of the container. I had a play with your script and did the usual knock up test..lolYou can find the "Player Food Cupboard" in Whiterun Bannered Mare Inn, on the left behind the bar.I just used property arrays for the food and static reference items.I ditched the Keyword properties as the seemed more like a hindrance then a help (for this instance anyways).This is the script I used attached to my cupboard:I filled the 2 property arrays in CK keeping the matching order to what you had. Scriptname WSFoodContainerScript extends ObjectReference Potion[] Property FoodType Auto ObjectReference[] Property WSStatic Auto Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) If (akBaseItem As Potion).IsFood() Int i = FoodType.Find(akBaseItem As Potion) If i >= 0 If WSStatic[i].IsDisabled() WSStatic[i].Enable() EndIf Else Debug.Notification("Added food item not in list: " + akBaseItem.GetName()) EndIf Else Self.RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer) Debug.MessageBox("Invalid Item: " + akBaseItem.GetName()) EndIf EndEvent Event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) Int i = FoodType.Find(akBaseItem As Potion) If i >= 0 If Self.GetItemCount(akBaseItem) == 0 WSStatic[i].Disable() EndIf Else Debug.Notification("Removed food item not in list: " + akBaseItem.GetName()) EndIf EndEventHave fun, I did :) Link to comment Share on other sites More sharing options...
Deleted31005User Posted May 18, 2015 Share Posted May 18, 2015 I just made an autosort system myself and I found it was impossible to have all items included with just the use of Keywords because Bethesda didn't even put Keywords on some items that should obviously have them.For those items I had to create FormLists, basically my script would first check my FormLists and then the Keywords, but using FormLists does slow down the sorting speed a bit though, esecially if the player decides to carry around several hundred items. (I know it sounds weird, but the amount of items inside the player inventory actually impacts the speed on which the container is doing the autosorting.) Link to comment Share on other sites More sharing options...
BigBizkit Posted May 18, 2015 Share Posted May 18, 2015 How is that weird? The game has to parse all items in order to check which of them are in a formlist and which aren't. Link to comment Share on other sites More sharing options...
sLoPpYdOtBiGhOlE Posted May 18, 2015 Share Posted May 18, 2015 Myself I've never been fond of Auto Sort containers, I should say Crafting Tables.eg: Workbench, Grindstone, Alchemy Lab, Arcane Enchanter etc.The concept I love the idea of, but the reality for me was that crafting tables are slow to navigate and make items in general.Then add the split seconds on top with the Auto Load/Sort items and it really becomes tedious when trying to craft hundreds of items while bouncing between stations.In the case of the op, his script really doesn't seem to sort much, more just filter what the user can add to the container and enable or disable a static item representing that the container has this type of item stored.Formlists are easier to work with then arrays, due to formlists can have mixed forms, where as an array is set to one data type only.Filling large Array Properties is tedious, creating a formlist takes seconds for 10000+ items, drag and drop, your done.But the speed of creating formlists is a trade for more code checks when handling them and overall slower performance at execution when performing per item checks.eg:Potion myItemInt i = myFormlist.Find(myItem)Will result in papyrus spam if myItem == none.so now I have to:Potion myItemIf myFormlist.HasForm(myItem) Int i = myFormlist.Find(myItem)EndIfWhere as an Array is fine to use a none value to search:Potion myItemInt i = myArray.Find(myItem)Papyrus doesn't generate spam when finding using a none value.Formlist or Array Each have their merits and limitations.Formlist for versatile ease of use, Array for faster execution.Then there are just cases where formlists shine for speed, eg: loading a gift menu, 100000+ items loaded in a gift menu is damn fast, try doing that with an array...lol I often use both Array and formlists.In a current version of MHIYH 4.4 (Not released yet), I use arrays of formlists.18 formlists in an array, each formlist contains 500 NavCut box references.9000 navcut boxes in total and it all works fairly quick. I do the same with MHIYH Duty Markers, 2300+ markers and once again it all works quick to find what I'm after. Link to comment Share on other sites More sharing options...
RadoGamer Posted November 18, 2018 Share Posted November 18, 2018 This works. Link to comment Share on other sites More sharing options...
Recommended Posts