jaam Posted November 15, 2013 Posted November 15, 2013 At first glance, that would requires "peeking" into bsa to be practical. Maybe later. By the way, use ExtractArgsEx for anything specific to NVSE.
Guest luthienanarion Posted November 15, 2013 Posted November 15, 2013 By the way, use ExtractArgsEx for anything specific to NVSE. It can't be that simple... Here's the function as of now: bool Cmd_FileExists_Execute(COMMAND_ARGS) { *result = 0; std::string pathstring; ExtractArgsEx(EXTRACT_ARGS_EX, &pathstring); if(pathstring == "") _MESSAGE("PATH IS NULL"); else _MESSAGE("EXTRACTED PATH: %s", pathstring); /* Actual file detection code commented out. */ return true; } The script I'm testing it with: scn FileTestQS ref armor string_var meshpath string_var newpath short check begin gamemode set armor to player.geteqobj 5 if(armor) let meshpath := getbipedmodelpath 0 armor let newpath := "blarg/" + meshpath printc "%z" newpath set check to fileexists newpath printc "%g" check endif end ; gamemode The meshpath string outputs to the console as expected, and check is obviously always 0. The plugin's log shows the "PATH IS NULL" message every time the function is called either by the GECK script or the in-game console. I'm sure to be missing something obvious.
jaam Posted November 15, 2013 Posted November 15, 2013 Look up https://sourceforge.net/p/nvseex/code/HEAD/tree/branches/hugues92/nvse_extender.cpp for a pratical example of using strings from a NVSE plugin. functions: Cmd_NX_SetEVSt_Execute Cmd_NX_GetEVSt_Execute Note that strings are passed as char[], not std::string
Xilandro Posted November 15, 2013 Posted November 15, 2013 set armor to player.geteqobj 5 object 5 is a weapon.
DoctaSax Posted November 15, 2013 Posted November 15, 2013 @ waffles: you may also need to go let newpath := sv_construct "blarg/" + meshpath in a non-override block
Guest luthienanarion Posted November 15, 2013 Posted November 15, 2013 Look up https://sourceforge.net/p/nvseex/code/HEAD/tree/branches/hugues92/nvse_extender.cpp for a pratical example of using strings from a NVSE plugin. functions: Cmd_NX_SetEVSt_Execute Cmd_NX_GetEVSt_Execute Note that strings are passed as char[], not std::string I knew it would be something simple. Thanks, jaam. It's been ages since I used C++. set armor to player.geteqobj 5 object 5 is a weapon. That's a typo in the forum post. Clearly, I've been awake too long. @ waffles: you may also need to go let newpath := sv_construct "blarg/" + meshpath in a non-override block I'm not sure what you mean by a "non-override" block. While sv_Construct is required to set a string value using the Set expression, I was under the impression that it was deprecated by Let with regard to strings. I never modded Oblivion, so these functions are all new to me. In better news, the function logs the correct path when called from the console. set check to fileexists newpath This logs the path as the variable name itself instead of the string value of said variable. Passing a string literal (set check to fileexists "foo.bar") works, but using $newpath results in a blank path that isn't detected as NULL. I should probably leave these things to the professionals, but I'm having too much fun with this. Update: Try as I might, I can't get the script to pass a string_var to the function at all. It's treating the name of the variable as a string literal when extracting the argument inside the function. NVSE Extender and PN are the only NVSE plugin sources available to examine, and they (of course) don't have any functions that use string variables as arguments.
Gribbleshnibit8 Posted November 17, 2013 Posted November 17, 2013 Whew, finally. Took long enough, but I finally got pretty much everything done. I'm sure I missed a few functions, and I know they don't all have the info they're supposed to have, but at least the bulk of the work is done. Options for filtering include the function name of course, the alias name, hidden tag values like String, Inventory, Weapon, etc, and the version number. I copied over the info on string and array variables from the OBSE page, so if one of you who knows how they work in FNV could look through those and make sure I got them right that'd be good. I also added in an Examples section that can be given multiple examples of how to use a function. Right now only two functions have examples, sv_Construct, and another of the new ones I forget right now. If anyone has suggestions for examples to be used I'd appreciate it and I'll add them. I'll try to add a form for example suggestion soon. I don't think I have the proper calling conventions on at least some of the new things, possibly most of it. If anyone who knows what the calling convention for the new stuff is could give it a look I'd appreciate it. Anyway, here we go: http://gribbleshnibit8.beastnode.net/projects/NVSEDocs/NVSECommandDocs.htm
Xilandro Posted November 17, 2013 Posted November 17, 2013 here we go: http://gribbleshnibit8.beastnode.net/projects/NVSEDocs/NVSECommandDocs.htm Thanks for the update =) I definitely like it. I hope NVSE will be updated on official site as well.
Gribbleshnibit8 Posted November 18, 2013 Posted November 18, 2013 How much of the expressions and OBSE operator stuff made it in? Both function and Call in the OBSE docs specify multiple args, how is that handled? They only have 1 parameter listed in the output I've got.
jaam Posted November 18, 2013 Posted November 18, 2013 expression: normally, all. Args for functions and calls are theorically "illimited". They are specified inside the script.
Guest carywinton Posted November 21, 2013 Posted November 21, 2013 Kudos to you Pride and Zippy, nice job on the NVSE Extender and NX functions! Very well written instructions as well, I do not see well written instructions very often, it's hard to be a good technical writer and a programmer.
Guest luthienanarion Posted November 22, 2013 Posted November 22, 2013 I've just about given up on this plugin function. Plugin source: #include "nvse/PluginAPI.h" #include "nvse/GameAPI.h" #include "nvse/ParamInfos.h" #include <string> IDebugLog gLog("lutana_nvse.log"); PluginHandle g_pluginHandle = kPluginHandle_Invalid; const std::string gameDir = GetFalloutDirectory(); bool Cmd_FileExists_Execute(COMMAND_ARGS) { *result = 0; char strVar[512]; _MESSAGE(""); _MESSAGE("FILEEXISTS CALLED"); if(ExtractArgsEx(EXTRACT_ARGS_EX, &strVar)) { if(!strVar) _MESSAGE(" PATH IS NULL"); else { _MESSAGE(" EXTRACTED PATH: %s", strVar); Console_Print(" PATH: %s", strVar); std::string filepath = gameDir + "Data/" + strVar; _MESSAGE(" FILE: %s", filepath.c_str()); DWORD attr = GetFileAttributes(filepath.c_str()); if(attr == INVALID_FILE_ATTRIBUTES || (attr & FILE_ATTRIBUTE_DIRECTORY)) { if(IsConsoleMode()) Console_Print("NOT FOUND"); } else { if(IsConsoleMode()) Console_Print("FOUND"); _MESSAGE(" **FOUND**"); *result = 1; } } } else _MESSAGE(" ARGUMENT EXTRACTION FAILED"); return true; } DEFINE_COMMAND_PLUGIN(FileExists, "checks for a file", 0, 1, kParams_OneString); extern "C" { __declspec(dllexport) bool NVSEPlugin_Query(const NVSEInterface * nvse, PluginInfo * info) { info->infoVersion = PluginInfo::kInfoVersion; info->name = "lutana_nvse"; info->version = 1; if(nvse->nvseVersion < 4) { _ERROR("NVSE version too old (got %08X expected at least %08X)", nvse->nvseVersion, 4); return false; } return true; } __declspec(dllexport) bool NVSEPlugin_Load(const NVSEInterface * nvse) { g_pluginHandle = nvse->GetPluginHandle(); nvse->SetOpcodeBase(0x2000); nvse->RegisterCommand(&kCommandInfo_FileExists); return true; } }; GECK script: scn FileTestQS ref oldarmor ref newarmor string_var meshpath float armordur begin gamemode set oldarmor to player.geteqobj 2 if(oldarmor) if(listgetformindex lutADarmor oldarmor == -1) if(listgetformindex lutCHarmor oldarmor == -1) if(listgetformindex lutXXarmor oldarmor == -1) let meshpath := getbipedmodelpath 0 oldarmor let meshpath := "LCWE/" + meshpath messageboxex meshpath ; Displays "meshpath" messageboxex $meshpath ; Displays the correct path string, ie: "LCWE/armor/republicans/republican_02.nif" if(fileexists meshpath || fileexists $meshpath) ; Calling with and without '$' to test the function's _MESSAGE() outputs. set newarmor to tempcloneform oldarmor setbipedmodelpathex "%z" meshpath 0 newarmor listaddform lutADarmor oldarmor listaddform lutCHarmor newarmor set armordur to (player.geteqcurhealth 2) / (gethealth oldarmor) player.unequipitem oldarmor 0 1 player.removeitem oldarmor 1 1 player.additemhealthpercent newarmor 1 armordur 1 player.equipitem newarmor 0 1 else listaddform lutXXarmor oldarmor endif sv_destruct meshpath endif endif endif endif end ; gamemode Log output: fallout root = E:\SteamLibrary\SteamApps\common\fallout new vegas\ FILEEXISTS CALLED EXTRACTED PATH: meshpath FILE: E:\SteamLibrary\SteamApps\common\fallout new vegas\Data/meshpath FILEEXISTS CALLED EXTRACTED PATH: FILE: E:\SteamLibrary\SteamApps\common\fallout new vegas\Data/ Is there something esoteric I have to do to pass the data in a string_var to a plugin function? It works as expected when passed string literals. Given that MessageBoxEx also reads the name of the variable if the $ operator is not used, I thought it would be reasonable to expect that operator to work with FileExists. Maybe I'm just doing something horribly wrong...
DoctaSax Posted November 22, 2013 Posted November 22, 2013 NVSE (non-extender) updated to V4B1 alpha 9 this fixes an issue with being unable to return string & array vars as UDF function values jaam also "changed the example plugin to show the proper way to use ExtractArgEx from plugins due to compiler overrides."
DoctaSax Posted November 22, 2013 Posted November 22, 2013 @waffles: I'm not sure at all here - I just got involved with a bit of testing & I do the uploading in pride's absence - but you may want to try the compiler override (scroll down from here) in order to get fileexists to work with a stringvar. I had to do the same with the GetModIni function that's part of the MCM plugin.
jaam Posted November 22, 2013 Posted November 22, 2013 @waffles: your plugin should work, at least when called with a literal string or a $ prefixed stringvar (the required parameter is a string). I added your function to one of my test plugin with success, though I had to split constructing filepath in 3 lines. (My compiler did not like the + operator but was ok with += ). Also don't forget to add _MESSAGE(" **NOT FOUND**"); on the bad path and make a simplier test to begin like if (fileexists "FalloutNV.esm") But given I can only test with alpha 9, try this also: update to alpha from the first post. None of the changes should matter, but...
jaam Posted November 22, 2013 Posted November 22, 2013 How much of the expressions and OBSE operator stuff made it in? Both function and Call in the OBSE docs specify multiple args, how is that handled? They only have 1 parameter listed in the output I've got. Note that since nvse v4 beta 1 alpha 9 ( ) call return type is defined as Ambiguous, meaning chosen by the function called. This allows returning string_var and array_var from functions.
zippy57 Posted November 22, 2013 Posted November 22, 2013 Kudos to you Pride and Zippy, nice job on the NVSE Extender and NX functions!Don't thank me. All I did was re-upload the file while prideslayer was gone. I had nothing to do with creating the functions. The credit is not mine to take.
Guest luthienanarion Posted November 23, 2013 Posted November 23, 2013 @waffles: your plugin should work, at least when called with a literal string or a $ prefixed stringvar (the required parameter is a string). I added your function to one of my test plugin with success, though I had to split constructing filepath in 3 lines. (My compiler did not like the + operator but was ok with += ). Also don't forget to add _MESSAGE(" **NOT FOUND**"); on the bad path and make a simplier test to begin like if (fileexists "FalloutNV.esm") But given I can only test with alpha 9, try this also: update to alpha from the first post. None of the changes should matter, but... I thought that test was simple. I updated to alpha 9 and ran a simpler test: scn FEtestQS string_var testString begin gamemode if(getgamerestarted) let testString := "DeadMoney.esm" fileexists "FalloutNV.esm" fileexists $testString endif end ; gamemode The log output: fallout root = E:\SteamLibrary\SteamApps\common\fallout new vegas\ FILEEXISTS CALLED EXTRACTED PATH: FalloutNV.esm FILE: E:\SteamLibrary\SteamApps\common\fallout new vegas\Data/FalloutNV.esm **FOUND** FILEEXISTS CALLED EXTRACTED PATH: FILE: E:\SteamLibrary\SteamApps\common\fallout new vegas\Data/ **NOT FOUND** For some reason, the $ operator seems to be passing nothing to the function. $ works fine with MessageBoxEx in my previous test.
jaam Posted November 23, 2013 Posted November 23, 2013 You should not be affected by that, but... Rather than using the ExtractArgEX from gameApi.h, use the one from NVSEScriptInterface. NVSEScriptInterface* g_script; #define ExtractArgsEx(...) g_script->ExtractArgsEx(__VA_ARGS__) #define ExtractFormatStringArgs(...) g_script->ExtractFormatStringArgs(__VA_ARGS__) and initialize g_script from your NVSEPlugin_Load function.
Guest luthienanarion Posted November 23, 2013 Posted November 23, 2013 I could kiss you, jaam. Diverting ExtractArgsEx to NVSEScriptInterface did the trick! Now I get to rewrite LCWE's armor-swapping system in preparation for the NVSE 4 update.
DoctaSax Posted November 29, 2013 Posted November 29, 2013 NVSE (non-extender) updated to v4b1alpha11 fixes some weird sort of "apple bug" that I encountered in a foreach loop mingled with nx_setevfo functions also finishes implementing Update3D, so changes to NPC appearance with setmodelpath etc can be seen immediately.
Guest luthienanarion Posted December 4, 2013 Posted December 4, 2013 NVSE (non-extender) updated to v4b1alpha11 fixes some weird sort of "apple bug" that I encountered in a foreach loop mingled with nx_setevfo functions also finishes implementing Update3D, so changes to NPC appearance with setmodelpath etc can be seen immediately. Calling Update3D on the player seems to move the third-person camera to a point far, far above the player and makes it unusable. Subsequent calls increase the distance even further.
jaam Posted December 5, 2013 Posted December 5, 2013 It should be noted that calling Update3D on the player has unpredicted result (ie please don't) The issue did not seem to be solved in Oblivion.
shegontal1 Posted December 30, 2013 Posted December 30, 2013 Idk if this has been addressed before, but I'm trying to modify NVSE scripts in GECK, but for some reason, the moment a change is made, they refuse to save, even if I delete or undo all changes. I think it is because my NVSE extender files are not loading correctly, but I am at a complete loss as to why not. I have the proper beta files for NVSE and all my files are in the correct plugins folder. I know it has to do with NVSE because regular mods save just fine and in mod scripts, if I delete all NVSE chunks from it and still keep it as a functioning script, it saves as well. I even have Power Up installed in the hopes it would give me an error or a clue as to why it is not loading, but to no avail. If anyone can help, I'd really appreciate it. I'm going to paste my nvse log into this, becuase I think it has something to do with the nvse_extender_ng.dll not loading.... NVSE runtime: initialize (version = 3.0.2 040020D0 01CF0585318CF53A)imagebase = 00400000fallout root = C:\Program Files (x86)\Steam\steamapps\common\fallout new vegas\plugin directory = C:\Program Files (x86)\Steam\steamapps\common\fallout new vegas\Data\NVSE\Plugins\checking plugin C:\Program Files (x86)\Steam\steamapps\common\fallout new vegas\Data\NVSE\Plugins\\MCM.dllSetOpcodeBase 000021C0RegisterCommand GetModINISetting (21C0)RegisterCommand SetModINISetting (21C1)RegisterCommand GetMCMFloat (21C2)RegisterCommand SetMCMFloat (21C3)RegisterCommand SetMCMString (21C4)RegisterCommand SetMCMFloatMass (21C5)RegisterCommand SetMCMStringMass (21C6)RegisterCommand SetMCMModList (21C7)RegisterCommand GetMCMListWidth (21C8)plugin C:\Program Files (x86)\Steam\steamapps\common\fallout new vegas\Data\NVSE\Plugins\\MCM.dll (00000001 MCM Extensions 00000001) loaded correctlychecking plugin C:\Program Files (x86)\Steam\steamapps\common\fallout new vegas\Data\NVSE\Plugins\\nvse_extender.dllSetOpcodeBase 00002140RegisterCommand NX_GetVersion (2140)RegisterCommand NX_IsUsingSkeleton (2141)RegisterCommand NX_IsInList (2142)RegisterCommand NX_SetEVFl (2143)RegisterCommand NX_GetEVFl (2144)RegisterCommand NX_SetEVFo (2145)RegisterCommand NX_GetEVFo (2146)RegisterCommand NX_GetConversationPartner (2147)RegisterCommand NX_ClrEVFl (2148)RegisterCommand NX_ClrEVFo (2149)register plugin listener for NVSEplugin C:\Program Files (x86)\Steam\steamapps\common\fallout new vegas\Data\NVSE\Plugins\\nvse_extender.dll (00000001 Extensions for NVSE 0000000B) loaded correctlychecking plugin C:\Program Files (x86)\Steam\steamapps\common\fallout new vegas\Data\NVSE\Plugins\\nvse_extender_ng.dllplugin C:\Program Files (x86)\Steam\steamapps\common\fallout new vegas\Data\NVSE\Plugins\\nvse_extender_ng.dll (00000001 Extensions for NVSE 0000000B) reported as incompatible during querychecking plugin C:\Program Files (x86)\Steam\steamapps\common\fallout new vegas\Data\NVSE\Plugins\\pn_nvse.dllSetOpcodeBase 00002125RegisterCommand PN_GetProjectileExplosion (2125)RegisterCommand PN_GetExplosionDamage (2126)RegisterCommand PN_GetExplosionForce (2127)RegisterCommand PN_SetExplosionDamage (2128)RegisterCommand PN_SetExplosionForce (2129)RegisterCommand PN_ListClear (212A)RegisterCommand PN_GetActorBaseFlagsLow (212B)RegisterCommand PN_SetConditionDamagePenalty (212C)RegisterCommand PN_GetConditionDamagePenalty (212D)plugin C:\Program Files (x86)\Steam\steamapps\common\fallout new vegas\Data\NVSE\Plugins\\pn_nvse.dll (00000001 pn_nvse 00000002) loaded correctly
Recommended Posts