Jump to content

Puzzling mod issue, need suggestions from other modders


Recommended Posts

Hello All,

 

Note this is a duplicate post because I put it in the wrong place to start with...

 

Okay, I've created a mod that contains what I call "Enchanted Containers"; there are six different ones. Each uses a script to filter allowed vs. not allowed items. Please note, the actual question is at the bottom

 

Ingredient Pouch - Items are filtered based on keyword, all items with "VendorItemIngredient" are allowed

 

Scriptname aaCh18_FilterContainerItems extends ObjectReference

Keyword Property VendorTypeKeyword Auto

Actor Property PlayerREF Auto

 

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

 

If akSourceContainer==PlayerREF

 

If !akBaseItem.HasKeyword(VendorTypeKeyword)

 

RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)

Debug.MessageBox("Invalid Item")

 

EndIf

 

EndIf

 

EndEvent

 

 

Gem Bag - This is a small sack that holds gems and jewelry, items are filtered using a Formlist of keywords

 

Scriptname aaCh18_FilterOnKeywordFormlist extends ObjectReference

FormList Property ElligibleKeywordsFLST Auto

Actor Property PlayerREF Auto

 

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

 

If akSourceContainer == PlayerREF

 

Int iCount = ElligibleKeywordsFLST.GetSize()

Bool bAcceptable = False

 

While iCount && !bAcceptable

 

iCount -= 1

Keyword kReference = ElligibleKeywordsFLST.GetAt(iCount) as Keyword

If akBaseItem.HasKeyWord(kReference)

bAcceptable = true

Endif

 

EndWhile

 

If bAcceptable == False

RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)

Endif

 

EndIf

 

EndEvent

 

Here is the FormList:

VendorItemSoulGem

VendorItemJewelry

VendorItemGem

ArmorJewelry

ClothingCirclet

ClothingRing

ClothingNecklace

 

Note that an item is rejected by default (bAcceptable = False) and as soon as one keyword matches bAcceptable = True.

 

Okay, here's my boggle...

 

I have three mods in my load order (a lot more but three for this conversation)

 

Enchanted_Containers.esp (my mod)

 

ImprovedFishBASIC.esp http://www.nexusmods...yrim/mods/14320

 

LeftHandRings.esp

LeftHandRings - Dawnguard.esp http://www.nexusmods...yrim/mods/21720

 

In both the Improved Fish and the Left Hand Rings mods all the items have the appropriate keywords already associated with them. However, all the ingredients from ImprovedFishBASIC go right into their container like they should. On the other hand the items from LeftHandRings which should go into the Gem container will not.

 

The main reason I set them up this way was to increase compatibility with other mods. I'm not very familiar with Papyrus yet so perhaps I'm overlooking something obvious. I've tried all the load orders, all three function exactly the same in any load order.

 

Sorry, was having fun with the colors. Simple things amuse me .

 

 

Link to comment
Share on other sites

I don't use left hand rings, but it may be that they don't have the correct keyword.

Also, I would check the keywords differently. The keywords would need to be properties if done this way though.

 

You could still use the form list of keywords without the while loop though. I recommend getting rid of the while loop personally. I use them only when there is no other alternative, because they lag.

If akSourceContainer == PlayerREF
    if Item.HasKeyword(VendorItemSoulGem):
        bAcceptable = true
    elseif Item.HakKeyword(VendorItemJewelry):
        bAcceptable = true
    elseif Item.HasKeyword(VendorItemGem)
        bAcceptable = true
    elseif Item.HasKeyword(ArmorJewelry)
        bAcceptable = true
    elseif Item.HasKeyword(ClothingCirclet)
        bAcceptable = true
    elseif Item.HasKeyword(ClothingRing)
        bAcceptable = true
    elseif Item.HasKeyword(ClothingNecklace)
        bAcceptable = true
    endif

    if !bAcceptable ; (this is the same as bAcceptable == False)
        RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)
    endif
endif
Link to comment
Share on other sites

Well, now I can't get it to work at all...

 

I changed the script the in way you described and it worked fine. The next time I loaded the game to play nothing would go into the container. In order to try to correct this situation I reverted the setup to what I had before. It still doesn't accept any items. I'm sure there is something fundamental I'm missing so here are additional details about what I'm doing.

 

Each "Enchanted_Container" actually has two components and two scripts. The two components are a MISC item the player has in his/her inventory and a CONT item in a hidden cell. The MISC item has the following script:

 

Scriptname ItemToContainerScript extends ObjectReference

{Used to connect misc item a container.}

ObjectReference Property aaCh18Container Auto

{container object ref to be activated and used as trash bin}

MiscObject Property ContainerObj Auto

