niston Posted January 25, 2020 Share Posted January 25, 2020 I have a full interior settlement (full red workbench, registered as workshop, can set up supply lines, etc). When I'm in that settlement, I can access the workshop contents using refWorkshop.GetContainer() just fine. The refWorkshop reference is a hard one, always pointing to the workshop in that interior settlement (ie, its not filled through aliases or anything). Now, when I go to another interior (not a settlement) and try to access the workshop container with the same code, it comes back totally empty - UNLESS I first went to the interior settlement and opened the workshop and then returned to my non-settlement interior. In that case, I can access the interior settlement workshop contents. Strange enough. But if I then go from that non-settlement interior to another non-settlement interior and try to access my red workshop contents once more, the container is empty. UNLESS I go back to the interior workshop settlement first, and open the workshop. WTF! If I use the same code to access other settlement workshops, it works just perfectly fine, all the time. I can access Sanctuary workshop content w/o problems. I can also access the Mechanist's Lair Workshop content (tested to make sure that it isn't a general problem with interior settlements). But as soon as I try to access my own interior settlement workshop's content and haven't visitied that interior settlement immediately beforehand, the container shows up completely empty. I have checked the WorkshopLinkContainer reflink on the settlement workbench. I've also made sure the red workbench there has the MustPersist keyword. But it's as if my workshop in the interior settlement would not persist and get unloaded anyways, for some weird reason. Why is this super bizarre behavior? I can't figure out a solution, It's driving me insane! Link to comment Share on other sites More sharing options...
DieFeM Posted January 25, 2020 Share Posted January 25, 2020 I never had to deal with this situation, but there you have a couple of things I would try, and a possible solution: If you look at a cell in FO4Edit you'll notice the objects are stored in two categories, persistent and temporary, I don't know what is the criteria that the CK uses for storing objects on those categories, but I noticed all vanilla workbenches are stored in the persistent category, so if, for some weird reason, your custom workshop workbench is stored in the temporary category that could maybe be the reason. Additionally I would make sure the parent location of the location assigned for this interior is properly configured, I don't say it must have something to do with it, but doesn't hurt testing. As a last resource, you could call PreloadTargetArea() on the workshop reference before GetContainer() to force the cell references to be loaded if the player is not in this cell (If WorkshopRef.GetParentCell() != Game.GetPlayer().GetParentCell()). Link to comment Share on other sites More sharing options...
niston Posted January 25, 2020 Author Share Posted January 25, 2020 Hey DieFem :smile: I already checked the persistence flags in xedit. I've also tried adding a quest with two reference aliases, filled w/ specific references <red workshop> and <chest>. That should force persistence, but the result is unchanged. What I'm ultimately trying to do is, I've got a bunch (about 70) buildable interiors with interior workbenches each (WorkshopWorkbenchInterior). I would like them to access the inventory of the red workbench in my interior settlement. So I refLinked the interior workshops to the settlement workshop, via WorkshopLinkContainer keyword. When I visit the interior settlement, and then go to one of the buildable interiors, this works fine: After opening the interior workshop with R) TRANSFER, the inventory from the interior settlement workbench is displayed. But if I go to another buildable interior and try to open the workshop there, I'm presented with an empty container. I have to go back to my interior settlement first and open workshop, then return to the buildable interior. So I thought, maybe its not possible to link the workshops directly. And I tried making a script to access the interior settlement workshop, to see if I could cunningly transfer the red workshops' contents to the interior workshop when it's opened, and then transfer the contents back to the settlement workshop, once the interior workshop is closed again. But when I try to do this, refInteriorSettlementWorkshop.GetContainer() also gives me an empty container as initially described. I'm a bit at a loss. EDIT: Now that I written everything down, it dawned on me. It appears that workshops sort of "acquire" their linked container, when they're opened in presence (walk up to, R for inventory). So when I opened up the red workshop in the interior settlement, it acquired it's proper container. But as I then opened an interior workshop in another interior, and because it was linked with LinkContainer keyword, it would then acquire the empty container of the interior workshop. So, after removing the reflink to the red workshop from the interior workshop, GetContainer() now appears to work as expected. Link to comment Share on other sites More sharing options...
niston Posted January 25, 2020 Author Share Posted January 25, 2020 Here's the little script that does the copying: Scriptname YourNamespace:InteriorWorkshopLink extends ObjectReference String Property PluginName = "YourPlugin.esp" Auto Const { Name of the plugin this script resides in } Int Property MasterWorkshopID = 0x1337 Auto Const { REFR form ID for the master workshop workbench } Event OnCellAttach() Setup() EndEvent Event OnCellDetach() Teardown() EndEvent Event OnWorkshopMode(bool bStart) ; red workshop contents might have changed in time, so make sure we transfer again on workshop start/stop Setup() EndEvent Function Setup() ; move everything from red workshop to self ObjectReference refMasterWorkshop = Game.GetFormFromFile(MasterWorkshopID, PluginName) as ObjectReference refMasterWorkshop.RemoveAllItems(Self, true) refMasterWorkshop = none EndFunction Function Teardown() ; move everything from self back to red workshop ObjectReference refMasterWorkshop = Game.GetFormFromFile(MasterWorkshopID, PluginName) as ObjectReference Self.RemoveAllItems(refMasterWorkshop, true) refMasterWorkshop = none EndFunction It's to be attached to a custom interior workshop workbench. I choose to leverage the CellAttached/Detached events instead Workshop Open/Close and use the later only for update purposes; Works perfectly fine for interior cells. You must replace the workshop REFR form ID as well as the plugin name, plus you have to edit the namespace to use the script. Link to comment Share on other sites More sharing options...
SKKmods Posted January 25, 2020 Share Posted January 25, 2020 I believe that the separate workshoplinkcontainer is from a time before the red workshop became a container itself. If you always use the workshopref, not the external container you will be fine. Thats how my global workshop storage and global stash mods have been working to manage internal and external workshop inventory with no problem for several years. Tldr; ignore workshoplinkcontainer just use the workshopref. Link to comment Share on other sites More sharing options...
Recommended Posts