Difference between revisions of "Tutorial: String Variables 6"
imported>Odessa (Created page with "This is the sixth article in a tutorial on string variables. ==Passing String Variables as parameters: ToString ($)== If a vanilla or NVSE...") |
imported>Odessa m (cat) |
||
Line 1: | Line 1: | ||
This is the sixth article in a [[Tutorial: String Variables|tutorial]] on [[string variables]]. | This is the sixth article in a [[Tutorial: String Variables|tutorial series]] on [[string variables]]. | ||
==Passing String Variables as parameters: ToString ($)== | ==Passing String Variables as parameters: ToString ($)== | ||
Line 55: | Line 55: | ||
==External Links== | ==External Links== | ||
*[http://www.loverslab.com/topic/26963-tutorial-nvse4-part-3-string-variables/ The original text of this page was adapted with permission from this source] | *[http://www.loverslab.com/topic/26963-tutorial-nvse4-part-3-string-variables/ The original text of this page was adapted with permission from this source] | ||
[[Category:String Variables]] |
Revision as of 11:52, 27 June 2014
This is the sixth article in a tutorial series on string variables.
Passing String Variables as parameters: ToString ($)
If a vanilla or NVSE function takes one or more formatted strings as parameters:
DebugPrint "I'm a string" MessageEX "I'm a string" SetModelPathEX "Clutter\Junk\WhetStone.NIF" NX_SetEVFl "some nx key string" someFloat NX_SetEVSt "some nx key string" "some string value"
you can force them to take a string variable as parameter instead with the ToString function, in short: $
DebugPrint $sv_stringvar MessageEX $sv_stringvar SetModelPathEX $sv_stringvar NX_SetEVFl $sv_keystringvar someFloat NX_SetEVSt $sv_keystringvar $sv_valuestringvar
There are a few functions, especially fallout-specific ones and ones that are injected with NVSE plugins like MCM, that may not seem to work with ToString + string var that way - this is because they probably haven't been prepped for that. If you think this is the case in your script, try using the script compiler override, which should force it.
The ToString function can also return a string representation of numbers and forms, ie pass them to a string:
It will return the name of a form if the form has a name:
let rRef := DocMitchellRef let sv_name := $rRef printc "%z" sv_name
--> displays 'Doc Mitchell'
Or its hex FormID if it doesn't:
let rRef := BlackBoardMarker let sv_name := $rRef printc "%z" sv_name
--> displays '00002FCC'
Numbers:
let iInt := 32 let sv_name := $iInt printc "%z" sv_name
--> displays '32'
Tutorial part 7: Concatanating string vars, or adding them up