SkyrimThiago Posted April 17 Share Posted April 17 (edited) I am trying to copy the scripts from a form to another, however I am having an issue that the script I want to copy is not appearing, I have the hypothesis that this is because it is an object reference script. I have a misc object I created in CK, with this script attached: Quote ScriptName FC_ScriptMessageOnActivate Extends ObjectReference MiscObject Property Item Auto Event OnEquipped(Actor akActor) Debug.MessageBox(Item) EndEvent It prints a form that it takes as a property when you click on the item in your inventory, mostly to see if the properties are being copied correctly The following code is an attempt of copying the scripts, it is not getting the script I want to copy. It is instead getting only a script I don't want to copy (some kind of base scripts the object have), however I can ignore this script later when I'm getting the actual script auto* virtualMachine = RE::BSScript::Internal::VirtualMachine::GetSingleton(); if (virtualMachine) { auto* handlePolicy = virtualMachine->GetObjectHandlePolicy(); auto* bindPolicy = virtualMachine->GetObjectBindPolicy(); if (handlePolicy && bindPolicy) { auto baseHandler = handlePolicy->GetHandleForObject(baseForm->GetFormType(), baseForm); auto newHandler = handlePolicy->GetHandleForObject(newForm->GetFormType(), newForm); print("form", baseForm->GetName()); if (baseHandler != handlePolicy->EmptyHandle() && newHandler != handlePolicy->EmptyHandle()) { auto baseHandlerScripts = virtualMachine->attachedScripts.find(baseHandler); if (baseHandlerScripts != virtualMachine->attachedScripts.end()) { auto* scripts = &(*baseHandlerScripts).second; auto scriptNumber = scripts->size(); for (uint32_t i = 0; i < scriptNumber; ++i) { auto script = (*scripts)[i].get(); auto ptr = new RE::BSTSmartPointer(script); bindPolicy->BindObject(*ptr, newHandler); print("script", script->type->GetName()); } } } } } Both newForm and baseForm are RE::TESObjectMISC here is the code for the print function, it is mostly for debugging so i did not put much thought into that I have also tried doing this but no success auto baseHandler = handlePolicy->GetHandleForObject(RE::FormType::Reference, baseForm); auto newHandler = handlePolicy->GetHandleForObject(RE::FormType::Reference, newForm); If I find a solution to this ill post here, but maybe someone is able to help me. Edited April 17 by SkyrimThiago Link to comment Share on other sites More sharing options...
IsharaMeradin Posted April 17 Share Posted April 17 I cannot help you as I know nothing about the C++ side of SKSE. However, I have to ask, why are you using SKSE to try and copy a script from one record to another? Why can you not assign the script to the desired record(s) in the Creation Kit? Link to comment Share on other sites More sharing options...
SkyrimThiago Posted April 17 Author Share Posted April 17 (edited) 1 hour ago, IsharaMeradin said: I cannot help you as I know nothing about the C++ side of SKSE. However, I have to ask, why are you using SKSE to try and copy a script from one record to another? Why can you not assign the script to the desired record(s) in the Creation Kit? I am working on a mod that allow the creation of persistent forms at runtime, as a copy of another form. And I want to copy the scripts from the original form into the new form. Edited April 17 by SkyrimThiago Link to comment Share on other sites More sharing options...
Recommended Posts