Created
September 30, 2017 23:34
-
-
Save Scrivener07/60b5098a221752e5807b3611a7a0d756 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "f4se/GameAPI.h" | |
#include "f4se/GameData.h" | |
#include "f4se/PapyrusNativeFunctions.h" | |
#include "f4se/PapyrusVM.h" | |
#include "f4se/PluginAPI.h" | |
#include "f4se_common/f4se_version.h" | |
#include "main.h" | |
#include <shlobj.h> | |
#include <string> | |
#define SCRIPT_NAME "Secret" | |
std::string mName = "template"; | |
IDebugLog gLog; | |
PluginHandle g_pluginHandle = kPluginHandle_Invalid; | |
F4SEPapyrusInterface *g_papyrus = NULL; | |
// Papyrus | |
// --------------------------------------------- | |
bool RegisterPapyrus(VirtualMachine *vm) | |
{ | |
RegisterFuncs(vm); | |
_MESSAGE("Registered Papyrus native functions."); | |
return true; | |
} | |
void RegisterFuncs(VirtualMachine* vm) | |
{ | |
vm->RegisterFunction(new NativeFunction0<StaticFunctionTag, UInt32>("GetSecretNumber", SCRIPT_NAME, GetSecretNumber, vm)); | |
vm->SetFunctionFlags(SCRIPT_NAME, "GetSecretNumber", IFunction::kFunctionFlag_NoWait); | |
} | |
UInt32 GetSecretNumber(StaticFunctionTag* base) | |
{ | |
return 42; | |
} | |
void logMessage(std::string aString) | |
{ | |
_MESSAGE(("["+mName+"] "+aString).c_str()); | |
} | |
// Plugin | |
// --------------------------------------------- | |
extern "C" | |
{ | |
bool F4SEPlugin_Query(const F4SEInterface * f4se, PluginInfo * info) | |
{ | |
gLog.OpenRelative(CSIDL_MYDOCUMENTS, (const char*)("\\My Games\\Fallout4\\F4SE\\"+ mName +".log").c_str()); | |
logMessage("v1.0"); | |
logMessage("query"); | |
// populate info structure | |
info->infoVersion = PluginInfo::kInfoVersion; | |
info->name = mName.c_str(); | |
info->version = 1; | |
// store plugin handle so we can identify ourselves later | |
g_pluginHandle = f4se->GetPluginHandle(); | |
// Check game version | |
if (f4se->runtimeVersion != RUNTIME_VERSION_1_10_26) { | |
_WARNING("WARNING: Unsupported runtime version %08X. This DLL is built for v1.10.26 only.", f4se->runtimeVersion); | |
MessageBox(NULL, (LPCSTR)("Unsupported runtime version (expected v1.10.26). \n"+mName+" will be disabled.").c_str(), (LPCSTR)mName.c_str(), MB_OK | MB_ICONEXCLAMATION); | |
return false; | |
} | |
// Get the papyrus interface | |
g_papyrus = (F4SEPapyrusInterface *)f4se->QueryInterface(kInterface_Papyrus); | |
if (!g_papyrus) { | |
_MESSAGE("couldn't get papyrus interface"); | |
return false; | |
} | |
return true; | |
} | |
bool F4SEPlugin_Load(const F4SEInterface *f4se) | |
{ | |
logMessage("load"); | |
g_papyrus->Register(RegisterPapyrus); | |
return true; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
void RegisterFuncs(VirtualMachine* vm); | |
UInt32 GetSecretNumber(StaticFunctionTag* base); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment