RunScriptSnippet
From GECK
A function added by the JIP NVSE Plugin.
Description
Constructs, compiles and runs the script source in the formatted string.
- The script is executed immediately or, if the delayTime argument is non-zero, is deferred for the specified number of frames.
- The script should follow the same structure rules as Result Scripts (of quest stages, dialogue topics, etc.), and may include local variables and if/else statements.
- If the function is called on a reference (implicitly/explicitly), the script will be called on that same reference (passed as "this" and returned by GetSelf). Otherwise, it will be called on the player (see examples, below).
- When used skillfully, this function can generate and run fully customizable scripts.
Syntax
reference.RunScriptSnippet delayTime:int scriptSource:formattedString formatVars(up to 20)
Example
set rItem to Ammo12GaSlug set iCount to 50 CraigBooneRef.RunScriptSnippet 5 "ref rItem%rint iCount%rset rItem to %q%i%q%rset iCount to %g%rif GetItemCount rItem < iCount%rAddItem rItem iCount%rendif" rItem iCount
Will generate the following script, executed after a 5 frames delay, using CraigBooneRef as the calling reference:
ref rItem int iCount set rItem to "0013E447" set iCount to 50 if GetItemCount rItem < iCount AddItem rItem iCount endif
Notes:
- The %r format specifier must be used to indicate a new line.
- When using forms/references, the Form ID must be passed (not the Editor ID), enclosed in double quotation marks (using the %q specifier).