ZerasCETA Posted March 10, 2017 Share Posted March 10, 2017 (edited) I've got an objectreference script attached to a workshop created object, that upon the event OnInit(), immediately places another unique object on a node. The second placed object needs to have access to the unique reference of the first to be able to disable and delete it. The problem I'm having is that since both are unique, placed references, I can't use a property referencing the base object from the editor, meaning the objectreference properties have to be created dynamically. These objects could exist multiple times in the world and i need the second objects to only reference the ones that created them. This is the script running on the first object, it has no issues for what it does but probably needs something added for the solution to my issue. Scriptname ZW_GMccT_BaseActivator extends ObjectReference Default Form Property GMccT_PA_Dummy Auto Const ;The base object of the one to be created Event OnInit() self.BlockActivation(True, True) ObjectReference GMccT = self as objectreference GMccT.PlaceAtNode("PA_Attach", GMccT_PA_Dummy) ;new object placed endEvent Then here's the hypothetical script running on the second object, where the reference "InstanceOfOriginalObjectThatCreatedThisOne" would reference the object instance that created this object, and no others, even if others of the same base object exist in the same cell: Scriptname ZW_GMccT_PA extends ObjectReference Default ObjectReference InstanceOfOriginalObjectThatCreatedThisOne Property Event OnActivate(ObjectReference ActivateRef) InstanceOfOriginalObjectThatCreatedThisOne.DisableNoWait() InstanceOfOriginalObjectThatCreatedThisOne.Delete() EndEvent I've read up on LinkedRefs and didn't understand it but that might be the answer. I also considered using the return value of PlaceAtNode but I'm pretty sure this just returns the base object, right? I really couldn't get that to work right so I abandoned it. I also considered using keywords but quickly realized that there's nothing to stop all instances of the object from having the same keywords and all being deleted at once.So... How do I do it...? Edited March 10, 2017 by ZerasCETA Link to comment Share on other sites More sharing options...
deadbeeftffn Posted March 10, 2017 Share Posted March 10, 2017 (edited) LinkedRef is the way to success ;-) Scriptname ZW_GMccT_BaseActivator extends ObjectReference Default Form Property GMccT_PA_Dummy Auto Const ;The base object of the one to be created Keyword Property theKey Auto Const Event OnInit() self.BlockActivation(True, True) ObjectReference GMccT = self as objectreference ObjectReference newItem = GMccT.PlaceAtNode("PA_Attach", GMccT_PA_Dummy) ;new object placed newItem.SetLinkedRef(GMccT, theKey) endEvent Scriptname ZW_GMccT_PA extends ObjectReference Default Keyword Property theKey Auto Const Event OnActivate(ObjectReference ActivateRef) ObjectReference myMaster = GetLinkedRef(theKey) SetLinkedRef(none, theKey) ; unlink myMaster (see Edit) myMaster.DisableNoWait() myMaster.Delete() EndEvent Well, i didn't test it. I wrote this quickly from memory, thus it could be totally wrong.Maybe it will also work without a keyword since keywords are optional. Not sure... Edit: It would be a good idea to unlink the master object since it will not be available any longer after Delete() Edited March 10, 2017 by deadbeeftffn Link to comment Share on other sites More sharing options...
ZerasCETA Posted March 10, 2017 Author Share Posted March 10, 2017 That did it! And without the keyword too, that's perfect, thank you so much. I tried to learn about linked ref's from an old skyrim tutorial by Cipsis but I just wasn't getting it by the way it was explained. I still don't fully understand but whatever, it works and that's what I needed. Link to comment Share on other sites More sharing options...
Recommended Posts