bluemarvin Posted November 23, 2018 Share Posted November 23, 2018 OK so this is strange. I'm just trying to run a simple GetItemCount call on a container/chest to check and see if it contain's Linwe's Armor. Here's the function with the debug message I'm using, expecting it to return "1" for the result since the item IS in the container: Function ReportFromChest (Armor akArmor1, ObjectReference akMyHiddenArmorBox) Debug.MessageBox ("In Hidden Box: " + akMyHiddenArmorBox.GetItemCount(akArmor1) + "!") endFunctionThe container is an ObjectReference set through Properties to point at a container in the cell: ObjectReference Property ArmoryLightHiddenBox AutoAnd here is how the function is called which is during an OnCellLoad event: ReportFromChest(ArmorToPass,ArmoryLightHiddenBox)Even though the armor IS in the box, I get 0 every time. But here's the kicker: I have another container in the environment with a copy of the armor in it, and when I assign through properties to THAT container, I get the expected 1. So I duplicated the container that is working and assigned the container Object Reference to that duplicate, and it goes back to reporting 0. Even though I am setting it through Properties to the intended container, I don't think the script is looking in the right container. Except when I use the container that had been in the cell for a while before I started working this new script. Any ideas on this complete mystery? Link to comment Share on other sites More sharing options...
foamyesque Posted November 23, 2018 Share Posted November 23, 2018 What happens if you open and close the container, then run the script? Or if you load the cell, unload the cell, then load the cell again? I suspect what's happening is that the new container's inventory hasn't been generated at the time the script runs. Link to comment Share on other sites More sharing options...
bluemarvin Posted November 23, 2018 Author Share Posted November 23, 2018 You nailed it, wow thank you so much. I wasted HOURS on this.It was the opening the chest that did it; I had already been exiting and re-entering the room in order to cause the script to fire, so apparently that wasn't enough, I needed to actually open the chest once. I hope this was just caused by my use of an old save file to start, because the chest will ultimately be hidden and players won't have a chance to open/close it of course when all is done. Thanks again. Link to comment Share on other sites More sharing options...
bluemarvin Posted November 23, 2018 Author Share Posted November 23, 2018 Just as an update here... so far open/closing the chest is the only thing that works. I tried waiting around in the cell, then leaving, then fast traveling to the other side of the world and back, but still reports "0" on entering the cell unless I open/close that chest first and THEN leave/re-enter it. That's a potential problem for the mod. Any ideas how I can force that chest to load the inventory programmatically? Link to comment Share on other sites More sharing options...
IsharaMeradin Posted November 23, 2018 Share Posted November 23, 2018 Items pre-placed in a container are unknown to papyrus. Solutions in no particular order:1. Require player to open the container thus exposing the contents.2. Use papyrus to remove all the items from the one container to a known mod added empty container. Have a script on this second container return the individual items as they are added. After adding back, GetItemCount should recognize any item found within the first container. Link to comment Share on other sites More sharing options...
PeterMartyr Posted November 23, 2018 Share Posted November 23, 2018 Try creating a Array or Formlist, with the contents of the chest & check that. If loading or opening the chest is an issue. Remember with SKSE you can have unsigned Arrays, be responsible with what you do, or don't do at all!! (or make sure the chest has less than 128 items) Also you will find no information on CK wikki (nor use there be! this is dangerous stuff) on how use Utility Create Array SKSE features. So if your Papyrus Log Explodes? Take the hint. Also if you don't get how to use these features, don't ask. it missing for a reason, & posting how to on forum how to is not very responsible either. But if you code, you will work out. Link to comment Share on other sites More sharing options...
foamyesque Posted November 24, 2018 Share Posted November 24, 2018 Just as an update here... so far open/closing the chest is the only thing that works. I tried waiting around in the cell, then leaving, then fast traveling to the other side of the world and back, but still reports "0" on entering the cell unless I open/close that chest first and THEN leave/re-enter it. That's a potential problem for the mod. Any ideas how I can force that chest to load the inventory programmatically? Try putting it in a quest alias. That should make the chest persistent, at least, which may fix your load problems. Link to comment Share on other sites More sharing options...
NexusComa Posted November 24, 2018 Share Posted November 24, 2018 (edited) Just a guess here ... if (akMyHiddenArmorBox.GetItemCount(akArmor1) == 1) Debug.Trace("Chest has Armor") endIf or != 0 I looked at a few of mine but mine go off Event OnItemAdded Edited November 24, 2018 by NexusComa Link to comment Share on other sites More sharing options...
Recommended Posts