{misc item property for the bucket to be removed}

 

Event OnEquipped(Actor akActor) ;when the bucket is equipped...

Game.DisablePlayerControls(false, false, false, false, false, true, false)

utility.wait(0.1)

Game.EnablePlayerControls(false, false, false, false, false, true, false)

utility.wait(0.5)

aaCh18Container.Activate(Game.GetPlayer()) ;...open the trash container

EndEvent

 

This script was taken from another mod (trash container) and I can't say I understand why it works.

 

The script on the container is:

 

Scriptname aaCh18_FilterOnKeywordFormlist extends ObjectReference

FormList Property ElligibleKeywordsFLST Auto

Actor Property PlayerREF Auto

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

If akSourceContainer == PlayerREF

Int iCount = ElligibleKeywordsFLST.GetSize()

Bool bAcceptable = False

 

While iCount && !bAcceptable

 

iCount -= 1

Keyword kReference = ElligibleKeywordsFLST.GetAt(iCount) as Keyword

 

If akBaseItem.HasKeyWord(kReference)

bAcceptable = true

Endif

 

EndWhile

 

If !bAcceptable

RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)

Endif

 

EndIf

 

EndEvent

 

The Formlist is:

 

VendorItemGem

VendorItemJewelry

VendorItemSoulGem

ArmorJewelry

ClothingCirclet

ClothingNecklace

ClothingRing

Link to comment
Share on other sites

Well the problem isn't with this script. I deleted it from the container and the items still didn't go in. I'll go scratch my head some more...

 

Okay, I made some changes to the container's script in an effort to figure out where I am going wrong. The script now looks like this:

 

  1. Scriptname aaCh18_FilterOnKeywordFormlist extends ObjectReference
  2. FormList Property ElligibleKeywordsFLST Auto
  3. Actor Property PlayerREF Auto
  4. Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
  5. Debug.messagebox ("Received " + aiitemcount + "x " + akBaseItem)
  6. If akSourceContainer == PlayerREF
  7. Int iCount = ElligibleKeywordsFLST.GetSize()
  8. Bool bAcceptable = False
  9. While iCount && !bAcceptable
  10. iCount -= 1
  11. Keyword kReference = ElligibleKeywordsFLST.GetAt(iCount) as Keyword
  12. Debug.Messagebox("("+ iCount + ") " + kReference + ", " + bAcceptable)
  13. If akBaseItem.HasKeyWord(kReference)
  14. bAcceptable = true
  15. Debug.Messagebox ("Acceptable with " + kReference + ", " + bAcceptable)
  16. Endif
  17. EndWhile
  18. If bAcceptable == False
  19. Debug.Messagebox ("Putting back in Player's inventory.")
  20. RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)
  21. Endif
  22. EndIf
  23. EndEvent

If I add an item that should be allowed,

I get a message box showing the quantity and item added (Line 7)

I get messages for each keyword as the script looks at it (Line 17)

When a keyword matches I get the message saying the item is acceptable with Boolean set to "True"

At this point since bAcceptable is no longer False the While loop should end,

However, the next message I get is from Line 17 listing the next keyword and bAcceptable as "False"

BUT I never get the message from line 26 telling me the item is going back into the player's inventory

 

There are 7 keywords in the formlist.

The messages come up like this:

(6) <keyword>, False (line 17)

(4) <keyword>, False (line 17)

(2) <keyword>, False (line 17)

(0) <keyword>, False (line 17)

Acceptable with <>, True (line 21) *****Script should be done right here*****

(1) <keyword>, False (line 17)

(3) <keyword>, False (line 17)

(5) <keyword>, False (line 17)

In place of <keyword> is the actual keyword, just too lazy to type them.

 

If I add an item that should NOT be allowed, all the messages are exactly what they should be

  • I get a message box showing the quantity and item added
  • I get messages for each keyword as the script looks at it
  • I get a message telling me "Putting back in Player's inventory"

Obviously I'm confuseded somewhere :smile:.

 

Visually the item appears to go back into the player's inventory before executing the script which makes me think the MISC item and CONT aren't properly linked. But the script executing indicates they are...

Edited by Chemist18
Link to comment
Share on other sites

Try this. It is just a little extra conditioning check in case the script isn't updating the bool value in time before the next iteration of the while loop

 

 

