Jump to content

Help Needed With Sort Script


NexBeth

Recommended Posts

First, I'm not a scripter, but I do have a sorting script that I attempted to modify for my need that did compile but is not working as intended.

 

The script:

 

 

;PROPERTIES

 

ObjectReference Property AcceptedItemsContainer Auto

{The container to place accepted items.}

ObjectReference Property AlcoholContainer Auto

ObjectReference Property FoodCookedContainer Auto

ObjectReference Property FoodRawContainer Auto

ObjectReference Property IngredientsContainer Auto

ObjectReference Property PotionsPoisonsContainer Auto

 

ObjectReference Property ApparelContainer Auto

ObjectReference Property ArcaneApparelContainer Auto

ObjectReference Property KidsClothesItemsContainer Auto

ObjectReference Property ArmorHeavyContainer Auto

ObjectReference Property ArmorLightContainer Auto

ObjectReference Property SheildsContainer Auto

 

ObjectReference Property AmmoContainer Auto

ObjectReference Property WeaponsContainer Auto

 

ObjectReference Property GemsContainer Auto

ObjectReference Property HeartStonesContainer Auto

ObjectReference Property JewelryCircletsContainer Auto

ObjectReference Property SoulGemsContainer Auto

 

ObjectReference Property AnimalPartsContainer Auto

ObjectReference Property IngotsStalhrimContainer Auto

ObjectReference Property OresDrewmerScrapContainer Auto

 

ObjectReference Property BooksContainer Auto

ObjectReference Property AlchemyReceipesTomesContainer Auto

ObjectReference Property ScrollsContainer Auto

 

ObjectReference Property FirewoodContainer Auto

ObjectReference Property SpidersPodsReceipesContainer Auto

ObjectReference Property MISCContainer Auto

 

FormList Property AcceptedItemsList Auto

{The form list of items this container will accept.}

FormList Property AlcoholList Auto

FormList Property FoodCookedList Auto

FormList Property FoodRawList Auto

FormList Property IngredientsList Auto

FormList Property PotionsPoisonsList Auto

 

FormList Property ApparelList Auto

FormList Property ArcaneApparelList Auto

FormList Property KidsClothesItemsList Auto

FormList Property ArmorHeavyList Auto

FormList Property ArmorLightList Auto

FormList Property SheildsList Auto

 

FormList Property AmmoList Auto

FormList Property WeaponsList Auto

 

FormList Property GemsItemsList Auto

FormList Property HeartStonesList Auto

FormList Property JewelryCircletsList Auto

FormList Property SoulGemsList Auto

 

FormList Property AnimalPartsList Auto

FormList Property IngotsStalhrimList Auto

FormList Property OresDwemerScrapItemsList Auto

 

FormList Property BooksList Auto

FormList Property AlchemyReceipesList Auto

FormList Property ScrollsList Auto

 

FormList Property Firewood Auto

FormList Property SpidersPodsReceipesList Auto

FormList Property MISCList Auto

 

 

;EVENTS

 

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

 

If AcceptedItemsList.HasForm(akBaseItem)

 

RemoveItem(akBaseItem, aiItemCount, True, AcceptedItemsContainer)

 

Else

RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)

debug.notification("Can not store this item.")

 

EndIf

 

EndEvent

 

 

 

 

This is supposed to auto sort items into respective containers. I have a "master" container (where this script is attached) where all the items are dumped in by the player. (I am using 4 activators that link to the "master" container. These activators are what the player has access to as the "master" sort container is in an inaccessible cell) Items are supposed to then be sorted in to respective containers (such as: Weapons, Armor, Ingredients, etc.) I've completed FormLists related to all these containers. All properties are filled in the script. The problem is that whatever I try to put in to the Master Sort Container, is rejected for sorting....."Can not store this item."

 

Help very much appreciated!

Link to comment
Share on other sites

What are the items in the form list assigned to the AcceptedItemsList property? If these items are not base objects, then individual instances will be rejected. Furthermore, if they are other form lists, behavior may not be what is expected.

 

Also, why the plethora of form lists if only using one within the script? Same question for the containers.

 

I would probably do the following:

 

Not tested for compilation or function, method is viable as I use similar in my Inventory Management System mod.

;PROPERTIES

