LoginToDownload Posted February 22, 2012 Share Posted February 22, 2012 (edited) I notice the PlaceAtMe functionality has increased significantly since Oblivion days, including a 'force persistent' variable, but I'm having some trouble finding out what this means for its usage. Does this mean that you can use PlaceAtMe indefinitely without bloating the savegame, so long as Force Persistent remains false? Just for Actors? For everything, from WorldObjects to swords? Thanks to all. My current scripts are piling up references at an uncomfortable rate, and I would love to be able to use forms instead. Edited February 22, 2012 by LoginToDownload Link to comment Share on other sites More sharing options...
gsmanners Posted February 22, 2012 Share Posted February 22, 2012 (edited) PlaceAtMe will "bloat" your save file either way. It's just a question of how much. The thing about "persistent" objects is that they bloat how much memory they use at run time. (A persistent object stays in memory even if you aren't in the same cell.) Edited February 22, 2012 by gsmanners Link to comment Share on other sites More sharing options...
LoginToDownload Posted February 22, 2012 Author Share Posted February 22, 2012 (edited) Alright, I'll stick to the old-fashioned way. Thank you.Grumblemumble stupid CK... EDIT: What if one uses the Delete function? Edited February 22, 2012 by LoginToDownload Link to comment Share on other sites More sharing options...
LoginToDownload Posted February 23, 2012 Author Share Posted February 23, 2012 Ordinarily I would just suck it up, let this thread fall down and act as if it was impossible, but the Delete function seems tailor-made for this and it's not something I can really test personally. Can someone pretty please confirm/deny that Delete can be used to completely remove PlaceAtMe'd objects? Link to comment Share on other sites More sharing options...
gsmanners Posted February 23, 2012 Share Posted February 23, 2012 I don't see how anyone could confirm it, although I'm 99% confident that Delete will work (so long as you don't have the object being used). Link to comment Share on other sites More sharing options...
LoginToDownload Posted February 23, 2012 Author Share Posted February 23, 2012 (edited) Thank you again. If someone with a basic understanding of the scripts says they should work, that's easily good enough for me. Edited February 24, 2012 by LoginToDownload Link to comment Share on other sites More sharing options...
5133p39 Posted September 11, 2019 Share Posted September 11, 2019 (edited) I recently "found" something i wouldn't expect.It is about how the game stores values of references that you cast as something else, possibly resulting in creation of unexpected variable references to objects, preventing those objects from being removed from the save after calling Delete(), because something is still referencing those objects.A simplified realworld example of a script i have:(this is attached to my custom MiscItem in CK, which is getting frequently spawned by another script using PlaceAtMe()) Scriptname MorsConjuredItem extends objectReference {attach to a miscItem in CK to make it despawn after some time once it was placed in the world} effectShader property onUnloadShader auto {effectShader to play right before despawning} float property duration = 5.0 auto {how long before the item despawns} potion property foodItem auto {the food item to turn this into when activated} form miscItem = none bool doOnce = true event OnLoad() if doOnce doOnce = false miscItem = self as form ; DO YOU SEE THE PROBLEM? YOU DO? WELL, I DIDNT UNTIL I FOUND THE HARD WAY GotoState("LINGER") RegisterForSingleUpdate(duration) endIf endEvent state LINGER event OnUpdate() GotoState("FADEOUT") if Is3DLoaded() && onUnloadShader onUnloadShader.Play(self) endIf RegisterForSingleUpdate(2.5) endEvent endState state FADEOUT event OnUpdate() Disable() Delete() miscItem = none ; SEE THIS? DID YOU KNOW THAT YOU NEED THIS TO PREVENT SAVE FILE BLOAT? endEvent endState event OnContainerChanged(objectReference _newContainer, objectReference _oldContainer) if _newContainer UnregisterForUpdate() _newContainer.RemoveItem(miscItem, 1, true) _newContainer.AddItem(foodItem, 1, true) miscItem = none ; HERE IT IS AGAIN. DID YOU REALLY KNOW WHAT WOULD HAPPEN IF YOU WOULDNT DO THIS? endIf endEventDo note the lines where i set miscItem to NONE?It turns out, that if you do... miscItem = self as form...the game seem to literally store the value as "reference to the objectReference this script is attached to, but as a form".In other words, doing the above seems to internally create a reference to the objectReference that script is attached to,preventing the objRef from being deleted after calling Delete() on it.I stumbled on this by accident when i checked my save file with Fallrim Tools out of pure curiosity, and saw over 51000 zombie instances of my item script and same number of related refids that never got deleted.So i recommend using Fallrim Tools from time to time to test what kind of leftovers your mod leaves behind - you may be surprised. Edited September 11, 2019 by 5133p39 Link to comment Share on other sites More sharing options...
ReDragon2013 Posted September 19, 2019 Share Posted September 19, 2019 According to your script above "5133p39" thank you very much.Good to known that objectReference (actors as well) stored in script "form" variable also suffer from "persistent bug". Best way is to avoid such construct, maybe script as follow:MorsConjuredItem Scriptname MorsConjuredItem extends ObjectReference {attach to a miscItem in CK to make it despawn after some time once it was placed in the world} ; https://forums.nexusmods.com/index.php?/topic/578205-placeatme-and-save-bloating/ ; 5133p39 wrote: "savegame bloat by using placeatme()" Potion PROPERTY foodItem auto ; {the food item to turn this into when activated} EffectShader PROPERTY onUnloadShader auto ; {effectShader to play right before despawning} Float PROPERTY duration = 5.0 auto ; {how long before the item despawns} Bool doOnce = TRUE Bool bRun ; [default=False] ; -- EVENTs -- 4 EVENT OnCellDetach() bRun = False ENDEVENT EVENT OnUnLoad() bRun = False ENDEVENT EVENT OnLoad() ; item has 3D ready now IF ( doOnce ) bRun = TRUE doOnce = False Utility.Wait(duration) ; How long before the item should play the unload sequence? IF ( bRun ) myF_Effect() Utility.Wait(2.5) ; How long before the item has to despawn finally? ENDIF IF ( bRun ) self.Disable() ; do it only, if object can be seen ENDIF self.Delete() ; mark this object as ready for deletion, objectID will be moved to trashcan queue only ENDIF ENDEVENT EVENT OnContainerChanged(ObjectReference akNewContainer, ObjectReference akOldContainer) IF ( akNewContainer ) myF_ItemSwitch(akNewContainer) ENDIF ENDEVENT ; -- FUNCTIONs -- 2 ;-------------------- FUNCTION myF_Effect() ;-------------------- IF ( onUnloadShader ) onUnloadShader.Play(self as ObjectReference) ENDIF ENDFUNCTION ;-------------------------------------------- FUNCTION myF_ItemSwitch(ObjectReference oRef) ;-------------------------------------------- oRef.RemoveItem(self as Form, 1, TRUE) IF ( foodItem ) oRef.AddItem(foodItem as Form, 1, TRUE) ELSE Debug.Notification("Missing property foodItem!") ENDIF ENDFUNCTION Link to comment Share on other sites More sharing options...
Recommended Posts