Jump to content

Detecting when a container is empty


Funkonaut

Recommended Posts

UPDATE: SOLVED

 

I found solution that works for my situation, though it still has limitations in application. I realized that since my container has gatekeep functions that only let items on a certain formlist to be added in the first place, I could add a keyword to all of these "allowed items" and then run a check using GetItemCount (which requires a specific akItem reference input, unfortunately, so you can't just say "get count of anything").

 

 

 

Event OnActivate(ObjectReference akActionRef)

if akActionRef == Game.GetPlayer()

if self.GetItemCount(MixerAllowedKeyword) == 0 ;add a keyword property at the top of script and fill in in the CK
Debug.Trace("no items with keyword inside, resetting mixerArray")
mixerArray = New Form[3]
else
debug.trace("something with mixer keyword inside, not resetting array")
endIf

Endif

EndEvent

 

 

 

 

 

__________

 

Hello,

 

Does anyone know if there is a way to detect via script when a container is emptied of its contents, or is in an empty state?

 

I need the script to detect when the player has hit 'R' and taken all items, which auto-closes the container. It would also be useful if I could detect when they simply Esc out and leave items still in there.

 

My two thoughts so far were

 

1) use OnClose() (if it works on non-animating objects) and simply force-clear the contents regardless of whether the player Esc'd out or did "R take all", and return any items to player inventory that were still in the container. At least that way I know the status of the items no matter what, though I'd prefer not to force things back into the player inventory as they might not be expecting it. I'm not sure if OnClose() works anyway, as the container I'm using doesn't have a close animation...?

 

2) Somehow detect the player's "R" input, knowing that that means they just "took all" from the container, i.e. now I can tell the script the container is empty with a bool or something.

 

Any advice or help is much appreciated.

 

EDIT:

 

Thought it might be useful to explain a little more what I'm doing. The script on my container is using an array to keep track of what goes into and out of the container, and also allows only certain types of items. An array of its contents, essentially (with a limit, i.e. they can't put more than 3 items in the container). It works great when the player adds and takes away items one by one, and handles when they try to add a large stack that exceeds the container's capacity as well as invalid ingredient types. My problem arises when a player hits R to take all and auto-exits. This seems to throw off the array somehow, it doesn't empty properly and often will retain some of the references (but not all), even though of course the container appears empty in terms of inventory. If I could detect the empty state I could just force-clear the array to avoid this problem.

Edited by Funkonaut
Link to comment
Share on other sites

  • Recently Browsing   0 members

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