FormList Property AcceptedItemsContainersList Auto
;this list is a list of all the object references referring to our desired containers
;the list is as follows:
;index 0 = AlcoholContainer
;index 1 = FoodCookedContainer 
;index 2 = FoodRawContainer 
;index 3 = IngredientsContainer 
;index 4 = PotionsPoisonsContainer 
;index 5 = ApparelContainer 
;index 6 = ArcaneApparelContainer 
;index 7 = KidsClothesItemsContainer 
;index 8 = ArmorHeavyContainer 
;index 9 = ArmorLightContainer 
;index 10 = SheildsContainer 
;index 11 = AmmoContainer 
;index 12 = WeaponsContainer 
;index 13 = GemsContainer 
;index 14 = HeartStonesContainer 
;index 15 = JewelryCircletsContainer 
;index 16 = SoulGemsContainer 
;index 17 = AnimalPartsContainer 
;index 18 = IngotsStalhrimContainer 
;index 19 = OresDrewmerScrapContainer 
;index 20 = BooksContainer 
;index 21 = AlchemyReceipesTomesContainer 
;index 22 = ScrollsContainer 
;index 23 = FirewoodContainer 
;index 24 = SpidersPodsReceipesContainer 
;index 25 = MISCContainer 

FormList Property AcceptedItemsList Auto
;this list is a list of all the formlists containing store-able objects, index matching with the container list
;the list is as follows:
;index 0 = AlcoholList Auto
;index 1 = FoodCookedList Auto
;index 2 = FoodRawList Auto
;index 3 = IngredientsList Auto
;index 4 = PotionsPoisonsList Auto
;index 5 = ApparelList Auto
;index 6 = ArcaneApparelList Auto
;index 7 = KidsClothesItemsList Auto
;index 8 = ArmorHeavyList Auto
;index 9 = ArmorLightList Auto
;index 10 = SheildsList Auto
;index 11 = AmmoList Auto
;index 12 = WeaponsList Auto
;index 13 = GemsItemsList Auto
;index 14 = HeartStonesList Auto
;index 15 = JewelryCircletsList Auto
;index 16 = SoulGemsList Auto
;index 17 = AnimalPartsList Auto
;index 18 = IngotsStalhrimList Auto
;index 19 = OresDwemerScrapItemsList Auto
;index 20 = BooksList Auto
;index 21 = AlchemyReceipesList Auto
;index 22 = ScrollsList Auto
;index 23 = Firewood Auto
;index 24 = SpidersPodsReceipesList Auto
;index 25 = MISCList Auto

;EVENTS

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

  Int index = 0
  Debug.Notification("Please be patient as items sort")

  ;sort into containers
  While index < AcceptedItemsList.GetSize()
    Formlist TheList = AcceptedItemsList.GetAt(index) as FormList
    ObjectReference TheCont = AcceptedItemsContainersList.GetAt(index) as ObjectReference

    If TheList.HasForm(akBaseItem)
      Self.RemoveItem(akBaseItem,aiItemCount,True,TheCont)
      Debug.Notification("Moved "+aiItemCount+" of "+akBaseItem.GetName()+" to "+TheCont.GetName())

      ;Only one object sorted at a time, it has been sorted. No need to check others
      ;get out of loop
      index = AcceptedItemsList.GetSize() 
    Else
      index += 1
    EndIf

  EndWhile

  ;finished sorting... deal with left overs
  If Self.GetItemCount(akBaseItem) >= 1
    RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)
    debug.notification("This item cannot be stored.")
  EndIf

  Debug.Notification("Sorting complete")

EndEvent

Note: You may wish to comment out some of the notification statements after testing. Also, the notification statement including GetName() will require SKSE for proper display. If not including SKSE when compiling, remove the GetName() and leave just the variable. The displayed text would then show the ID number of the objects in question.

 

 

 

EDIT: Tweaked code slightly.

Edited by IsharaMeradin
Link to comment
Share on other sites

The items in lists are base items. Also I created a form list for each container. The idea is that the script will sort out everything the player drops into the sort box in to respective containers according to what is in those formlists. Is that wrong?

 

Thank you, IsharaMeradin for the script change. I will implement it. I definitely do not want my mod dependent upon SKSE. To remove the GetName, would I remove this whole line?

 

Debug.Notification("Moved "+aiItemCount+" of "+akBaseItem.GetName()+" to "+TheCont.GetName())

 

Sorry, but I'm really not a scripter.

Link to comment
Share on other sites

The approach is not wrong. However, if you were using SKSE you could improve the code a bit and wait for the container menu to close before sorting out the items. Why? I can foresee large dumps of items into the master chest causing a stack overflow as each item triggers the OnItemAdded event. Without SKSE, you may wish to inform users that they should refrain from dumping large quantities of items. A stack of 100 would be fine but 100 individual items at once could become an issue for some setups. A non-SKSE solution would be to utilize a button or lever to initiate the sorting process. Thus player puts items in, player pulls lever, items sort out.

 

You can remove the line completely or simply drop GetName() making it

Debug.Notification("Moved "+aiItemCount+" of "+akBaseItem+" to "+TheCont)

 

It would end up displaying something like: Moved 6 of [00123456] to [061a2b3c]

Which isn't a good thing to show to the player, but could be helpful in testing.

Link to comment
Share on other sites