Scriptname aaCh18_FilterOnKeywordFormlist extends ObjectReference
FormList Property ElligibleKeywordsFLST Auto
Actor Property PlayerREF Auto
 
Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	Debug.messagebox ("Received " + aiitemcount + "x " + akBaseItem)
	If akSourceContainer == PlayerREF
		Int iCount = ElligibleKeywordsFLST.GetSize()
		Bool bAcceptable = False
		While iCount <= ElligibleKeywordsFLST.GetSize() && bAcceptable == false
			iCount -= 1
			Keyword kReference = ElligibleKeywordsFLST.GetAt(iCount) as Keyword
			Debug.Messagebox("("+ iCount + ") " + kReference + ", " + bAcceptable)
			If akBaseItem.HasKeyWord(kReference)
				bAcceptable = true
				iCount = (ElligibleKeywordsFLST.GetSize() + 1)
				Debug.Messagebox ("Acceptable with " + kReference + ", " + bAcceptable)
			Endif
		EndWhile
		If bAcceptable == False
			Debug.Messagebox ("Putting back in Player's inventory.")
			RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)
		Endif
	EndIf
EndEvent 

 

 

Link to comment
Share on other sites

Thanks :).

 

I think my problem is bigger than the script though unfortunately. I deleted the script from the container and tested it. Without the script it should accept any item but all items were put right back into the player's inventory. I think the best way to proceed is to create a duplicate of this container from scratch (using your script) and see if it behaves differently.

Link to comment
Share on other sites

Try this. It is just a little extra conditioning check in case the script isn't updating the bool value in time before the next iteration of the while loop

 

 

Scriptname aaCh18_FilterOnKeywordFormlist extends ObjectReference
FormList Property ElligibleKeywordsFLST Auto
Actor Property PlayerREF Auto
 
Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	Debug.messagebox ("Received " + aiitemcount + "x " + akBaseItem)
	If akSourceContainer == PlayerREF
		Int iCount = ElligibleKeywordsFLST.GetSize()
		Bool bAcceptable = False
		While iCount <= ElligibleKeywordsFLST.GetSize() && bAcceptable == false
			iCount -= 1
			Keyword kReference = ElligibleKeywordsFLST.GetAt(iCount) as Keyword
			Debug.Messagebox("("+ iCount + ") " + kReference + ", " + bAcceptable)
			If akBaseItem.HasKeyWord(kReference)
				bAcceptable = true
				iCount = (ElligibleKeywordsFLST.GetSize() + 1)
				Debug.Messagebox ("Acceptable with " + kReference + ", " + bAcceptable)
			Endif
		EndWhile
		If bAcceptable == False
			Debug.Messagebox ("Putting back in Player's inventory.")
			RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)
		Endif
	EndIf
EndEvent 

 

 

How do you guys get your code so neatly into the boxes?

Link to comment
Share on other sites

 

Try this. It is just a little extra conditioning check in case the script isn't updating the bool value in time before the next iteration of the while loop

 

 

Scriptname aaCh18_FilterOnKeywordFormlist extends ObjectReference
FormList Property ElligibleKeywordsFLST Auto
Actor Property PlayerREF Auto
 
Event OnItemAdded(Form akBaseItem, Int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
	Debug.messagebox ("Received " + aiitemcount + "x " + akBaseItem)
	If akSourceContainer == PlayerREF
		Int iCount = ElligibleKeywordsFLST.GetSize()
		Bool bAcceptable = False
		While iCount <= ElligibleKeywordsFLST.GetSize() && bAcceptable == false
			iCount -= 1
			Keyword kReference = ElligibleKeywordsFLST.GetAt(iCount) as Keyword
			Debug.Messagebox("("+ iCount + ") " + kReference + ", " + bAcceptable)
			If akBaseItem.HasKeyWord(kReference)
				bAcceptable = true
				iCount = (ElligibleKeywordsFLST.GetSize() + 1)
				Debug.Messagebox ("Acceptable with " + kReference + ", " + bAcceptable)
			Endif
		EndWhile
		If bAcceptable == False
			Debug.Messagebox ("Putting back in Player's inventory.")
			RemoveItem(akBaseItem, aiItemCount, True, akSourceContainer)
		Endif
	EndIf
EndEvent 

 

 

How do you guys get your code so neatly into the boxes?

 

First, I manually type the spoiler tag (see below) without the hyphens.

[-spoiler-][/-spoiler-]

Second, I copy the script code

Third, I press the code button (blue angle brackets)

Fourth, I paste the copied code into the box that pops up.

 

If you manually type the code tag and paste the code inside, the formatting (i.e. tab spacing) will be lost.

Link to comment
Share on other sites

Thanks :smile:.

 

I think my problem is bigger than the script though unfortunately. I deleted the script from the container and tested it. Without the script it should accept any item but all items were put right back into the player's inventory. I think the best way to proceed is to create a duplicate of this container from scratch (using your script) and see if it behaves differently.

Did you test that on a new game? Sounds like you are using a save that has some previous state of the container stored and it is not taking the new changes into affect.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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