Jump to content

Problem with OnItemAdded() to a container


Recommended Posts

To keep my question simple here is a very simple script to do something when I add an item to a container. It works as expected in Skyrim SE but not in Fallout 4. Am I missing something?

 

I attached this script to a container in a cell. I filled out the properties. When I add any item to the container the OnItemAdded() block does not happen. When I remove the item the OnClose() block runs just fine and I see the trace.

 

Scriptname testxxx extends ObjectReference Const
Actor Property PlayerRef Auto Const
MiscObject Property caps001 Auto Const
Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
PlayerREF.AddItem(caps001)
Debug.Trace("XXX999 Item Added")
EndEvent
Event OnClose(ObjectReference akActionRef)
PlayerREF.AddItem(caps001)
Debug.Trace("XXX999 Item Removed")
endEvent
Link to comment
Share on other sites

You need to add AddInventoryEventFilter to your script.

 

Thanks! I missed that link in the doc when I looked up OnItemAdded().

 

The purpose of the real script is to append the item placed in the container into an existing formlist. I won't know before hand what the item is so I can't apply a filter to it. For instance if another mod adds a new scrap item, I want the player to be able to add that scrap item to a formlist so I can then do something with the items in the form list. It's basically a scrap auto-sorter system that will accept mod added items.

 

Is there way to allow any normally storeable item to be recognized by the OnItemAdded()? Maybe a way to tell the filter everything is allowed?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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