Well, I was planing to let users know that large dumps should be avoided. I prefer no dependencies in my mods, especially skse since cc updates breaks it until the team puts out a new version.

 

I don't really want a weird ID message showing up either. Would dropping the line completely produce the ID number type of notifications, or were you referring to changing the debug notification causing that?

 

I actually had a sorting and crafting system set up that is in the modder's resource section which took some time to get going right but it didn't work with the cooking and baking so I ended up scrapping it and going for something simplier. I just deleted out all the buttons attached to that version this weekend! That system had another custom script attached to the levers. Would I need another script to use levers again with this new script?

 

Thanks for the help.

 

-----

I compiled the script without the debug line and the properties are:

Properties Formlist

Accepted items container list

Accepted items list

 

Not sure what I'm supposed to do with that. What about all the form lists I created? Doesn't the script need to know how everything is going to be sorted and where put the the sorted items?

Edited by NexBeth
Link to comment
Share on other sites

With regards to IsharaMeradin.. there is a similar way by using keywords and only few formlists

The next script is an approach, that means something may have to be changed to be working as intended!

 

xyzContainerSortScript

 

Scriptname xyzContainerSortScript extends ObjectReference
; https://forums.nexusmods.com/index.php?/topic/8372013-help-needed-with-sort-script/

; see also
; https://forums.nexusmods.com/index.php?/topic/8301788-reversing-inventoryeventfilter-function/

; ingredients
  FormList PROPERTY CookingIngredientsList auto    ; filled with CK, CookingIngredientsList [FLST:00067E9B]
    ;* [INGR:0001B3BD] Snowberry "Snowberries"
    ;* [INGR:0007E8C5] SlaughterfishEgg01 "Slaughterfish Egg"
    ;* [INGR:00034CDF] SaltPile "Salt Pile"
    ;* [INGR:0005076E] JuniperBerries "Juniper Berries"
    ;* [INGR:0007E8C8] BirdEgg01 "Rock Warbler Egg"
    ;* ..
    ;* [INGR:0004B0BA] Wheat
    ;* [INGR:00034D22] Garlic

; potion/Ingestible
  FormList PROPERTY AlcoholList auto               ; filled with CK, AlcoholicDrinksList [FLST:00072EA2]
    ;* [ALCH:00034C5E] Ale
    ;* [ALCH:00034C5D] FoodMead "Nord Mead"
    ;* [ALCH:0003133C] FoodWineBottle02
    ;* [ALCH:0003133B] FoodWineAlto

  FormList PROPERTY FoodList auto                  ; filled with CK, new created formlist (missing keyword for cooked food)
    ; [ALCH:000F4320] FoodElsweyrFondue
    ; [ALCH:000F431C] FoodTomatoSoup    
    ; [ALCH:000F431E] FoodVegetableSoup
    ; [ALCH:000F431D] FoodVenisonStew

  FormList PROPERTY ExcludeFoodRawList auto        ; filled with CK, new created formlist (vanilla bad keyword settings)
    ; [ALCH:000722BB] FoodMammothMeatCooked
    ; [ALCH:0007224C] FoodGoatMeatCooked
    ; [ALCH:000722C7] FoodPheasantCooked
    ; [ALCH:000722C2] FoodRabbitCooked

  FormList PROPERTY EmptyList auto                ; filled with CK, new created empty formlist


; -- EVENTs -- 4 + "Waiting"

EVENT OnInit()
    Debug.Trace("MasterContainer: OnInit() - has been reached..  emptyList = " +EmptyList)    ; debugging info
    RegisterForSingleUpdateGameTime(0.0)
ENDEVENT


EVENT OnUpdateGameTime()
; update formlists on the fly
    AlcoholList.AddForm( Game.GetForm(0x0001895F) )        ; [ALCH:0001895F] FirebrandWine
    AlcoholList.AddForm( Game.GetForm(0x00085368) )        ; [ALCH:00085368] FoodSolitudeSpicedWine
;;;    AlcoholList.AddForm( Game.GetForm(0x0009380D) )     ; [ALCH:0009380D] AleWhiterunQuest
;;;    AlcoholList.AddForm( Game.GetForm(0x000C5349) )     ; [ALCH:000C5349] FoodWineAltoA
;;;    AlcoholList.AddForm( Game.GetForm(0x000C5348) )     ; [ALCH:000C5348] FoodWineBottle02A
ENDEVENT


EVENT OnActivate(ObjectReference akActionRef)
    Utility.Wait(0.25)        ; -- wait until container menu has been closed --
    gotoState("Waiting")            ; ### STATE ###
    myF_Sort()
ENDEVENT


EVENT OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
; https://www.creationkit.com/index.php?title=AddForm_-_FormList

    EmptyList.AddForm(akBaseItem)
ENDEVENT


