How to get a string from SKSE plugin into Papyrus?

Post » Tue Jan 26, 2016 2:56 pm

I have a lot of dev experience. But, am completely new to C++. So, the answer to this question may be really obvious... I followed this guide to create my first, simple SKSE plugin: https://github.com/xanderdunn/skaar/wiki/SKSE%3A-Getting-Started



That works great. Now I want to alter the plug-in so that it sends a string into Papyrus instead of a number. I have tried adding "#include " to various places and tried every combination I could think of for "string" and "std::string" as the type identifiers. But, I keep getting compile errors that I don't quite understand.



Can anyone explain how to send a string into Papyrus or write a piece of code showing how it is done? Maybe as a return value isn't the best way...?



Any help would be greatly appreciated!

User avatar
Jade MacSpade
 
Posts: 3432
Joined: Thu Jul 20, 2006 9:53 pm

Post » Tue Jan 26, 2016 5:23 pm

You probably want BSFixedString. Take a look at the SKSE papyrus scripts and their .h and .cpp files. ObjectReference.psc has "string Function GetDisplayName() native" corresponding to PapyrusObjectReference.h



BSFixedString GetDisplayName(TESObjectREFR* object);

and PapyrusObjectReference.cpp



BSFixedString GetDisplayName(TESObjectREFR* object)
{
return (object) ? CALL_MEMBER_FN(object, GetReferenceName)() : "";
}

and



registry->RegisterFunction(
new NativeFunction0("GetDisplayName", "ObjectReference", papyrusObjectReference::GetDisplayName, registry));
User avatar
Lakyn Ellery
 
Posts: 3447
Joined: Sat Jan 27, 2007 1:02 pm


Return to V - Skyrim