Difference between revisions of "SKSE Plugin Development/Calling Papyrus Functions"
Jump to navigation
Jump to search
(Created page with "<syntaxhighlight lang="c++"> auto vm = RE::BSScript::Internal::VirtualMachine::GetSingleton(); RE::TESForm* form = RE::TESForm::LookupByEditorID("MyQuest"); auto policy = vm...") |
(No difference)
|
Latest revision as of 17:50, 10 December 2024
auto vm = RE::BSScript::Internal::VirtualMachine::GetSingleton();
RE::TESForm* form = RE::TESForm::LookupByEditorID("MyQuest");
auto policy = vm->GetObjectHandlePolicy();
RE::VMHandle handle = policy->GetHandleForObject(form->GetFormType(), form);
if (handle == policy->EmptyHandle()) {
return;
}
RE::BSFixedString scriptName = "MyScript";
RE::BSFixedString functionName = "MyFunction";
RE::BSTSmartPointer<RE::BSScript::Object> object;
RE::BSTSmartPointer<RE::BSScript::IStackCallbackFunctor> result;
if (vm->FindBoundObject(handle, scriptName.c_str(), object)) {
int x = 42;
auto args = RE::MakeFunctionArguments(std::move(x));
vm->DispatchMethodCall1(object, functionName, args, result);
}
Source: How to call Papyrus functions from SKSE / CommonLibSSE Plugin : r/skyrimmods