;======================================
state Waiting
;============
    EVENT OnActivate(ObjectReference akActionRef)
        Debug.Notification("Please be patient while sorting items")
    ENDEVENT
;=======
endState


; -- FUNCTIONs -- 2 + 6 + 1 = 9

;--------------------------------------
Bool FUNCTION myF_HasKW(Form fm, Int i)  ; helper to shrink amount of properties
;--------------------------------------
    RETURN fm.HasKeyword(Game.GetForm(i) as Keyword)
ENDFUNCTION


;-------------------------------
FUNCTION myF_Add(Form fm, Int i)  ; internal helper
;-------------------------------
    objectReference oRef = myContainer[i]

IF ( oRef )
    self.RemoveItem(fm, self.GetItemCount(fm), TRUE, oRef)
ELSE
    Debug.Trace("Container not found.. index = " +i)
ENDIF
ENDFUNCTION


; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
; -- two-handed --
;;  Keyword PROPERTY WeapTypeBow        auto    ; [KYWD:0001E715] WeapTypeBow
;;  Keyword PROPERTY WeapTypeStaff      auto    ; [KYWD:0001E716] WeapTypeStaff
;;  Keyword PROPERTY VendorItemStaff    auto    ; [KYWD:000937A4] VendorItemStaff
;;  Keyword PROPERTY WeapTypeWarhammer  auto    ; [KYWD:0006D930] WeapTypeWarhammer
;;  Keyword PROPERTY WeapTypeGreatsword auto    ; [KYWD:0006D931] WeapTypeGreatsword
;;  Keyword PROPERTY WeapTypeBattleaxe  auto    ; [KYWD:0006D932] WeapTypeBattleaxe

;----------------------------
FUNCTION myF_Weapons(Form fm)  ; (akBaseItem.GetType() == 41)
;----------------------------
IF myF_HasKW(fm, 0x0001E715)
    myF_Add(fm, 18)            ; bows / crossbows
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x0001E716) ||    myF_HasKW(fm, 0x000937A4)
    myF_Add(fm, 17)            ; magic staves
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x0006D932) || myF_HasKW(fm, 0x0006D931) || myF_HasKW(fm, 0x0006D930)
    myF_Add(fm, 16)            ; 2H-Weapon
    RETURN    ; - STOP -
ENDIF
;---------------------
    myF_Add(fm, 15)            ; 1H-Weapon
ENDFUNCTION


; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;; Keyword PROPERTY ArmorShield   auto           ; [KYWD:000965B2] ArmorShield
;; Keyword PROPERTY ArmorHeavy    auto           ; [KYWD:0006BBD2] ArmorHeavy
;; Keyword PROPERTY ArmorLight    auto           ; [KYWD:0006BBD3] ArmorLight
;; Keyword PROPERTY ArmorJewelry  auto           ; [KYWD:0006BBE9] ArmorJewelry
;; Keyword PROPERTY ArmorClothing auto           ; [KYWD:0006BBE8] ArmorClothing
;; Keyword PROPERTY VendorItemClothing auto      ; [KYWD:0008F95B] VendorItemClothing
;; Keyword PROPERTY GiftChildSpecial auto        ; [KYWD:000A248C] GiftChildSpecial

;--------------------------
FUNCTION myF_Armor(Form fm)  ; (akBaseItem.GetType() == 26)
;--------------------------
IF myF_HasKW(fm, 0x000965B2)
    myF_Add(fm, 10)            ; shields
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x0006BBD2)
    myF_Add(fm, 11)            ; heavy armor
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x0006BBD3)
    myF_Add(fm, 12);           ; light armor
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x0006BBE9)
    myF_Add(fm, 13)            ; jewelry
    RETURN    ; - STOP -
ENDIF
;---------------------
;IF myF_HasKW(fm, 0x0006BBE8)
    myF_Add(fm, 14)            ; clothes
;ENDIF
ENDFUNCTION


; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;; Keyword PROPERTY VendorItemSpellTome auto    ; [KYWD:000937A5] VendorItemSpellTome
;; Keyword PROPERTY VendorItemRecipe    auto    ; [KYWD:000F5CB0] VendorItemRecipe
;; Keyword PROPERTY GiftWizardSpecial   auto    ; [KYWD:000A0E62] GiftWizardSpecial
;; Keyword PROPERTY VendorItemBook      auto    ; [KYWD:000937A2] VendorItemBook

;--------------------------
FUNCTION myF_Books(Form fm)  ; (akBaseItem.GetType() == 27)
;--------------------------
IF myF_HasKW(fm, 0x000937A5)                            
    myF_Add(fm, 6)            ; spelltome
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x000F5CB0)                            
    myF_Add(fm, 7)            ; receipe
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x000A0E62)                            
    myF_Add(fm, 8)            ; wizard skillbook
    RETURN    ; - STOP -
