This post showcases soon™-to-be-documented JIP LN NVSE script runner. This feature is already included and enabled in JIP LN NVSE, and can be used right now.
Instead of running init quests in Menu Mode 4 or GameMode, you can add event listeners via batch scripts. JIP LN NVSE scans the directory Data\nvse\plugins\scripts and runs files with certain prefixes on the following events:
- gr_*.txt on game start,
- gl_*.txt on game load,
- gs_*.txt on game save,
- gx_*.txt on game exit,
- xm_*.txt on exit to the main menu,
- gn_*.txt on new game (as of JIP LN 56.34).
Seems like they share scripting abilities with RunBatchScript, meaning local variables and if/else support. As of xNVSE 6.21, text scripts support practically full range of NVSE expressions, including loops and lambdas.
What’s the catch?
These files are executed in the console environment, hence no resolution of Editor IDs by default, only Form IDs are allowed. There are a few ways to circumvent this.
Method one – use JohnnyGuitar NVSE with bLoadEditorIDs=1.
This method implies, that your mod already depends on JohnnyGuitar NVSE and contains explicit instructions for users to keep bLoadEditorIDs enabled. With JG, you can run scripts by their Editor IDs.
Running them directly As of xNVSE 6.0,
call MyEditorID is not very reliable by my tests, but RunScript works fine.
call is working as expected from console.
Method two – determine your mod’s index, using a global variable, build reference variable for your UDF with BuildRef and run it.
int i ref rUDF set i to GetSourceModIndex AutorunDemoGlobal set rUDF to BuildRef i 5719 call rUDF
In this method, we utilize availability of global variables in the console.
- Create one constant global variable in your mod with any value and replace AutorunDemoGlobal with it.
- Now we need Form ID of your user defined function in decimal representation. Open FNVEdit, you’ll see something like this 00004240 – the first two symbols are load-order-dependent mod index, last six are the form ID of your UDF. We need the latter. Paste them into any hex-to-dec convertor, for instance, this one, and get a number. Insert it in place of 5719 in the example.
Done, you can now use all NVSE features. A potential disadvantage here is the possibility of Form ID renumbering during mod merging.
Method three – use GetFormFromMod for vanilla and unmergeable mods.
If you want to modify only vanilla items or know for sure, that no one in their right mind will merge the target mod, then literal Form IDs for FalloutNV.esm, or GetFormFromMod and StringToRef for other plugins are perfectly fine. Let’s remove the quest flag from Rocket Souvenir:
SetFlagsLow 0 "0008E665"
Or make Stealth Suit Mk II a light armor:
ref rArmor set rArmor to GetFormFromMod "OldWorldBlues.esm" "C12F" SetArmorClass rArmor 1 SetWeight 17 rArmor SetArmorAR 9 rArmor
Easy road – declare your mod unmergeable.
ref rUDF set rUDF to GetFormFromMod "MyCoolMod.esp" "800" call rUDF
ref rOnDrink set rOnDrink to GetFormFromMod "MyCoolMod.esp" "800" SetOnUseAidItemEventHandler rOnDrink 1 "0005C365" ; AlchoholicDrinks