ENDIF
;---------------------
;IF (fm.GetWeight() == 0.0)                ; SKSE required !!!
;    myF_Add(fm, ?)           ; note
;    RETURN    ; - STOP -
;ENDIF
;---------------------
    myF_Add(fm, 9)            ; book
ENDFUNCTION


; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;; Keyword PROPERTY VendorItemFoodRaw auto       ; [KYWD:000A0E56] VendorItemFoodRaw
;; Keyword PROPERTY VendorItemIngredient auto    ; [KYWD:0008CDEB] VendorItemIngredient

;--------------------------------
FUNCTION myF_Ingredients(Form fm)  ; (akBaseItem.GetType() == 30)
;--------------------------------
IF myF_HasKW(fm, 0x000A0E56)                            
    myF_Add(fm, 21)            ; food raw
    RETURN    ; - STOP -
ENDIF
;---------------------
    IF (CookingIngredientsList.Find(fm) >= 0)
        myF_Add(fm, 21)        ; cooking ingredients
    ELSE
        myF_Add(fm, 19)        ; ingredients
    ENDIF
ENDFUNCTION


; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;; Keyword PROPERTY VendorItemFoodRaw            ; [KYWD:000A0E56] VendorItemFoodRaw
;; Keyword PROPERTY VendorItemFood               ; [KYWD:0008CDEA] VendorItemFood
;; Keyword PROPERTY VendorItemPoison             ; [KYWD:0008CDED] VendorItemPoison

;----------------------------
FUNCTION myF_Potions(Form fm)  ; (akBaseItem.GetType() == 46)
;----------------------------
IF myF_HasKW(fm, 0x000A0E56) && (ExcludeFoodRawList.Find(fm) < 0)
    myF_Add(fm, 21)            ; FoodRaw
    RETURN    ; - STOP -
ENDIF
;---------------------
IF (AlcoholList.Find(fm) >= 0)
    myF_Add(fm, 24)            ; (beer, ale, mead, etc.)
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x0008CDEA)
    myF_Add(fm, 20)            ; Food recognized by keyword
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x0008CDED)
    myF_Add(fm, 23)            ; Poison
    RETURN    ; - STOP -
ENDIF
;---------------------
IF (FoodList.Find(fm) >= 0)
    myF_Add(fm, 20)            ; missing keyword "VendorItemFood"     (FoodElsweyrFondue, etc.)
ELSE
    myF_Add(fm, 22)            ; any other Potion / Ingestible
ENDIF
ENDFUNCTION


; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
;; Keyword PROPERTY VendorItemSoulGem    auto    ; [KYWD:000937A3] VendorItemSoulGem
;; Keyword PROPERTY VendorItemGem        auto    ; [KYWD:000914ED] VendorItemGem
;; Keyword PROPERTY VendorItemFireword   auto    ; [KYWD:000BECD7] VendorItemFireword
;; Keyword PROPERTY VendorItemOreIngot   auto    ; [KYWD:000914EC] VendorItemOreIngot
;; Keyword PROPERTY VendorItemClutter    auto    ; [KYWD:000914E9] VendorItemClutter
;; Keyword PROPERTY VendorItemAnimalHide auto    ; [KYWD:000914EA] VendorItemAnimalHide
;; Keyword PROPERTY VendorItemAnimalPart auto    ; [KYWD:000914EB] VendorItemAnimalPart
;; Keyword PROPERTY VendorItemTool       auto    ; [KYWD:000914EE] VendorItemTool

;--------------------------
FUNCTION myF_Miscs(Form fm)  ; (akBaseItem.GetType() == 32)
;--------------------------
    int i = fm.GetFormID()

IF myF_HasKW(fm, 0x000914ED)
    myF_Add(fm, 4)             ; gems
    RETURN    ; - STOP -
ENDIF
;---------------------
IF (i == 0x04017749)                ; [MISC:04017749] DLC2HeartStone **Dragonborn.esm
    myF_Add(fm, 5)             ; HeartStone
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x000BECD7)
    myF_Add(fm, 26)            ; firewood
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x000914EC)
    IF     (i == 0x0005ACDB)        ; [MISC:0005ACDB] OreCorundum
    ELSEIF (i == 0x0005ACDC)        ; [MISC:0005ACDC] OreEbony
    ELSEIF (i == 0x0005ACDE)        ; [MISC:0005ACDE] OreGold
    ELSEIF (i == 0x00071CF3)        ; [MISC:00071CF3] OreIron
    ELSEIF (i == 0x0005ACE1)        ; [MISC:0005ACE1] OreMalachite
    ELSEIF (i == 0x0005ACE0)        ; [MISC:0005ACE0] OreMoonstone
    ELSEIF (i == 0x0005ACDD)        ; [MISC:0005ACDD] OreOrichalcum
    ELSEIF (i == 0x0005ACE2)        ; [MISC:0005ACE2] OreQuicksilver
    ELSEIF (i == 0x0005ACDF)        ; [MISC:0005ACDF] OreSilver
    ELSEIF (i == 0x0402B06B)        ; [MISC:0402B06B] DLC2OreStalhrim  **Dragonborn.esm
    ELSE
        myF_Add(fm, 28)        ; ingot
        RETURN    ; - STOP -
    ENDIF
;    ----------------------
        myF_Add(fm, 27)        ; ore
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x000914EE)
    myF_Add(fm, 29)            ; tool items (charcoal)
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x000914E9)
    myF_Add(fm, 30)            ; clutter (basket)
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x000914EA)
    myF_Add(fm, 31)            ; animal hide (animal pelt)
    RETURN    ; - STOP -
ENDIF
;---------------------
IF myF_HasKW(fm, 0x000914EA)
    myF_Add(fm, 32)            ; animal part (bone skull, ChaurusChitin)
    RETURN    ; - STOP -
ENDIF
;---------------------
;;  [MISC:0401AAD6]    DLC2TaprootSoaked    **Dragonborn.esm        Ingredients

IF (fm as MiscObject)
    myF_Add(fm, 25)            ; any other miscItem
;ELSE
    ; let this item in master container
ENDIF
ENDFUNCTION


;;------------------------------------
;Int FUNCTION myF_GetBaseType(Form fm)  ; helper to reduce stack size, but slows down script runtime
;;------------------------------------
;IF (fm as Weapon)
;                    RETURN 1
;ENDIF
;IF (fm as Armor)
;                    RETURN 2
;ENDIF
;IF (fm as Book)
;                    RETURN 3
;ENDIF
;IF (fm as Ammo)
;                    RETURN 4
;ENDIF
;IF (fm as Scroll)
;                    RETURN 5
;ENDIF
;IF (fm as Key)
;                    RETURN 6
;ENDIF
;IF (fm as Soulgem)
;                    RETURN 7
;ENDIF
;IF (fm as Ingredient)
;                    RETURN 8
;ENDIF
;IF (fm as Potion)
;                    RETURN 9
;ENDIF
;                    RETURN 0
;ENDFUNCTION


;------------------
FUNCTION myF_Sort()
;------------------
    float f = Utility.GetCurrentGameTime()                ; debugging only

int i = EmptyList.GetSize()
    WHILE (i)                                ; WHILE (i > 0)
        i = i - 1
        form fm = EmptyList.GetAt(i)
;;;        int  n  = myF_GetBaseType(fm)    

        IF     (fm as Weapon)
                                myF_Weapons(fm)
        ELSEIF (fm as Armor)
                                myF_Armor(fm)
        ELSEIF (fm as Book)
                                myF_Books(fm)
        ELSEIF (fm as Ammo)
                                myF_Add(fm, 0)            ; AmmoContainer
        ELSEIF (fm as Scroll)
                                myF_Add(fm, 1)            ; ScrollsContainer
        ELSEIF (fm as Key)
                                myF_Add(fm, 2)            ; KeysContainer
        ELSEIF (fm as Soulgem)
                                myF_Add(fm, 3)            ; SoulgemsContainer
        ELSEIF (fm as Ingredient)
                                myF_Ingredients(fm)
        ELSEIF (fm as Potion)
                                myF_Potions(fm)
        ELSE
                                myF_Miscs(fm)
        ENDIF
    ENDWHILE

    f = Utility.GetCurrentGameTime() - f                ; debugging only
    Debug.Trace("Finish sorting in " +f+ " sec")        ; see "papyrus.0.log"
    Debug.Notification("Finish items sorting..")

; deal with left overs
;;;    self.RemoveAllItems(Game.GetPlayer(), TRUE, TRUE)
ENDFUNCTION


; ****************************************************************************************
;;  Keyword PROPERTY VendorItemArrow      auto        ; [KYWD:000917E7] VendorItemArrow
;;  Keyword Property VendorNoSale         auto        ; [KYWD:000FF9FB] VendorNoSale


  ObjectReference[] PROPERTY myContainer auto    ; array of all objectRefs which referring to desired containers
    ;  0 = AmmoContainer
    ;  1 = ScrollsContainer
    ;  2 = KeysContainer
    ;  3 = SoulGemsContainer
    ;  4 = GemsContainer
    ;  5 = HeartStonesContainer

; -- Books
    ;  6 = spelltomeContainer
    ;  7 = AlchemyReceipesTomesContainer
    ;  8 = skillbookContainer
    ;  9 = BooksContainer

; -- Armor --
    ; 10 = ShieldsContainer
    ; 11 = ArmorHeavyContainer
    ; 12 = ArmorLightContainer
    ; 13 = JewelryCircletsContainer
    ; 14 = ClothesContainer

; -- Weapons --
     ; 15 = Weapons1HContainer
     ; 16 = Weapons2HContainer
     ; 17 = BowsContainer
     ; 18 = StavesContainer

; -- Ingredients --
    ; 19 = IngredientsContainer
    ; 20 = FoodCookedContainer
    ; 21 = FoodRawContainer

; -- Potions --
    ; 22 = PotionsContainer
    ; 23 = PotionsPoisonsContainer
    ; 24 = AlcoholContainer

; -- MiscObjects --
    ; 25 = MISCContainer
    ; 26 = FirewoodContainer
    ; 27 = OreStalhrimContainer
    ; 28 = IngotContainer
    ; 29 = ToolItemsContainer
    ; 30 = ClutterContainer
    ; 31 = AnimalHideContainer
    ; 32 = AnimalPartsContainer

    ;  = DwemerScrapContainer
    ;  = ArcaneApparelContainer
    ;  = SpidersPodsReceipesContainer

 

 

Edited by ReDragon2013
Link to comment
Share on other sites

I actually removed sections of the original script that had a keyword section because, in some instances, keywords are absent on items in the CK or result in items that you want to sort to one container going to another. The original script had a formlist check first, then, if item failed the formlist, then it would rely on keywords. My thinking was that I could just rely on the formlists and make sure that items would be on the right lists without fail.

 

That is quite a script ReDragon! It says it relies on skse. It also has all the ids filled in; a lot of work on your part. Does the script prioritize formlist then goes to keywords if formlist fails?

Link to comment
Share on other sites

Well, I was planing to let users know that large dumps should be avoided. I prefer no dependencies in my mods, especially skse since cc updates breaks it until the team puts out a new version.

 

I don't really want a weird ID message showing up either. Would dropping the line completely produce the ID number type of notifications, or were you referring to changing the debug notification causing that?

 

I actually had a sorting and crafting system set up that is in the modder's resource section which took some time to get going right but it didn't work with the cooking and baking so I ended up scrapping it and going for something simplier. I just deleted out all the buttons attached to that version this weekend! That system had another custom script attached to the levers. Would I need another script to use levers again with this new script?

 

Thanks for the help.

 

-----

I compiled the script without the debug line and the properties are:

Properties Formlist

Accepted items container list

Accepted items list

 

Not sure what I'm supposed to do with that. What about all the form lists I created? Doesn't the script need to know how everything is going to be sorted and where put the the sorted items?

The code I provided has comment statements indicating what you need to do. It utilizes a formlist that will contain the other formlists. Instead of having a whole bunch of formlists on the script and having to explicitly write code for each one to be handled, they are all put into a single formlist which gets handled once.

 

If you were to use a button or lever, it would be a different script. Similar approach but it would have to be written from a slightly different viewpoint. Think of it like this, with the script on the master container the script is written in first person (i.e. the master container is referred to as Self). When on a button or lever the script is written in third person (i.e. the master container has to be referred to via property assignment)

 

Redragon is correct that you can use keywords provided those keywords fall in line with how you want to sort your items.

 

I have a modder's resource that demonstrates how to have a single container that the player puts items in and then sort them out to individual containers at the press of a button. It uses an array and was designed solely to work with ingredients. But it may be of use to see the code and how it works in-game. https://www.nexusmods.com/skyrim/mods/25890

Link to comment
Share on other sites

Hello, I created two formlists. One FL lists all my containers which match exactly with the names of the containers in the script. Another FL with all of individual FLs with names that match exactly with the names in the script. Both are indexed appropriatedly with containers and FLs matching up with indexes.

 

When I attempt to store in the sort container where the script is attached the container only accepts one item at a time. For instance, if I have 5 Health Potions, it will reject 4 potions. Try again, it will then reject 3 and accept 1 more potion, etc. This is only based on the messages I received and items reappearing back into my inventory rejected.

 

Now nothing actually goes to any of the containers. All items are lost.

 

I'll re-post my script as maybe I missed something?

 

 

;PROPERTIES

FormList Property EP_AcceptedItemsContainers_FL Auto
;this list is a list of all the object references referring to our desired containers
;the list is as follows:
;index 0 = EP_StorageAlcohol
;index 1 = EP_StorageFood
;index 2 = EP_StorageFoodRaw
;index 3 = EP_StorageIngredients
;index 4 = EP_StoragePotionsPoisons
;index 5 = EP_StorageApparel
;index 6 = EP_StorageArcaneApparel
;index 7 = EP_StorageKidsStuff
;index 8 = EP_StorageArmorHeavy
;index 9 = EP_StorageArmorLight
;index 10 = EP_StorageSheilds
;index 11 = EP_StorageAmmo
;index 12 = EP_StorageWeapons
;index 13 = EP_StorageGems
;index 14 = EP_StorageHeartStones
;index 15 = EP_StorageJewelryCirclets
;index 16 = EP_StorageSoulGems
;index 17 = EP_StorageAnimalParts
;index 18 = EP_StorageIngotsStalhrim
;index 19 = EP_StorageOreDrewmerScrap
;index 20 = EP_StorageBooksNotes
;index 21 = EP_StorageTomesAlchemyReceipes
;index 22 = EP_StorageScrolls
;index 23 = EP_StorageFirewood
;index 24 = EP_StorageSpidersPodsReceipes
;index 25 = EP_StorageMISC
;index 26 = EP_StorageKeys

FormList Property EP_AcceptedItems_FL Auto
;this list is a list of all the formlists containing store-able objects, index matching with the container list
;the list is as follows:
;index 0 = EP_Alcohol Auto
;index 1 = EP_Food Auto
;index 2 = EP_FoodRaw Auto
;index 3 = EP_Ingredients Auto
;index 4 = EP_PotionsPoisons Auto
;index 5 = EP_Apparel Auto
;index 6 = EP_ArcaneApparel Auto
;index 7 = EP_ChildrensItems Auto
;index 8 = EP_ArmorHeavy Auto
;index 9 = EP_ArmorLight Auto
;index 10 = EP_Sheilds Auto
;index 11 = EP_Ammo Auto
;index 12 = EP_Weapons Auto
;index 13 = EP_GemsItems Auto
;index 14 = EP_HeartStones Auto
;index 15 = EP_JewelryCirclets Auto
;index 16 = EP_SoulGems Auto
;index 17 = EP_AnimalParts Auto
;index 18 = EP_IngotsStalhrim Auto
;index 19 = EP_OreDwemerScrap Auto
;index 20 = EP_BooksNotes Auto
;index 21 = EP_TomesAlchemyReceipes Auto
;index 22 = EP_Scrolls Auto
;index 23 = EP_Firewood Auto
;index 24 = SpidersPodsReceipesList Auto
;index 25 = EP_MISC Auto
;index 26 = EP_Keys

;EVENTS

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)

Int index = 0
Debug.Notification("Patience as items sort")

;sort into containers
While index < EP_AcceptedItems_FL.GetSize()
Formlist TheList = EP_AcceptedItems_FL.GetAt(index) as FormList
ObjectReference TheCont = EP_AcceptedItemsContainers_FL.GetAt(index) as ObjectReference

If TheList.HasForm(akBaseItem)
Self.RemoveItem(akBaseItem,aiItemCount,True,TheCont)

;Only one object sorted at a time, it has been sorted. No need to check others
;get out of loop
index = EP_AcceptedItems_FL.GetSize()
Else
index += 1
EndIf

EndWhile

;finished sorting... deal with left overs
If Self.GetItemCount(akBaseItem) >= 1
RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)
debug.notification("This item cannot be stored.")
EndIf

Debug.Notification("Sorting complete")

EndEvent



I actually downloaded your modders resource awhile ago trying to figure things out. I looked at it again and esp in CK. I wouldn't know how to modify a script to include that. Also, I think I'd want to use only one button. The script I was using with the autosort and crafting system script (also a modder's resource) is:

 

 

Make sure to add a container as LinkedRef to this object in the editor.
The container must have bypassPlayerCheck set to false}

ObjectReference property master auto
{The ObjectReference attached with the _sgasgaAutosortMaster-script attached to it}
ObjectReference property mainChest auto
{A container linked to the autosort-system, where BypassPlayerCheck is set to true}
bool property grabItems = true auto hidden

event OnActivate(ObjectReference akActivator)
if self.getLinkedRef() == NONE
;debug.messagebox("No linked ref found!")
return
endif
if(grabItems)
;if you decide to add more containers to the system, add them here as well.
(master as _sgaAutosortMaster).ChestHeavyArmor.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestLightArmor.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestCloth.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestWeapon.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestArrow.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestJewlery.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestGem.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestBook.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestRawFood.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestCookedFood.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestPoison.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestPotion.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestIngredient.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestSoulgem.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestMisc.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestOre.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestLeather.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestIngot.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestShield.removeAllItems(self.getLinkedRef(),false,true)
(master as _sgaAutosortMaster).ChestScroll.removeAllItems(self.getLinkedRef(),false,true)
utility.wait(2.0)
grabItems = false
else
self.getLinkedRef().removeAllItems(mainChest,false,true)
utility.wait(2.0)
grabItems = true
endif

endEvent

 

 

Edited by NexBeth
Link to comment
Share on other sites

The containers that you put into the formlist were they the base object or your pre-placed copy in the render window? If the base object that would explain why they did not go anywhere.

 

No idea why it would only attempt to transfer one instance and reject the others from the stack. It should send the entire stack as that value should be the value of the aiItemCount parameter.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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